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


Java Versioning类代码示例

本文整理汇总了Java中org.apache.maven.artifact.repository.metadata.Versioning的典型用法代码示例。如果您正苦于以下问题:Java Versioning类的具体用法?Java Versioning怎么用?Java Versioning使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Versioning类属于org.apache.maven.artifact.repository.metadata包,在下文中一共展示了Versioning类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: a

import org.apache.maven.artifact.repository.metadata.Versioning; //导入依赖的package包/类
private Metadata a(final String groupId,
                   final String artifactId,
                   final String lastUpdated,
                   final String latest,
                   final String release,
                   final String... versions)
{
  final Metadata m = new Metadata();
  m.setGroupId(groupId);
  m.setArtifactId(artifactId);
  m.setVersioning(new Versioning());
  final Versioning mv = m.getVersioning();
  if (!Strings.isNullOrEmpty(lastUpdated)) {
    mv.setLastUpdated(lastUpdated);
  }
  if (!Strings.isNullOrEmpty(latest)) {
    mv.setLatest(latest);
  }
  if (!Strings.isNullOrEmpty(release)) {
    mv.setRelease(release);
  }
  mv.getVersions().addAll(Arrays.asList(versions));
  return m;
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:25,代码来源:RepositoryMetadataMergerTest.java

示例2: buildSnapshotMavenMetadata

import org.apache.maven.artifact.repository.metadata.Versioning; //导入依赖的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

示例3: buildReleasesMavenMetadata

import org.apache.maven.artifact.repository.metadata.Versioning; //导入依赖的package包/类
public static Metadata buildReleasesMavenMetadata(String organization, String module,
        SortedSet<String> sortedVersions) {
    Metadata metadata = new Metadata();
    metadata.setGroupId(organization);
    metadata.setArtifactId(module);
    if (!sortedVersions.isEmpty()) {
        metadata.setVersion(sortedVersions.first());
        Versioning versioning = new Versioning();
        metadata.setVersioning(versioning);
        versioning.setVersions(Lists.newArrayList(sortedVersions));
        versioning.setLastUpdatedTimestamp(new Date());
        versioning.setLatest(sortedVersions.last());
        versioning.setRelease(sortedVersions.last());
    }
    return metadata;
}
 
开发者ID:alancnet,项目名称:artifactory,代码行数:17,代码来源:MavenModelUtils.java

示例4: validStringToMetadata

import org.apache.maven.artifact.repository.metadata.Versioning; //导入依赖的package包/类
public void validStringToMetadata() throws IOException {
    Metadata metadata = MavenModelUtils.toMavenMetadata(
            "<metadata>\n" +
                    "<groupId>boo</groupId>\n" +
                    "<artifactId>boo</artifactId>\n" +
                    "<version>0.7.0.1921</version>\n" +
                    "<versioning>\n" +
                    "<versions>\n" +
                    "<version>0.7.0.1921</version>\n" +
                    "</versions>\n" +
                    "</versioning>\n" +
                    "</metadata>");

    assertEquals(metadata.getGroupId(), "boo");
    Versioning versioning = metadata.getVersioning();
    assertNotNull(versioning);
    assertEquals(versioning.getVersions().size(), 1);
}
 
开发者ID:alancnet,项目名称:artifactory,代码行数:19,代码来源:MavenModelUtilsTest.java

示例5: addSnapshotVersions

import org.apache.maven.artifact.repository.metadata.Versioning; //导入依赖的package包/类
private void addSnapshotVersions(Versioning existingVersioning, Versioning otherMetadataVersioning) {
    //Maven metadata merge function does not include snapshot version (https://jira.codehaus.org/browse/MNG-5180)
    SnapshotComparator comparator = MavenMetadataCalculator.createSnapshotComparator();
    List<SnapshotVersion> otherSnapshotVersions = otherMetadataVersioning.getSnapshotVersions();
    if ((otherSnapshotVersions != null) && !otherSnapshotVersions.isEmpty()) {

        List<SnapshotVersion> existingSnapshotVersions = existingVersioning.getSnapshotVersions();
        if ((existingSnapshotVersions == null) || existingSnapshotVersions.isEmpty()) {
            existingVersioning.setSnapshotVersions(otherSnapshotVersions);
        } else {
            for (SnapshotVersion otherSnapshotVersion : otherSnapshotVersions) {
                for (SnapshotVersion existingSnapshotVersion : existingSnapshotVersions) {
                    if (snapshotVersionClassifiersEqual(otherSnapshotVersion, existingSnapshotVersion) &&
                            snapshotVersionExtensionEqual(otherSnapshotVersion, existingSnapshotVersion)) {
                        if (comparator.compare(otherSnapshotVersion, existingSnapshotVersion) > 0) {
                            existingSnapshotVersion.setUpdated(otherSnapshotVersion.getUpdated());
                            existingSnapshotVersion.setVersion(otherSnapshotVersion.getVersion());
                        }
                    }
                }
            }
        }
    }
}
 
开发者ID:alancnet,项目名称:artifactory,代码行数:25,代码来源:MergeableMavenMetadata.java

示例6: constructVersion

import org.apache.maven.artifact.repository.metadata.Versioning; //导入依赖的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;
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:19,代码来源:SnapshotTransformation.java

示例7: getBuildNumber

import org.apache.maven.artifact.repository.metadata.Versioning; //导入依赖的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;
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:17,代码来源:RemoteSnapshotMetadata.java

示例8: createMetadata

import org.apache.maven.artifact.repository.metadata.Versioning; //导入依赖的package包/类
private static Metadata createMetadata( Artifact artifact, boolean legacyFormat )
{
    Snapshot snapshot = new Snapshot();
    snapshot.setLocalCopy( true );
    Versioning versioning = new Versioning();
    versioning.setSnapshot( snapshot );

    Metadata metadata = new Metadata();
    metadata.setVersioning( versioning );
    metadata.setGroupId( artifact.getGroupId() );
    metadata.setArtifactId( artifact.getArtifactId() );
    metadata.setVersion( artifact.getBaseVersion() );

    if ( !legacyFormat )
    {
        metadata.setModelVersion( "1.1.0" );
    }

    return metadata;
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:21,代码来源:LocalSnapshotMetadata.java

示例9: createMetadata

import org.apache.maven.artifact.repository.metadata.Versioning; //导入依赖的package包/类
private static Metadata createMetadata( Artifact artifact )
{
    Versioning versioning = new Versioning();
    versioning.addVersion( artifact.getBaseVersion() );
    if ( !artifact.isSnapshot() )
    {
        versioning.setRelease( artifact.getBaseVersion() );
    }
    if ( "maven-plugin".equals( artifact.getProperty( ArtifactProperties.TYPE, "" ) ) )
    {
        versioning.setLatest( artifact.getBaseVersion() );
    }

    Metadata metadata = new Metadata();
    metadata.setVersioning( versioning );
    metadata.setGroupId( artifact.getGroupId() );
    metadata.setArtifactId( artifact.getArtifactId() );

    return metadata;
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:21,代码来源:VersionsMetadata.java

示例10: merge

import org.apache.maven.artifact.repository.metadata.Versioning; //导入依赖的package包/类
@Override
protected void merge( Metadata recessive )
{
    Versioning versioning = metadata.getVersioning();
    versioning.updateTimestamp();

    if ( recessive.getVersioning() != null )
    {
        if ( versioning.getLatest() == null )
        {
            versioning.setLatest( recessive.getVersioning().getLatest() );
        }
        if ( versioning.getRelease() == null )
        {
            versioning.setRelease( recessive.getVersioning().getRelease() );
        }

        Collection<String> versions = new LinkedHashSet<String>( recessive.getVersioning().getVersions() );
        versions.addAll( versioning.getVersions() );
        versioning.setVersions( new ArrayList<String>( versions ) );
    }
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:23,代码来源:VersionsMetadata.java

示例11: givenAvailableVersions

import org.apache.maven.artifact.repository.metadata.Versioning; //导入依赖的package包/类
private void givenAvailableVersions(final String... availableVersions) {
    try {
        doAnswer(new Answer() {
            @Override
            public Object answer(InvocationOnMock invocation) throws Throwable {
                RepositoryMetadata repositoryMetadata = (RepositoryMetadata) invocation.getArguments()[0];
                Versioning versioning = new Versioning();
                versioning.setVersions(Arrays.asList(availableVersions));
                repositoryMetadata.getMetadata().setVersioning(versioning);
                return null;
            }
        }).when(repositoryMetadataManager).resolve(any(RepositoryMetadata.class),
                anyListOf(ArtifactRepository.class), any(ArtifactRepository.class));
    } catch (RepositoryMetadataResolutionException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:ImmobilienScout24,项目名称:deadcode4j,代码行数:18,代码来源:An_UpdateChecker.java

示例12: writeMetadata

import org.apache.maven.artifact.repository.metadata.Versioning; //导入依赖的package包/类
private void writeMetadata(File folder, List<MavenCoordinates> coordinates) {
	List<SnapshotVersion> snapshotVersions = getSnapshotVersionMetadata(coordinates);
	if (!snapshotVersions.isEmpty()) {
		Metadata metadata = new Metadata();
		Versioning versioning = new Versioning();
		versioning.setSnapshotVersions(snapshotVersions);
		metadata.setVersioning(versioning);
		metadata.setGroupId(coordinates.get(0).getGroupId());
		metadata.setArtifactId(coordinates.get(0).getArtifactId());
		metadata.setVersion(coordinates.get(0).getVersion());
		writeMetadataFile(metadata, new File(folder, "maven-metadata.xml"));
	}
}
 
开发者ID:spring-io,项目名称:artifactory-resource,代码行数:14,代码来源:MavenMetadataGenerator.java

示例13: v

import org.apache.maven.artifact.repository.metadata.Versioning; //导入依赖的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

示例14: addSnapshotVersions

import org.apache.maven.artifact.repository.metadata.Versioning; //导入依赖的package包/类
/**
 * Add the list of {@link SnapshotVersion}s to the {@link Versioning}.
 *
 * @param versioning       the versionioning to add to.
 * @param snapshotVersions the snapshot versions to add.
 * @since 1.0
 */
private static void addSnapshotVersions( Versioning versioning, List<SnapshotVersion> snapshotVersions )
{
    try
    {
        for ( SnapshotVersion snapshotVersion : snapshotVersions )
        {
            versioning.addSnapshotVersion( snapshotVersion );
        }
    }
    catch ( NoClassDefFoundError e )
    {
        // Maven 2
    }
}
 
开发者ID:mojohaus,项目名称:mrm,代码行数:22,代码来源:MemoryArtifactStore.java

示例15: isSnapshotMavenMetadata

import org.apache.maven.artifact.repository.metadata.Versioning; //导入依赖的package包/类
private boolean isSnapshotMavenMetadata(Metadata metadata) {
    Versioning versioning = metadata.getVersioning();
    if (versioning == null) {
        return false;
    }
    List<SnapshotVersion> snapshots = versioning.getSnapshotVersions();
    return snapshots != null && !snapshots.isEmpty();
}
 
开发者ID:alancnet,项目名称:artifactory,代码行数:9,代码来源:MavenMetadataCalculator.java


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