当前位置: 首页>>代码示例>>Java>>正文


Java Snapshot.setBuildNumber方法代码示例

本文整理汇总了Java中org.apache.maven.artifact.repository.metadata.Snapshot.setBuildNumber方法的典型用法代码示例。如果您正苦于以下问题:Java Snapshot.setBuildNumber方法的具体用法?Java Snapshot.setBuildNumber怎么用?Java Snapshot.setBuildNumber使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.maven.artifact.repository.metadata.Snapshot的用法示例。


在下文中一共展示了Snapshot.setBuildNumber方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: buildSnapshotMavenMetadata

import org.apache.maven.artifact.repository.metadata.Snapshot; //导入方法依赖的package包/类
/**
 * Build custom maven-metadata.xml according to a specific version.
 *
 * @param moduleInfo The original {@code ModuleInfo} to assemble the maven metadata according to the same
 *                   gid,aid,and version, {@link org.apache.maven.artifact.repository.metadata.Versioning#setLastUpdatedTimestamp(java.util.Date)} is updated to now. and
 *                   the build number and timestamp in the {@link org.apache.maven.artifact.repository.metadata.Snapshot} is set according to the name.
 * @param fileName   The file name
 * @return The custom maven-metadata.xml
 */
public static Metadata buildSnapshotMavenMetadata(ModuleInfo moduleInfo, String fileName) {
    Metadata metadata = new Metadata();
    metadata.setGroupId(moduleInfo.getOrganization());
    metadata.setArtifactId(moduleInfo.getModule());
    metadata.setVersion(moduleInfo.getBaseRevision() + "-" + moduleInfo.getFolderIntegrationRevision());
    Versioning versioning = new Versioning();
    metadata.setVersioning(versioning);
    versioning.setLastUpdatedTimestamp(new Date());
    Snapshot snapshot = new Snapshot();
    versioning.setSnapshot(snapshot);
    snapshot.setBuildNumber(MavenNaming.getUniqueSnapshotVersionBuildNumber(fileName));
    snapshot.setTimestamp(MavenNaming.getUniqueSnapshotVersionTimestamp(fileName));
    if (ConstantValues.mvnMetadataVersion3Enabled.getBoolean()) {
        SnapshotVersion snapshotVersion = new SnapshotVersion();
        snapshotVersion.setUpdated(StringUtils.remove(snapshot.getTimestamp(), '.'));
        snapshotVersion.setVersion(moduleInfo.getBaseRevision() + "-" +
                moduleInfo.getFileIntegrationRevision());
        //Should always be a pom, since this method is called only by PropertiesAddonImpl.assembleDynamicMetadata
        snapshotVersion.setExtension(moduleInfo.getExt());
        versioning.setSnapshotVersions(Lists.newArrayList(snapshotVersion));
    }
    return metadata;
}
 
开发者ID:alancnet,项目名称:artifactory,代码行数:33,代码来源:MavenModelUtils.java

示例2: v

import org.apache.maven.artifact.repository.metadata.Snapshot; //导入方法依赖的package包/类
private Metadata v(final String groupId,
                   final String artifactId,
                   final String versionPrefix,
                   final String timestamp,
                   final int buildNumber)
{
  final Metadata m = new Metadata();
  m.setGroupId(groupId);
  m.setArtifactId(artifactId);
  m.setVersion(versionPrefix + "-SNAPSHOT");
  m.setVersioning(new Versioning());
  final Versioning mv = m.getVersioning();
  mv.setLastUpdated(timestamp.replace(".", ""));
  final Snapshot snapshot = new Snapshot();
  snapshot.setTimestamp(timestamp);
  snapshot.setBuildNumber(buildNumber);
  mv.setSnapshot(snapshot);
  final SnapshotVersion pom = new SnapshotVersion();
  pom.setExtension("pom");
  pom.setVersion(versionPrefix + "-" + timestamp + "-" + buildNumber);
  pom.setUpdated(timestamp);
  mv.getSnapshotVersions().add(pom);

  final SnapshotVersion jar = new SnapshotVersion();
  jar.setExtension("jar");
  jar.setVersion(versionPrefix + "-" + timestamp + "-" + buildNumber);
  jar.setUpdated(timestamp);
  mv.getSnapshotVersions().add(jar);

  final SnapshotVersion sources = new SnapshotVersion();
  sources.setExtension("jar");
  sources.setClassifier("sources");
  sources.setVersion(versionPrefix + "-" + timestamp + "-" + buildNumber);
  sources.setUpdated(timestamp);
  mv.getSnapshotVersions().add(sources);

  return m;
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:39,代码来源:RepositoryMetadataMergerTest.java

示例3: transformForDeployment

import org.apache.maven.artifact.repository.metadata.Snapshot; //导入方法依赖的package包/类
public void transformForDeployment( Artifact artifact, ArtifactRepository remoteRepository,
                                    ArtifactRepository localRepository )
    throws ArtifactDeploymentException
{
    if ( artifact.isSnapshot() )
    {
        Snapshot snapshot = new Snapshot();

        snapshot.setTimestamp( getDeploymentTimestamp() );

        // we update the build number anyway so that it doesn't get lost. It requires the timestamp to take effect
        try
        {
            int buildNumber = resolveLatestSnapshotBuildNumber( artifact, localRepository, remoteRepository );

            snapshot.setBuildNumber( buildNumber + 1 );
        }
        catch ( RepositoryMetadataResolutionException e )
        {
            throw new ArtifactDeploymentException( "Error retrieving previous build number for artifact '"
                + artifact.getDependencyConflictId() + "': " + e.getMessage(), e );
        }

        RepositoryMetadata metadata = new SnapshotArtifactRepositoryMetadata( artifact, snapshot );

        artifact.setResolvedVersion(
            constructVersion( metadata.getMetadata().getVersioning(), artifact.getBaseVersion() ) );

        artifact.addMetadata( metadata );
    }
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:32,代码来源:SnapshotTransformation.java

示例4: createSnapshotsMetadata

import org.apache.maven.artifact.repository.metadata.Snapshot; //导入方法依赖的package包/类
private boolean createSnapshotsMetadata(RepoPath repoPath, ItemNode treeNode) {
    if (!folderContainsPoms(treeNode)) {
        return false;
    }
    List<ItemNode> folderItems = treeNode.getChildren();
    Iterable<ItemNode> poms = Iterables.filter(folderItems, new Predicate<ItemNode>() {
        @Override
        public boolean apply(@Nullable ItemNode input) {
            return (input != null) && MavenNaming.isPom(input.getItemInfo().getName());
        }
    });

    RepoPath firstPom = poms.iterator().next().getRepoPath();
    MavenArtifactInfo artifactInfo = MavenArtifactInfo.fromRepoPath(firstPom);
    if (!artifactInfo.isValid()) {
        return true;
    }
    Metadata metadata = new Metadata();
    metadata.setGroupId(artifactInfo.getGroupId());
    metadata.setArtifactId(artifactInfo.getArtifactId());
    metadata.setVersion(artifactInfo.getVersion());
    Versioning versioning = new Versioning();
    metadata.setVersioning(versioning);
    versioning.setLastUpdatedTimestamp(new Date());
    Snapshot snapshot = new Snapshot();
    versioning.setSnapshot(snapshot);

    LocalRepoDescriptor localRepoDescriptor =
            getRepositoryService().localOrCachedRepoDescriptorByKey(repoPath.getRepoKey());
    SnapshotVersionBehavior snapshotBehavior = localRepoDescriptor.getSnapshotVersionBehavior();
    String latestUniquePom = getLatestUniqueSnapshotPomName(poms);
    if (snapshotBehavior.equals(SnapshotVersionBehavior.NONUNIQUE) ||
            (snapshotBehavior.equals(SnapshotVersionBehavior.DEPLOYER) && latestUniquePom == null)) {
        snapshot.setBuildNumber(1);
    } else if (snapshotBehavior.equals(SnapshotVersionBehavior.UNIQUE)) {
        // take the latest unique snapshot file file
        if (latestUniquePom != null) {
            snapshot.setBuildNumber(MavenNaming.getUniqueSnapshotVersionBuildNumber(latestUniquePom));
            snapshot.setTimestamp(MavenNaming.getUniqueSnapshotVersionTimestamp(latestUniquePom));
        }

        if (ConstantValues.mvnMetadataVersion3Enabled.getBoolean()) {
            List<SnapshotVersion> snapshotVersions = Lists.newArrayList(getFolderItemSnapshotVersions(folderItems));
            if (!snapshotVersions.isEmpty()) {
                versioning.setSnapshotVersions(snapshotVersions);
            }
        }
    }
    saveMetadata(repoPath, metadata);
    return true;
}
 
开发者ID:alancnet,项目名称:artifactory,代码行数:52,代码来源:MavenMetadataCalculator.java

示例5: merge

import org.apache.maven.artifact.repository.metadata.Snapshot; //导入方法依赖的package包/类
public void merge(Metadata otherMetadata, RepoResource foundResource) {
    long otherLastModified = foundResource.getLastModified();
    if (metadata == null) {
        metadata = otherMetadata;
        lastModified = otherLastModified;
        if (!mergeSnapshotVersions) {
            Versioning versioning = metadata.getVersioning();
            if (versioning != null) {
                versioning.setSnapshotVersions(null);
            }
        }
    } else {
        metadata.merge(otherMetadata);
        lastModified = Math.max(otherLastModified, lastModified);

        Versioning existingVersioning = metadata.getVersioning();
        if (existingVersioning != null) {
            List<String> versions = existingVersioning.getVersions();
            if (!CollectionUtils.isNullOrEmpty(versions)) {
                try {
                    Collections.sort(versions, new MavenVersionComparator());
                } catch (IllegalArgumentException e) {
                    // New Java 7 TimSort is pointing out the non transitive behavior
                    // of the Mercury version comparator => Doing fallback to natural string order
                    log.info(
                            "Hitting Mercury version comparator non transitive behavior message='" + e.getMessage() + "'");
                    if (log.isDebugEnabled()) {
                        log.debug("The lists of versions is: " + versions);
                    }
                    Collections.sort(versions);
                }
                // latest is simply the last (be it snapshot or release version)
                String latestVersion = versions.get(versions.size() - 1);
                existingVersioning.setLatest(latestVersion);

                // release is the latest non snapshot version
                for (String version : versions) {
                    if (!MavenNaming.isSnapshot(version)) {
                        existingVersioning.setRelease(version);
                    }
                }
            }
            SnapshotComparator comparator = MavenMetadataCalculator.createSnapshotComparator();
            // if there's a unique snapshot version prefer the one with the bigger build number
            Snapshot snapshot = existingVersioning.getSnapshot();
            Versioning otherMetadataVersioning = otherMetadata.getVersioning();
            if (otherMetadataVersioning != null) {
                Snapshot otherSnapshot = otherMetadataVersioning.getSnapshot();
                if (snapshot != null && otherSnapshot != null) {
                    if (comparator.compare(otherSnapshot, snapshot) > 0) {
                        snapshot.setBuildNumber(otherSnapshot.getBuildNumber());
                        snapshot.setTimestamp(otherSnapshot.getTimestamp());
                    }
                }
                if (mergeSnapshotVersions) {
                    addSnapshotVersions(existingVersioning, otherMetadataVersioning);
                }
            }
        }
    }
}
 
开发者ID:alancnet,项目名称:artifactory,代码行数:62,代码来源:MergeableMavenMetadata.java


注:本文中的org.apache.maven.artifact.repository.metadata.Snapshot.setBuildNumber方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。