• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java SnapshotVersion类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: addSnapshotVersion

import org.apache.maven.artifact.repository.metadata.SnapshotVersion; //导入依赖的package包/类
/**
 * Adds a snapshot version to the list of snapshot versions.
 *
 * @param snapshotVersions the list of snapshot versions.
 * @param artifact         the artifact to add details of.
 * @param lastUpdatedTime  the time to flag for last updated.
 * @since 1.0
 */
private static void addSnapshotVersion( List<SnapshotVersion> snapshotVersions, Artifact artifact, String lastUpdatedTime )
{
    try
    {
        SnapshotVersion snapshotVersion = new SnapshotVersion();
        snapshotVersion.setExtension( artifact.getType() );
        snapshotVersion.setClassifier( artifact.getClassifier() == null ? "" : artifact.getClassifier() );
        snapshotVersion.setVersion( artifact.getTimestampVersion() );
        snapshotVersion.setUpdated( lastUpdatedTime );
        snapshotVersions.add( snapshotVersion );
    }
    catch ( NoClassDefFoundError e )
    {
        // Maven 2
    }
}
 
开发者ID:mojohaus,项目名称:mrm,代码行数:25,代码来源:MemoryArtifactStore.java


示例2: buildSnapshotMavenMetadata

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

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


示例4: writeMetadata

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


示例5: asSnapshotVersionMetadata

import org.apache.maven.artifact.repository.metadata.SnapshotVersion; //导入依赖的package包/类
private SnapshotVersion asSnapshotVersionMetadata(MavenCoordinates coordinates) {
	SnapshotVersion snapshotVersion = new SnapshotVersion();
	snapshotVersion.setClassifier(coordinates.getClassifier());
	snapshotVersion.setExtension(coordinates.getExtension());
	snapshotVersion.setVersion(coordinates.getSnapshotVersion());
	return snapshotVersion;
}
 
开发者ID:spring-io,项目名称:artifactory-resource,代码行数:8,代码来源:MavenMetadataGenerator.java


示例6: v

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


示例7: addSnapshotVersions

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


示例8: isSnapshotMavenMetadata

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


示例9: compare

import org.apache.maven.artifact.repository.metadata.SnapshotVersion; //导入依赖的package包/类
@Override
public int compare(SnapshotVersion o1, SnapshotVersion o2) {
    String version1 = o1.getVersion();
    String timestamp1 = version1.substring(version1.indexOf('-') + 1, version1.lastIndexOf('-'));
    String version2 = o2.getVersion();
    String timestamp2 = version2.substring(version2.indexOf('-') + 1, version2.lastIndexOf('-'));
    long time1 = MavenModelUtils.uniqueSnapshotTimestampToDate(timestamp1).getTime();
    long time2 = MavenModelUtils.uniqueSnapshotTimestampToDate(timestamp2).getTime();
    long dif = time1 - time2;
    return dif > 0 ? 1 : dif < 0 ? -1 : 0;
}
 
开发者ID:alancnet,项目名称:artifactory,代码行数:12,代码来源:TimestampSnapshotComparator.java


示例10: snapshotVersionClassifiersEqual

import org.apache.maven.artifact.repository.metadata.SnapshotVersion; //导入依赖的package包/类
private boolean snapshotVersionClassifiersEqual(SnapshotVersion otherSnapshotVersion,
        SnapshotVersion existingSnapshotVersion) {
    String existingSnapshotClassifier = existingSnapshotVersion.getClassifier();
    String otherSnapshotClassifier = otherSnapshotVersion.getClassifier();
    return ((StringUtils.isBlank(otherSnapshotClassifier) && StringUtils.isBlank(existingSnapshotClassifier)) ||
            (StringUtils.isNotBlank(otherSnapshotClassifier) &&
                    otherSnapshotClassifier.equals(existingSnapshotClassifier)));
}
 
开发者ID:alancnet,项目名称:artifactory,代码行数:9,代码来源:MergeableMavenMetadata.java


示例11: snapshotVersionExtensionEqual

import org.apache.maven.artifact.repository.metadata.SnapshotVersion; //导入依赖的package包/类
private boolean snapshotVersionExtensionEqual(SnapshotVersion otherSnapshotVersion,
        SnapshotVersion existingSnapshotVersion) {
    String existingSnapshotExtension = existingSnapshotVersion.getExtension();
    String otherSnapshotExtension = otherSnapshotVersion.getExtension();
    return ((StringUtils.isBlank(otherSnapshotExtension) && StringUtils.isBlank(existingSnapshotExtension)) ||
            (StringUtils.isNotBlank(otherSnapshotExtension) &&
                    otherSnapshotExtension.equals(existingSnapshotExtension)));
}
 
开发者ID:alancnet,项目名称:artifactory,代码行数:9,代码来源:MergeableMavenMetadata.java


示例12: resolveMavenMetadataForCompatibility

