本文整理汇总了Java中org.apache.maven.artifact.repository.metadata.Snapshot.getBuildNumber方法的典型用法代码示例。如果您正苦于以下问题:Java Snapshot.getBuildNumber方法的具体用法?Java Snapshot.getBuildNumber怎么用?Java Snapshot.getBuildNumber使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.maven.artifact.repository.metadata.Snapshot
的用法示例。
在下文中一共展示了Snapshot.getBuildNumber方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: constructVersion
import org.apache.maven.artifact.repository.metadata.Snapshot; //导入方法依赖的package包/类
protected String constructVersion( Versioning versioning, String baseVersion )
{
String version = null;
Snapshot snapshot = versioning.getSnapshot();
if ( snapshot != null )
{
if ( snapshot.getTimestamp() != null && snapshot.getBuildNumber() > 0 )
{
String newVersion = snapshot.getTimestamp() + "-" + snapshot.getBuildNumber();
version = StringUtils.replace( baseVersion, Artifact.SNAPSHOT_VERSION, newVersion );
}
else
{
version = baseVersion;
}
}
return version;
}
示例2: getBuildNumber
import org.apache.maven.artifact.repository.metadata.Snapshot; //导入方法依赖的package包/类
private static int getBuildNumber( Metadata metadata )
{
int number = 0;
Versioning versioning = metadata.getVersioning();
if ( versioning != null )
{
Snapshot snapshot = versioning.getSnapshot();
if ( snapshot != null && snapshot.getBuildNumber() > 0 )
{
number = snapshot.getBuildNumber();
}
}
return number;
}
示例3: getLastBuildNumber
import org.apache.maven.artifact.repository.metadata.Snapshot; //导入方法依赖的package包/类
/**
* @return The last build number for snapshot version. 0 if maven-metadata not found for the path.
*/
private int getLastBuildNumber(RepoPath repoPath) {
int buildNumber = 0;
try {
// get the parent path which should contains the maven-metadata
RepoPath parentRepoPath = repoPath.getParent();
RepositoryService repoService = ContextHelper.get().getRepositoryService();
RepoPathImpl mavenMetadataPath = new RepoPathImpl(parentRepoPath, MavenNaming.MAVEN_METADATA_NAME);
if (repoService.exists(mavenMetadataPath)) {
String mavenMetadataStr = repoService.getStringContent(mavenMetadataPath);
Metadata metadata = MavenModelUtils.toMavenMetadata(mavenMetadataStr);
Versioning versioning = metadata.getVersioning();
if (versioning != null) {
Snapshot snapshot = versioning.getSnapshot();
if (snapshot != null) {
buildNumber = snapshot.getBuildNumber();
}
}
} else {
// ok probably not found. just log
log.debug("No maven metadata found for {}.", repoPath);
}
} catch (Exception e) {
log.error("Cannot obtain build number from metadata.", e);
}
return buildNumber;
}
示例4: merge
import org.apache.maven.artifact.repository.metadata.Snapshot; //导入方法依赖的package包/类
private void merge( Artifact artifact, Map<String, VersionInfo> infos, Versioning versioning,
ArtifactRepository repository )
{
if ( StringUtils.isNotEmpty( versioning.getRelease() ) )
{
merge( RELEASE, infos, versioning.getLastUpdated(), versioning.getRelease(), repository );
}
if ( StringUtils.isNotEmpty( versioning.getLatest() ) )
{
merge( LATEST, infos, versioning.getLastUpdated(), versioning.getLatest(), repository );
}
for ( SnapshotVersion sv : versioning.getSnapshotVersions() )
{
if ( StringUtils.isNotEmpty( sv.getVersion() ) )
{
String key = getKey( sv.getClassifier(), sv.getExtension() );
merge( SNAPSHOT + key, infos, sv.getUpdated(), sv.getVersion(), repository );
}
}
Snapshot snapshot = versioning.getSnapshot();
if ( snapshot != null && versioning.getSnapshotVersions().isEmpty() )
{
String version = artifact.getVersion();
if ( snapshot.getTimestamp() != null && snapshot.getBuildNumber() > 0 )
{
String qualifier = snapshot.getTimestamp() + '-' + snapshot.getBuildNumber();
version = version.substring( 0, version.length() - SNAPSHOT.length() ) + qualifier;
}
merge( SNAPSHOT, infos, versioning.getLastUpdated(), version, repository );
}
}
示例5: compare
import org.apache.maven.artifact.repository.metadata.Snapshot; //导入方法依赖的package包/类
@Override
public int compare(Snapshot o1, Snapshot o2) {
int buildNumber1 = o1.getBuildNumber();
int buildNumber2 = o2.getBuildNumber();
return buildNumber1 - buildNumber2;
}
示例6: getRequestContext
import org.apache.maven.artifact.repository.metadata.Snapshot; //导入方法依赖的package包/类
/**
* Downloads maven-metadata.xml from the remote and analyzes the latest version from it. If it does not exist, we
* return the original request context.
*/
@Override
protected InternalRequestContext getRequestContext(InternalRequestContext requestContext, Repo repo,
ModuleInfo originalModuleInfo) {
if (!(repo instanceof RemoteRepo)) {
return requestContext;
}
RemoteRepo remoteRepo = (RemoteRepo) repo;
if (!remoteRepo.getDescriptor().isMavenRepoLayout()) {
// Latest from remote is supported only for maven2 layout
return requestContext;
}
if (remoteRepo.isOffline()) {
// will fallback to local cache search
return requestContext;
}
String path = requestContext.getResourcePath();
if (MavenNaming.isMavenMetadata(path)) {
// Recursive request for maven metadata, simply return the original request context
return requestContext;
}
boolean searchForReleaseVersion = StringUtils.contains(path, "[RELEASE]");
RepoPath repoPath;
if (searchForReleaseVersion) {
repoPath = InternalRepoPathFactory.create(repo.getKey(), path).getParent();
} else {
repoPath = InternalRepoPathFactory.create(repo.getKey(), path);
}
Metadata metadata = tryDownloadingMavenMetadata(repoPath);
if (metadata != null) {
try {
Versioning versioning = metadata.getVersioning();
if (versioning != null) {
if (searchForReleaseVersion) {
String release = versioning.getRelease();
if (StringUtils.isNotBlank(release)) {
String releaseRepoPath = path.replace("[RELEASE]", release);
requestContext = translateRepoRequestContext(requestContext, repo, releaseRepoPath);
}
} else {
Snapshot snapshot = versioning.getSnapshot();
if (snapshot != null) {
String timestamp = snapshot.getTimestamp();
int buildNumber = snapshot.getBuildNumber();
if (StringUtils.isNotBlank(timestamp) && buildNumber > 0) {
String originalFileName = PathUtils.getFileName(path);
String fileName = originalFileName.replaceFirst("SNAPSHOT",
timestamp + "-" + buildNumber);
RepoPath parentRepoPath = repoPath.getParent();
String uniqueRepoPath = PathUtils.addTrailingSlash(parentRepoPath.getPath()) + fileName;
requestContext = translateRepoRequestContext(requestContext, repo, uniqueRepoPath);
}
}
}
}
} catch (Exception e) {
log.warn("Failed parsing maven metadata from remote repo '{}' for repoPath '{}'",
repoPath.getRepoKey(), repoPath.getPath());
}
}
return requestContext;
}