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


Java VersionRange类代码示例

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


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

示例1: setUp

import org.apache.maven.artifact.versioning.VersionRange; //导入依赖的package包/类
protected void setUp()
    throws Exception
{
    super.setUp();

    ArtifactHandler ah = new DefaultArtifactHandlerStub( "jar", null );
    VersionRange vr = VersionRange.createFromVersion( "1.1" );
    release = new DefaultArtifact( "test", "one", vr, Artifact.SCOPE_COMPILE, "jar", "sources", ah, false );
    artifacts.add( release );

    ah = new DefaultArtifactHandlerStub( "war", null );
    vr = VersionRange.createFromVersion( "1.1-SNAPSHOT" );
    snap = new DefaultArtifact( "test", "two", vr, Artifact.SCOPE_PROVIDED, "war", null, ah, false );
    artifacts.add( snap );

    ah = new DefaultArtifactHandlerStub( "war", null );
    vr = VersionRange.createFromVersion( "1.1-SNAPSHOT" );
    sources = new DefaultArtifact( "test", "two", vr, Artifact.SCOPE_PROVIDED, "sources", "sources", ah, false );

    // pick random output location
    Random a = new Random();
    outputFolder = new File( "target/copy" + a.nextLong() + "/" );
    outputFolder.delete();
    assertFalse( outputFolder.exists() );
}
 
开发者ID:kefik,项目名称:Pogamut3,代码行数:26,代码来源:TestDependencyUtil.java

示例2: getLatestReleaseVersion

import org.apache.maven.artifact.versioning.VersionRange; //导入依赖的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;
}
 
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-eclipse,代码行数:25,代码来源:ArtifactRetriever.java

示例3: testVersionRangeFromSpec

import org.apache.maven.artifact.versioning.VersionRange; //导入依赖的package包/类
@Test
public void testVersionRangeFromSpec() {
  VersionRange versionRange = majorVersion.getVersionRange();
  Restriction restriction = Iterables.getOnlyElement(versionRange.getRestrictions());
  assertEquals(majorVersion.getVersionRange(), majorVersion.getVersionRange());

  assertTrue(restriction.isLowerBoundInclusive());
  assertEquals(majorVersion.getInitialVersion(), restriction.getLowerBound());

  assertFalse(restriction.isUpperBoundInclusive());
  if (majorVersion.getMaxVersion().toString().trim().isEmpty()) {
    assertNull(
        "No Upper Bound should be specified if the max version is empty",
        restriction.getUpperBound());
  } else {
    assertEquals(majorVersion.getMaxVersion(), restriction.getUpperBound());
  }
}
 
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-eclipse,代码行数:19,代码来源:MajorVersionTest.java

示例4: testTruncateVersionRange

import org.apache.maven.artifact.versioning.VersionRange; //导入依赖的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));
  }
}
 
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-eclipse,代码行数:27,代码来源:MajorVersionTest.java

示例5: pinDataflowDependencyToCurrent

import org.apache.maven.artifact.versioning.VersionRange; //导入依赖的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();
  }
}
 
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-eclipse,代码行数:22,代码来源:DataflowMavenModel.java

示例6: getDataflowVersionRange

import org.apache.maven.artifact.versioning.VersionRange; //导入依赖的package包/类
public VersionRange getDataflowVersionRange(IProject project) {
  Model model = getModelFromProject(project);
  if (model != null) {
    Dependency dependency = getDataflowDependencyFromModel(model);
    if (dependency != null) {
      String version = dependency.getVersion();
      if (!Strings.isNullOrEmpty(version)) {
        try {
          return VersionRange.createFromVersionSpec(version);
        } catch (InvalidVersionSpecificationException ex) {
          String message =
              String.format("Could not create version range from existing version %s", version);
          throw new IllegalStateException(message, ex);
        }
      }
    }
  }
  return allVersions();
}
 
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-eclipse,代码行数:20,代码来源:DataflowDependencyManager.java

示例7: getArtifact

import org.apache.maven.artifact.versioning.VersionRange; //导入依赖的package包/类
protected Artifact getArtifact(ArtifactItem artifactItem) throws MojoExecutionException, InvalidVersionSpecificationException {
   Artifact artifact;
	
   VersionRange vr = VersionRange.createFromVersionSpec(artifactItem.getVersion());
	
   if (StringUtils.isEmpty(artifactItem.getClassifier())) {
       artifact = factory.createDependencyArtifact( artifactItem.getGroupId(), artifactItem.getArtifactId(), vr,
                                                    artifactItem.getType(), null, Artifact.SCOPE_COMPILE );
   } else {
       artifact = factory.createDependencyArtifact( artifactItem.getGroupId(), artifactItem.getArtifactId(), vr,
                                                    artifactItem.getType(), artifactItem.getClassifier(),
                                                    Artifact.SCOPE_COMPILE );
   }
	
   try {
	resolver.resolve(artifact, remoteRepos, local);
} catch (ArtifactResolutionException | ArtifactNotFoundException e) {
	throw new MojoExecutionException("Error resolving artifact "+artifact, e);
}
   
   return artifact;
  }
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:23,代码来源:SchemaDistMojo.java

示例8: ensureEngineIsInstalled

import org.apache.maven.artifact.versioning.VersionRange; //导入依赖的package包/类
private void ensureEngineIsInstalled() throws MojoExecutionException
{
  VersionRange ivyVersionRange = getIvyVersionRange();
  if (identifyAndGetEngineDirectory() == null)
  {
    handleNoInstalledEngine();
  }
  else
  {
    if (engineDirectoryIsEmpty())
    {
      getRawEngineDirectory().mkdirs();
    }
    ArtifactVersion installedEngineVersion = getInstalledEngineVersion(getRawEngineDirectory());
    
    if (installedEngineVersion == null || 
            !ivyVersionRange.containsVersion(installedEngineVersion))
    {
      handleWrongIvyVersion(installedEngineVersion);
    }
  }
}
 
开发者ID:axonivy,项目名称:project-build-plugin,代码行数:23,代码来源:InstallEngineMojo.java

示例9: getDependencies

import org.apache.maven.artifact.versioning.VersionRange; //导入依赖的package包/类
private List<File> getDependencies() throws MojoExecutionException {
    Set<Artifact> artifacts = new HashSet<>();
    String version = props.getProperty("version");
    String jettyVersion = props.getProperty("jettyVersion");

    getLog().info("Resolving dependencies for version " + version +" of jetty-console-core");

    artifacts.add(artifactFactory.createDependencyArtifact("org.simplericity.jettyconsole", "jetty-console-core", VersionRange.createFromVersion(version), "jar", null, "runtime"));

    List<File> artifactFiles = new ArrayList<File>();
    try {
        ArtifactResolutionResult result = resolver.resolveTransitively(artifacts, project.getArtifact(), remoteRepositories, localRepository, artifactMetadataSource);
        for(Artifact artifact : (Set<Artifact>) result.getArtifacts()) {
            artifactFiles.add(artifact.getFile());
        }
        return artifactFiles;

    } catch (ArtifactResolutionException | ArtifactNotFoundException e) {
        throw new MojoExecutionException(e.getMessage(), e);
    }
}
 
开发者ID:eirbjo,项目名称:jetty-console,代码行数:22,代码来源:CreateDescriptorMojo.java

示例10: testMojoLookup

import org.apache.maven.artifact.versioning.VersionRange; //导入依赖的package包/类
public void testMojoLookup()
    throws Exception
{
    File pluginXml = new File( getBasedir(), "src/test/resources/linker/plugin-config-ranlib.xml" );
    NativeRanlibMojo mojo = (NativeRanlibMojo) lookupMojo( "ranlib", pluginXml );
    assertNotNull( mojo );

    // simulate artifact
    ArtifactHandler artifactHandler = new DefaultArtifactHandler();

    Artifact artifact =
        new DefaultArtifact( "test", "test", VersionRange.createFromVersion( "1.0-SNAPSHOT" ), "compile", "exe",
                             null, artifactHandler );
    mojo.getProject().setArtifact( artifact );

    mojo.execute();
}
 