import org.apache.maven.artifact.repository.metadata.SnapshotVersion; //导入依赖的package包/类
private RepoResource resolveMavenMetadataForCompatibility(FileResource metadataResource,
        InternalRequestContext context) {
    if (ConstantValues.mvnMetadataVersion3Enabled.getBoolean() && !context.clientSupportsM3SnapshotVersions()) {
        RepoRequests.logToContext("Use of v3 Maven metadata is enabled, but the requesting client doesn't " +
                "support it - checking if the response should be modified for compatibility");
        FileInfo info = metadataResource.getInfo();
        try {
            Metadata metadata = MavenModelUtils.toMavenMetadata(repositoryService.getStringContent(info));
            Versioning versioning = metadata.getVersioning();
            if (versioning != null) {
                List<SnapshotVersion> snapshotVersions = versioning.getSnapshotVersions();
                if ((snapshotVersions != null) && !snapshotVersions.isEmpty()) {
                    RepoRequests.logToContext("Found snapshot versions - modifying the response for compatibility");
                    versioning.setSnapshotVersions(null);
                    return new ResolvedResource(metadataResource, MavenModelUtils.mavenMetadataToString(metadata));
                }
            }
        } catch (IOException e) {
            RepoPath repoPath = info.getRepoPath();
            log.error("An error occurred while filtering Maven metadata '{}' for compatibility: " +
                    "{}\nReturning original content.", repoPath, e.getMessage());
            RepoRequests.logToContext("An error occurred while filtering for compatibility. Returning the " +
                    "original content: %s", e.getMessage());
        }
    }
    //In case none of the above apply, or if we encountered an error, return the original resource
    return metadataResource;
}
 
开发者ID:alancnet,项目名称:artifactory,代码行数:29,代码来源:DbStoringRepoMixin.java


示例13: merge

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


示例14: generateMavenMetadata

import org.apache.maven.artifact.repository.metadata.SnapshotVersion; //导入依赖的package包/类
/**
 * Generate the maven-metadata-local.xml for the given Maven <code>Artifact</code>.
 *
 * @param artifact the Maven <code>Artifact</code>.
 * @param target   the target maven-metadata-local.xml file to generate.
 * @throws IOException if the maven-metadata-local.xml can't be generated.
 */
static void generateMavenMetadata(Artifact artifact, File target) throws IOException {
    target.getParentFile().mkdirs();
    Metadata metadata = new Metadata();
    metadata.setGroupId(artifact.getGroupId());
    metadata.setArtifactId(artifact.getArtifactId());
    metadata.setVersion(artifact.getVersion());
    metadata.setModelVersion("1.1.0");

    Versioning versioning = new Versioning();
    versioning.setLastUpdatedTimestamp(new Date(System.currentTimeMillis()));
    Snapshot snapshot = new Snapshot();
    snapshot.setLocalCopy(true);
    versioning.setSnapshot(snapshot);
    SnapshotVersion snapshotVersion = new SnapshotVersion();
    snapshotVersion.setClassifier(artifact.getClassifier());
    snapshotVersion.setVersion(artifact.getVersion());
    snapshotVersion.setExtension(artifact.getType());
    snapshotVersion.setUpdated(versioning.getLastUpdated());
    versioning.addSnapshotVersion(snapshotVersion);

    metadata.setVersioning(versioning);

    MetadataXpp3Writer metadataWriter = new MetadataXpp3Writer();
    Writer writer = new FileWriter(target);
    metadataWriter.write(writer, metadata);
}
 
开发者ID:retog,项目名称:karaf-maven-plugin,代码行数:34,代码来源:MavenUtil.java


示例15: getSnapshotVersionMetadata

import org.apache.maven.artifact.repository.metadata.SnapshotVersion; //导入依赖的package包/类
private List<SnapshotVersion> getSnapshotVersionMetadata(
		List<MavenCoordinates> coordinates) {
	return coordinates.stream().filter(MavenCoordinates::isSnapshotVersion).sorted()
			.map(this::asSnapshotVersionMetadata)
			.collect(Collectors.toCollection(ArrayList::new));
}
 
开发者ID:spring-io,项目名称:artifactory-resource,代码行数:7,代码来源:MavenMetadataGenerator.java


示例16: createSnapshotsMetadata

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


示例17: compare

import org.apache.maven.artifact.repository.metadata.SnapshotVersion; //导入依赖的package包/类
@Override
public int compare(SnapshotVersion o1, SnapshotVersion o2) {
    int buildNumber1 = Integer.valueOf(StringUtils.substringAfterLast(o1.getVersion(), "-"));
    int buildNumber2 = Integer.valueOf(StringUtils.substringAfterLast(o2.getVersion(), "-"));
    return buildNumber1 - buildNumber2;
}
 
开发者ID:alancnet,项目名称:artifactory,代码行数:7,代码来源:BuildNumberSnapshotComparator.java


示例18: compare

import org.apache.maven.artifact.repository.metadata.SnapshotVersion; //导入依赖的package包/类
int compare(SnapshotVersion o1, SnapshotVersion o2); 
开发者ID:alancnet,项目名称:artifactory,代码行数:2,代码来源:SnapshotComparator.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java NioServerBossPool类代码示例发布时间:2022-05-23
下一篇:
Java Field类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap