本文整理汇总了Java中org.apache.maven.artifact.repository.metadata.Versioning.getVersions方法的典型用法代码示例。如果您正苦于以下问题:Java Versioning.getVersions方法的具体用法?Java Versioning.getVersions怎么用?Java Versioning.getVersions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.maven.artifact.repository.metadata.Versioning
的用法示例。
在下文中一共展示了Versioning.getVersions方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: mergeMetadata
import org.apache.maven.artifact.repository.metadata.Versioning; //导入方法依赖的package包/类
private void mergeMetadata( Versions versions, Metadata source, ArtifactRepository repository )
{
Versioning versioning = source.getVersioning();
if ( versioning != null )
{
String timestamp = StringUtils.clean( versioning.getLastUpdated() );
if ( StringUtils.isNotEmpty( versioning.getRelease() )
&& timestamp.compareTo( versions.releaseTimestamp ) > 0 )
{
versions.releaseVersion = versioning.getRelease();
versions.releaseTimestamp = timestamp;
versions.releaseRepository = repository;
}
if ( StringUtils.isNotEmpty( versioning.getLatest() )
&& timestamp.compareTo( versions.latestTimestamp ) > 0 )
{
versions.latestVersion = versioning.getLatest();
versions.latestTimestamp = timestamp;
versions.latestRepository = repository;
}
for ( String version : versioning.getVersions() )
{
if ( !versions.versions.containsKey( version ) )
{
versions.versions.put( version, repository );
}
}
}
}
示例2: merge
import org.apache.maven.artifact.repository.metadata.Versioning; //导入方法依赖的package包/类
/**
* List up all the versions found in the metadata.
*/
private void merge(Versioning versioning, ArtifactRepository from, List<VersionInfo> found) {
if ( StringUtils.isNotEmpty( versioning.getRelease() ) )
found.add(new VersionInfo(versioning.getRelease(),from));
if ( StringUtils.isNotEmpty( versioning.getLatest() ) )
found.add(new VersionInfo(versioning.getLatest(),from));
for ( String v : versioning.getVersions() )
found.add(new VersionInfo(v,from));
}
示例3: merge
import org.apache.maven.artifact.repository.metadata.Versioning; //导入方法依赖的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);
}
}
}
}
}