本文整理汇总了Java中org.apache.maven.artifact.versioning.ArtifactVersion类的典型用法代码示例。如果您正苦于以下问题:Java ArtifactVersion类的具体用法?Java ArtifactVersion怎么用?Java ArtifactVersion使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ArtifactVersion类属于org.apache.maven.artifact.versioning包,在下文中一共展示了ArtifactVersion类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: compareMavenVersionStrings
import org.apache.maven.artifact.versioning.ArtifactVersion; //导入依赖的package包/类
private int compareMavenVersionStrings(String dependencyVersionString, String duplicateVersionString) {
String dependencyVersion = emptyToNull(dependencyVersionString);
String duplicateVersion = emptyToNull(duplicateVersionString);
if (dependencyVersion == null && duplicateVersion == null) {
return 0;
}
if (dependencyVersion == null) {
return -1;
}
if (duplicateVersion == null) {
return 1;
}
ArtifactVersion dependencyArtifactVersion = new DefaultArtifactVersion(dependencyVersion);
ArtifactVersion duplicateArtifactVersion = new DefaultArtifactVersion(duplicateVersion);
return dependencyArtifactVersion.compareTo(duplicateArtifactVersion);
}
示例2: getResult
import org.apache.maven.artifact.versioning.ArtifactVersion; //导入依赖的package包/类
FixDescription getResult() {
FixDescription res = new FixDescription();
res.isSet = addSetCheck.isSelected();
res.version2Set = res.isSet ? (ArtifactVersion) versionList.getSelectedValue() : null;
res.isExclude = excludeCheck.isSelected();
if (res.isExclude) {
res.exclusionTargets = new HashSet<Artifact>();
res.conflictParents = new HashSet<MavenDependencyNode>();
ListModel lm = excludesList.getModel();
for (int i = 0; i < lm.getSize(); i++) {
ExclTargetEntry entry = (ExclTargetEntry) lm.getElementAt(i);
if (entry.isSelected) {
res.exclusionTargets.add(entry.artif);
res.conflictParents.addAll(eTargets.getConflictParents(entry.artif));
}
}
}
return res;
}
示例3: getLatestReleaseVersion
import org.apache.maven.artifact.versioning.ArtifactVersion; //导入依赖的package包/类
/**
* Returns the latest published release artifact version in the version range,
* or null if there is no such version.
*/
public ArtifactVersion getLatestReleaseVersion(
String groupId, String artifactId, VersionRange range) {
String coordinates = idToKey(groupId, artifactId);
try {
NavigableSet<ArtifactVersion> versions = availableVersions.get(coordinates);
for (ArtifactVersion version : versions.descendingSet()) {
if (isReleased(version)) {
if (range == null || range.containsVersion(version)) {
return version;
}
}
}
} catch (ExecutionException ex) {
logger.log(
Level.WARNING,
"Could not retrieve version for artifact " + coordinates,
ex.getCause());
}
return null;
}
示例4: testTruncateVersionRange
import org.apache.maven.artifact.versioning.ArtifactVersion; //导入依赖的package包/类
@Test
public void testTruncateVersionRange() {
ArtifactVersion initialVersion = majorVersion.getInitialVersion();
ArtifactVersion newStart =
new DefaultArtifactVersion(
String.format(
"%s.%s.%s",
initialVersion.getMajorVersion(),
initialVersion.getMajorVersion(),
initialVersion.getIncrementalVersion() + 5));
assumeTrue(majorVersion.getMaxVersion().compareTo(newStart) > 0);
VersionRange updatedRange = MajorVersion.truncateAtLatest(newStart, majorVersion.getVersionRange());
assertFalse(updatedRange.containsVersion(majorVersion.getInitialVersion()));
ArtifactVersion afterStart =
new DefaultArtifactVersion(
String.format(
"%s.%s.%s",
initialVersion.getMajorVersion(),
initialVersion.getMajorVersion(),
initialVersion.getIncrementalVersion() + 6));
if (majorVersion.hasStableApi()) {
assertTrue(updatedRange.containsVersion(afterStart));
} else {
assertFalse(updatedRange.containsVersion(afterStart));
}
}
示例5: testGetLatestVersions
import org.apache.maven.artifact.versioning.ArtifactVersion; //导入依赖的package包/类
@Test
public void testGetLatestVersions() {
ArtifactVersion latestVersionOne = new DefaultArtifactVersion("1.2.3");
when(artifactRetriever.getLatestReleaseVersion(DataflowMavenCoordinates.GROUP_ID,
DataflowMavenCoordinates.ARTIFACT_ID, MajorVersion.ONE.getVersionRange()))
.thenReturn(latestVersionOne);
ArtifactVersion latestVersionTwo = new DefaultArtifactVersion("2.0.0");
when(artifactRetriever.getLatestReleaseVersion(DataflowMavenCoordinates.GROUP_ID,
DataflowMavenCoordinates.ARTIFACT_ID, MajorVersion.TWO.getVersionRange()))
.thenReturn(latestVersionTwo);
Map<ArtifactVersion, MajorVersion> expected = ImmutableMap.of(
latestVersionOne, MajorVersion.ONE,
latestVersionTwo, MajorVersion.TWO);
assertEquals(
expected,
manager.getLatestVersions(ImmutableSortedSet.of(MajorVersion.ONE, MajorVersion.TWO)));
}
示例6: testGetLatestVersionUnstableWithStableVersionInMap
import org.apache.maven.artifact.versioning.ArtifactVersion; //导入依赖的package包/类
@Test
public void testGetLatestVersionUnstableWithStableVersionInMap() {
ArtifactVersion latestQualified = new DefaultArtifactVersion("2.0.0-beta2");
when(artifactRetriever.getLatestReleaseVersion(DataflowMavenCoordinates.GROUP_ID,
DataflowMavenCoordinates.ARTIFACT_ID, MajorVersion.QUALIFIED_TWO.getVersionRange()))
.thenReturn(latestQualified);
ArtifactVersion latestMajor = new DefaultArtifactVersion("2.0.0");
when(artifactRetriever.getLatestReleaseVersion(DataflowMavenCoordinates.GROUP_ID,
DataflowMavenCoordinates.ARTIFACT_ID, MajorVersion.TWO.getVersionRange()))
.thenReturn(latestMajor);
assertEquals(
Collections.singletonMap(latestMajor, MajorVersion.TWO),
manager.getLatestVersions(
ImmutableSortedSet.of(MajorVersion.QUALIFIED_TWO, MajorVersion.TWO)));
}
示例7: testGetLatestVersionUnstableWithNoStableVersion
import org.apache.maven.artifact.versioning.ArtifactVersion; //导入依赖的package包/类
@Test
public void testGetLatestVersionUnstableWithNoStableVersion() {
ArtifactVersion latestOne = new DefaultArtifactVersion("1.9.0");
when(artifactRetriever.getLatestReleaseVersion(DataflowMavenCoordinates.GROUP_ID,
DataflowMavenCoordinates.ARTIFACT_ID, MajorVersion.ONE.getVersionRange()))
.thenReturn(latestOne);
ArtifactVersion latestQualifiedTwo = new DefaultArtifactVersion("2.0.0-beta2");
when(artifactRetriever.getLatestReleaseVersion(DataflowMavenCoordinates.GROUP_ID,
DataflowMavenCoordinates.ARTIFACT_ID, MajorVersion.QUALIFIED_TWO.getVersionRange()))
.thenReturn(latestQualifiedTwo);
Map<ArtifactVersion, MajorVersion> expected = ImmutableMap.of(
latestOne, MajorVersion.ONE,
latestQualifiedTwo, MajorVersion.QUALIFIED_TWO);
assertEquals(
expected,
manager.getLatestVersions(
ImmutableSortedSet.of(MajorVersion.ONE, MajorVersion.QUALIFIED_TWO)));
}
示例8: updateAvailableVersions
import org.apache.maven.artifact.versioning.ArtifactVersion; //导入依赖的package包/类
/**
* Update the dropdown of available template (archetype) versions to versions that are available
* for the currently selected template. If the available versions for the currently selected
* template do not include the currently selected version, select the latest stable version.
*/
private void updateAvailableVersions() {
String selected = templateVersionDropdown.getText();
templateVersionDropdown.removeAll();
DataflowProjectArchetype template = DataflowProjectArchetype.values()[templateDropdown.getSelectionIndex()];
for (MajorVersion majorVersion : template.getSdkVersions().descendingSet()) {
ArtifactVersion latestArtifact = ArtifactRetriever.DEFAULT.getLatestReleaseVersion(
DataflowMavenCoordinates.GROUP_ID, template.getArtifactId(),
majorVersion.getVersionRange());
if (latestArtifact != null) {
templateVersionDropdown.add(latestArtifact.toString());
if (latestArtifact.toString().equals(selected)) {
templateVersionDropdown.select(templateVersionDropdown.getItemCount() - 1);
}
}
}
if (templateVersionDropdown.getSelectionIndex() == -1) {
templateVersionDropdown.select(0);
}
updateArchetypeVersion();
}
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-eclipse,代码行数:29,代码来源:NewDataflowProjectWizardLandingPage.java
示例9: pinDataflowDependencyToCurrent
import org.apache.maven.artifact.versioning.ArtifactVersion; //导入依赖的package包/类
/**
* Sets the Dataflow Dependency of this model to the [current latest version, next major version).
*/
public void pinDataflowDependencyToCurrent(IProgressMonitor monitor) throws CoreException {
try {
VersionRange existingVersionRange = dependencyManager.getDataflowVersionRange(project);
ArtifactVersion version =
dependencyManager.getLatestDataflowDependencyInRange(existingVersionRange);
VersionRange newRange = MajorVersion.truncateAtLatest(version, existingVersionRange);
editPom(new SetDataflowDependencyVersion(newRange));
} catch (IOException e) {
throw new CoreException(
new Status(
Status.ERROR,
DataflowCorePlugin.PLUGIN_ID,
"Exception when trying to pin Dataflow Dependency",
e));
} finally {
monitor.done();
}
}
示例10: retrieveAvailableVersions
import org.apache.maven.artifact.versioning.ArtifactVersion; //导入依赖的package包/类
@NotNull
@Override
public List<String> retrieveAvailableVersions(@NotNull String groupId,
@NotNull String artifactId,
@NotNull List<MavenRemoteRepository> remoteRepositories)
throws RemoteException {
try {
Artifact artifact =
new DefaultArtifact(groupId, artifactId, "", Artifact.SCOPE_COMPILE, "pom", null, new DefaultArtifactHandler("pom"));
List<ArtifactVersion> versions = getComponent(ArtifactMetadataSource.class)
.retrieveAvailableVersions(
artifact,
getLocalRepository(),
convertRepositories(remoteRepositories));
return ContainerUtil.map(versions, new Function<ArtifactVersion, String>() {
@Override
public String fun(ArtifactVersion version) {
return version.toString();
}
});
}
catch (Exception e) {
Maven3ServerGlobals.getLogger().info(e);
}
return Collections.emptyList();
}
示例11: getVersions
import org.apache.maven.artifact.versioning.ArtifactVersion; //导入依赖的package包/类
public ArtifactVersion[] getVersions( boolean includeSnapshots )
{
Set<ArtifactVersion> result;
if ( includeSnapshots )
{
result = versions;
}
else
{
result = new TreeSet<ArtifactVersion>( versionComparator );
for ( ArtifactVersion candidate : versions )
{
if ( ArtifactUtils.isSnapshot( candidate.toString() ) )
{
continue;
}
result.add( candidate );
}
}
return result.toArray( new ArtifactVersion[result.size()] );
}
示例12: findLatestVersion
import org.apache.maven.artifact.versioning.ArtifactVersion; //导入依赖的package包/类
/**
* Finds the latest version of the specified artifact that matches the version range.
*
* @param artifact The artifact.
* @param versionRange The version range.
* @param allowingSnapshots <code>null</code> for no override, otherwise the local override to apply.
* @param usePluginRepositories
* @return The latest version of the specified artifact that matches the specified version range or
* <code>null</code> if no matching version could be found.
* @throws ArtifactMetadataRetrievalException
* If the artifact metadata could not be found.
* @since 1.0-alpha-1
*/
protected ArtifactVersion findLatestVersion( Artifact artifact, VersionRange versionRange,
Boolean allowingSnapshots, boolean usePluginRepositories )
throws ArtifactMetadataRetrievalException, MojoExecutionException
{
boolean includeSnapshots = Boolean.TRUE.equals( this.allowSnapshots );
if ( Boolean.TRUE.equals( allowingSnapshots ) )
{
includeSnapshots = true;
}
if ( Boolean.FALSE.equals( allowingSnapshots ) )
{
includeSnapshots = false;
}
final ArtifactVersions artifactVersions = getHelper().lookupArtifactVersions( artifact, usePluginRepositories );
return artifactVersions.getNewestVersion( versionRange, includeSnapshots );
}
开发者ID:petr-ujezdsky,项目名称:versions-maven-plugin-svn-clone,代码行数:30,代码来源:AbstractVersionsUpdaterMojo.java
示例13: findEngineDownloadUrl
import org.apache.maven.artifact.versioning.ArtifactVersion; //导入依赖的package包/类
URL findEngineDownloadUrl(InputStream htmlStream) throws MojoExecutionException, MalformedURLException
{
String engineFileNameRegex = "AxonIvyEngine[^.]+?\\.[^.]+?\\.+[^_]*?_"+osArchitecture+"\\.zip";
Pattern enginePattern = Pattern.compile("href=[\"|'][^\"']*?"+engineFileNameRegex+"[\"|']");
try(Scanner scanner = new Scanner(htmlStream))
{
String engineLink = null;
while (StringUtils.isBlank(engineLink))
{
String engineLinkMatch = scanner.findWithinHorizon(enginePattern, 0);
if (engineLinkMatch == null)
{
throw new MojoExecutionException("Could not find a link to engine for version '"+ivyVersion+"' on site '"+engineListPageUrl+"'");
}
String versionString = StringUtils.substringBetween(engineLinkMatch, "AxonIvyEngine", "_"+osArchitecture);
ArtifactVersion version = new DefaultArtifactVersion(EngineVersionEvaluator.toReleaseVersion(versionString));
if (getIvyVersionRange().containsVersion(version))
{
engineLink = StringUtils.replace(engineLinkMatch, "\"", "'");
engineLink = StringUtils.substringBetween(engineLink, "href='", "'");
}
}
return toAbsoluteLink(engineListPageUrl, engineLink);
}
}
示例14: getVersions
import org.apache.maven.artifact.versioning.ArtifactVersion; //导入依赖的package包/类
/**
* Uses the {@link DefaultVersionsHelper} to find all available versions that match all
* the associations with this property.
*
* @param includeSnapshots Whether to include snapshot versions in our search.
* @return The (possibly empty) array of versions.
*/
public synchronized ArtifactVersion[] getVersions( boolean includeSnapshots )
{
Set<ArtifactVersion> result;
if ( includeSnapshots )
{
result = versions;
}
else
{
result = new TreeSet<ArtifactVersion>( getVersionComparator() );
for ( ArtifactVersion candidate : versions )
{
if ( ArtifactUtils.isSnapshot( candidate.toString() ) )
{
continue;
}
result.add( candidate );
}
}
return asArtifactVersionArray( result );
}
示例15: findLatestVersion
import org.apache.maven.artifact.versioning.ArtifactVersion; //导入依赖的package包/类
/**
* Finds the latest version of the specified artifact that matches the version range.
*
* @param artifact The artifact.
* @param versionRange The version range.
* @param allowingSnapshots <code>null</code> for no override, otherwise the local override to apply.
* @return The latest version of the specified artifact that matches the specified version range or
* <code>null</code> if no matching version could be found.
* @throws MojoExecutionException If the artifact metadata could not be found.
* @since 1.0-alpha-1
*/
protected ArtifactVersion findLatestVersion( Artifact artifact, VersionRange versionRange,
boolean allowingSnapshots, boolean usePluginRepositories )
throws MavenReportException
{
boolean includeSnapshots = this.allowSnapshots;
if ( allowingSnapshots )
{
includeSnapshots = true;
}
if ( allowingSnapshots )
{
includeSnapshots = false;
}
try
{
final ArtifactVersions artifactVersions =
getHelper().lookupArtifactVersions( artifact, usePluginRepositories );
return artifactVersions.getNewestVersion( versionRange, includeSnapshots );
}
catch ( ArtifactMetadataRetrievalException e )
{
throw new MavenReportException( e.getMessage(), e );
}
}