开发者ID:mojohaus,项目名称:maven-native,代码行数:18,代码来源:NativeRanlibMojoTest.java

示例11: resolveSnapshotVersion

import org.apache.maven.artifact.versioning.VersionRange; //导入依赖的package包/类
/**
 * Determine the timestamp version of the snapshot dependency used in the build.
 *
 * @param dep
 * @return The timestamp version if exists, otherwise the original snapshot dependency version is returned.
 */
private String resolveSnapshotVersion( Dependency dep )
{
    getLog().debug( "Resolving snapshot version for dependency: " + dep );

    String lockedVersion = dep.getVersion();

    try
    {
        Artifact depArtifact =
            artifactFactory.createDependencyArtifact( dep.getGroupId(), dep.getArtifactId(),
                                                      VersionRange.createFromVersionSpec( dep.getVersion() ),
                                                      dep.getType(), dep.getClassifier(), dep.getScope() );
        resolver.resolve( depArtifact, getProject().getRemoteArtifactRepositories(), localRepository );

        lockedVersion = depArtifact.getVersion();
    }
    catch ( Exception e )
    {
        getLog().error( e );
    }
    return lockedVersion;
}
 
开发者ID:mojohaus,项目名称:versions-maven-plugin,代码行数:29,代码来源:LockSnapshotsMojo.java

示例12: findLatestVersion

import org.apache.maven.artifact.versioning.VersionRange; //导入依赖的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 = 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:mojohaus,项目名称:versions-maven-plugin,代码行数:29,代码来源:AbstractVersionsUpdaterMojo.java

示例13: findLatestVersion

import org.apache.maven.artifact.versioning.VersionRange; //导入依赖的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 );
    }
}
 
开发者ID:mojohaus,项目名称:versions-maven-plugin,代码行数:36,代码来源:AbstractVersionsReport.java

示例14: isVersionOverlap

import org.apache.maven.artifact.versioning.VersionRange; //导入依赖的package包/类
/**
 * Checks if two versions or ranges have an overlap.
 *
 * @param leftVersionOrRange the 1st version number or range to test
 * @param rightVersionOrRange the 2nd version number or range to test
 * @return true if both versions have an overlap
 * @throws InvalidVersionSpecificationException if the versions can't be parsed to a range
 */
public static boolean isVersionOverlap( String leftVersionOrRange, String rightVersionOrRange )
    throws InvalidVersionSpecificationException
{
    VersionRange pomVersionRange = createVersionRange( leftVersionOrRange );
    if ( !pomVersionRange.hasRestrictions() )
    {
        return true;
    }

    VersionRange oldVersionRange = createVersionRange( rightVersionOrRange );
    if ( !oldVersionRange.hasRestrictions() )
    {
        return true;
    }

    VersionRange result = oldVersionRange.restrict( pomVersionRange );
    return result.hasRestrictions();
}
 
开发者ID:mojohaus,项目名称:versions-maven-plugin,代码行数:27,代码来源:PomHelper.java

示例15: filterVersionsWithIncludes

import org.apache.maven.artifact.versioning.VersionRange; //导入依赖的package包/类
private ArtifactVersion[] filterVersionsWithIncludes( ArtifactVersion[] newer, Artifact artifact )
{
    List<ArtifactVersion> filteredNewer = new ArrayList<>( newer.length );
    for ( int j = 0; j < newer.length; j++ )
    {
        ArtifactVersion artifactVersion = newer[j];
        Artifact artefactWithNewVersion =
            new DefaultArtifact( artifact.getGroupId(), artifact.getArtifactId(),
                                 VersionRange.createFromVersion( artifactVersion.toString() ), artifact.getScope(),
                                 artifact.getType(), null, new DefaultArtifactHandler(), false );
        if ( isIncluded( artefactWithNewVersion ) )
        {
            filteredNewer.add( artifactVersion );
        }
    }
    return filteredNewer.toArray( new ArtifactVersion[filteredNewer.size()] );
}
 
开发者ID:mojohaus,项目名称:versions-maven-plugin,代码行数:18,代码来源:UseLatestReleasesMojo.java


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