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


Java VersionRangeRequest类代码示例

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


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

示例1: getLatestVersion

import org.eclipse.aether.resolution.VersionRangeRequest; //导入依赖的package包/类
private String getLatestVersion(String groupId, String artifactId, String range,
        RepositorySystemSession session, List<RemoteRepository> remotes)
        throws VersionRangeResolutionException {
    VersionRangeRequest rangeRequest = new VersionRangeRequest();
    rangeRequest.setArtifact(
            new DefaultArtifact(String.format("%s:%s:%s", groupId, artifactId, range)));
    rangeRequest.setRepositories(remotes);

    VersionRangeResult rangeResult = repoSystem.resolveVersionRange(session, rangeRequest);
    if (rangeResult.getHighestVersion() != null) {
        return rangeResult.getHighestVersion().toString();
    }
    else {
        throw new com.atomist.rug.resolver.maven.DependencyCollectionException(String
                .format("Unable to find a version of archive %s:%s.", groupId, artifactId),
                properties.repositories());
    }
}
 
开发者ID:atomist-attic,项目名称:rug-resolver,代码行数:19,代码来源:MavenBasedDependencyResolver.java

示例2: determineNewestVersion

import org.eclipse.aether.resolution.VersionRangeRequest; //导入依赖的package包/类
private static String determineNewestVersion(RepositorySystem repoSystem, RepositorySystemSession repoSession, List<RemoteRepository>[] repos) throws MojoExecutionException {
  String version;VersionRangeRequest rangeRequest = new VersionRangeRequest();
  rangeRequest.setArtifact(new DefaultArtifact(SDK_GROUP_ID + ":" + SDK_ARTIFACT_ID + ":[0,)"));
  for(List<RemoteRepository> repoList : repos) {
    for(RemoteRepository repo : repoList) {
      rangeRequest.addRepository(repo);
    }
  }

  VersionRangeResult rangeResult;
  try {
    rangeResult = repoSystem.resolveVersionRange(repoSession, rangeRequest);
  } catch (VersionRangeResolutionException e) {
    throw new MojoExecutionException("Could not resolve latest version of the App Engine Java SDK", e);
  }

  List<Version> versions = rangeResult.getVersions();

  Collections.sort(versions);

  Version newest = Iterables.getLast(versions);

  version = newest.toString();
  return version;
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-maven-plugin,代码行数:26,代码来源:SdkResolver.java

示例3: highestVersion

import org.eclipse.aether.resolution.VersionRangeRequest; //导入依赖的package包/类
private Version highestVersion(Artifact artifact) throws MojoExecutionException {
  VersionRangeRequest request = new VersionRangeRequest(artifact, repositories, null);
  VersionRangeResult v = resolve(request);

  if (!includeSnapshots) {
    List<Version> filtered = new ArrayList<Version>();
    for (Version aVersion : v.getVersions()) {
      if (!aVersion.toString().endsWith("SNAPSHOT")) {
        filtered.add(aVersion);
      }
    }
    v.setVersions(filtered);
  }

  if (v.getHighestVersion() == null) {
    throw (v.getExceptions().isEmpty())
        ? new MojoExecutionException("Failed to resolve " + artifact.toString())
        : new MojoExecutionException("Failed to resolve " + artifact.toString(), v.getExceptions().get(0));
  }

  return v.getHighestVersion();
}
 
开发者ID:stickycode,项目名称:bounds-maven-plugin,代码行数:23,代码来源:StickyBoundsMojo.java

示例4: findAvailableVersions

import org.eclipse.aether.resolution.VersionRangeRequest; //导入依赖的package包/类
public Collection<String> findAvailableVersions(String moduleId) {

        Artifact artifact = new DefaultArtifact(groupId, moduleId, "jar", "[0,)");

        VersionRangeRequest rangeRequest = new VersionRangeRequest();
        rangeRequest.setArtifact(artifact);
        rangeRequest.setRepositories(repos);

        VersionRangeResult rangeResult;
        try {
            rangeResult = system.resolveVersionRange(session, rangeRequest);
        } catch (VersionRangeResolutionException e) {
            logger.error("The requested range could not be parsed", e);
            return Collections.emptyList();
        }

        // transform List<Version> to a List<String> using toString()
        return FluentIterable.from(rangeResult.getVersions()).transform(Functions.toStringFunction()).toList();
    }
 
开发者ID:MovingBlocks,项目名称:ModuleManager,代码行数:20,代码来源:RepositoryConnector.java

示例5: resolveVersionRange

import org.eclipse.aether.resolution.VersionRangeRequest; //导入依赖的package包/类
private String resolveVersionRange(String groupId, String artifactId, String extension, String version)
        throws VersionRangeResolutionException {
    org.eclipse.aether.artifact.Artifact aetherArtifact = new org.eclipse.aether.artifact.DefaultArtifact(groupId,
            artifactId, extension, version);
    
    VersionRangeRequest rangeRequest = new VersionRangeRequest();
    rangeRequest.setArtifact(aetherArtifact);
    rangeRequest.setRepositories(repositories);
    
    VersionRangeResult rangeResult = this.repositorySystem.resolveVersionRange(this.repoSession, rangeRequest);
    
    if (rangeResult == null || rangeResult.getHighestVersion() == null) {
        throw new VersionRangeResolutionException(rangeResult, "Unable to resolve version range fram " + groupId
                + ":" + artifactId + ":" + extension + ":" + version);
    }
    getLog().debug("Available versions: " + rangeResult.getVersions());
    return rangeResult.getHighestVersion().toString();
}
 
开发者ID:WASdev,项目名称:ci.maven,代码行数:19,代码来源:AbstractLibertySupport.java

示例6: detectAllVersionsOf

import org.eclipse.aether.resolution.VersionRangeRequest; //导入依赖的package包/类
public ResolvedProject detectAllVersionsOf(ProjectCoordinates project) throws RepositoryException {
	Artifact artifact = new DefaultArtifact(project.groupId(), project.artifactId(), "jar", "[0,)");
	Stream<String> versions = repositorySystem
			.resolveVersionRange(
					repositorySystemSession,
					new VersionRangeRequest(artifact, singletonList(mavenCentral), NULL_CONTEXT))
			.getVersions().stream()
			.map(Version::toString);
	return new ResolvedProject(project, project.toArtifactsWithVersions(versions));
}
 
开发者ID:CodeFX-org,项目名称:jdeps-wall-of-shame,代码行数:11,代码来源:MavenCentral.java

示例7: getAvailableVersions

import org.eclipse.aether.resolution.VersionRangeRequest; //导入依赖的package包/类
@Override
public List<String> getAvailableVersions(String artifactGroup, String artifactName, List<PluginRepository> remoteRepositories) {
    List<String> versions = new ArrayList<>();
    try {
        // TODO figure out how to force remote check
        VersionRangeRequest rangeRequest = new VersionRangeRequest();
        rangeRequest.setArtifact(new DefaultArtifact(artifactGroup, artifactName, "jar", "[0,)"));
        if (remoteRepositories != null) {
            for (PluginRepository pluginRepository : remoteRepositories) {
                rangeRequest.addRepository(
                        new RemoteRepository.Builder(pluginRepository.getName(), "default", pluginRepository.getUrl()).build());
            }
        }
        DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession();
        File tempDir = new File(System.getProperty("java.io.tmpdir"), "temp-local-repo");
        tempDir.mkdirs();
        LocalRepository localRepo = new LocalRepository(tempDir.getAbsolutePath());
        session.setLocalRepositoryManager(repositorySystem.newLocalRepositoryManager(session, localRepo));
        session.setTransferListener(new PluginTransferListener());
        session.setRepositoryListener(new PluginRepositoryListener());
        VersionRangeResult rangeResult = repositorySystem.resolveVersionRange(session, rangeRequest);
        if (rangeResult != null) {
            List<Version> versionList = rangeResult.getVersions();
            for (Version version : versionList) {
                versions.add(version.toString());
            }
        }
        FileUtils.deleteQuietly(tempDir);
    } catch (VersionRangeResolutionException e) {
        logger.error("", e);
    }
    return versions;
}
 
开发者ID:JumpMind,项目名称:metl,代码行数:34,代码来源:PluginManager.java

示例8: getLatestLocalVersion

import org.eclipse.aether.resolution.VersionRangeRequest; //导入依赖的package包/类
@Override
public String getLatestLocalVersion(String artifactGroup, String artifactName) {
    String latestVersion = null;
    try {
        VersionRangeRequest rangeRequest = new VersionRangeRequest();
        rangeRequest.setArtifact(new DefaultArtifact(artifactGroup, artifactName, "jar", "[0,)"));
        VersionRangeResult rangeResult = repositorySystem.resolveVersionRange(repositorySystemSession, rangeRequest);
        if (rangeResult != null && rangeResult.getHighestVersion() != null) {
            latestVersion = rangeResult.getHighestVersion().toString();
        }
    } catch (VersionRangeResolutionException e) {
        logger.error("", e);
    }
    return latestVersion;
}
 
开发者ID:JumpMind,项目名称:metl,代码行数:16,代码来源:PluginManager.java

示例9: resolve

import org.eclipse.aether.resolution.VersionRangeRequest; //导入依赖的package包/类
private VersionRangeResult resolve(VersionRangeRequest request) {
  try {
    return repository.resolveVersionRange(session, request);
  }
  catch (VersionRangeResolutionException e) {
    throw new RuntimeException(e);
  }
}
 
开发者ID:stickycode,项目名称:bounds-maven-plugin,代码行数:9,代码来源:StickyBoundsMojo.java

示例10: resolveNewestMatching

import org.eclipse.aether.resolution.VersionRangeRequest; //导入依赖的package包/类
/**
 * Tries to find the newest version of the artifact that matches given regular expression.
 * The found version will be older than the {@code upToVersion} or newest available if {@code upToVersion} is null.
 *
 * @param gav the coordinates of the artifact. The version part is ignored
 * @param upToVersion the version up to which the versions will be matched
 * @param versionMatcher the matcher to match the version
 * @param remoteOnly true if only remotely available artifacts should be considered
 * @param upToInclusive whether the {@code upToVersion} should be considered inclusive or exclusive
 * @return the resolved artifact
 * @throws VersionRangeResolutionException
 */
public Artifact resolveNewestMatching(String gav, @Nullable String upToVersion, Pattern versionMatcher,
                                      boolean remoteOnly, boolean upToInclusive)
        throws VersionRangeResolutionException, ArtifactResolutionException {


    Artifact artifact = new DefaultArtifact(gav);
    artifact = artifact.setVersion(upToVersion == null ? "[,)" : "[," + upToVersion + (upToInclusive ? "]" : ")"));
    VersionRangeRequest rangeRequest = new VersionRangeRequest(artifact, repositories, null);

    RepositorySystemSession session = remoteOnly ? makeRemoteOnly(this.session) : this.session;

    VersionRangeResult result = repositorySystem.resolveVersionRange(session, rangeRequest);

    List<Version> versions = new ArrayList<>(result.getVersions());
    Collections.reverse(versions);

    for(Version v : versions) {
        if (versionMatcher.matcher(v.toString()).matches()) {
            return resolveArtifact(artifact.setVersion(v.toString()), session);
        }
    }

    throw new VersionRangeResolutionException(result) {
        @Override
        public String getMessage() {
            return "Failed to find a version of artifact '" + gav + "' that would correspond to an expression '"
                    + versionMatcher + "'. The versions found were: " + versions;
        }
    };
}
 
开发者ID:revapi,项目名称:revapi,代码行数:43,代码来源:ArtifactResolver.java

示例11: determineNewestVersion

import org.eclipse.aether.resolution.VersionRangeRequest; //导入依赖的package包/类
private static String determineNewestVersion(RepositorySystem repoSystem,
    RepositorySystemSession repoSession, List<RemoteRepository>[] repos)
    throws MojoExecutionException {
  String version;
  VersionRangeRequest rangeRequest = new VersionRangeRequest();
  rangeRequest.setArtifact(new DefaultArtifact(SDK_GROUP_ID + ":" + SDK_ARTIFACT_ID + ":[0,)"));
  for (List<RemoteRepository> repoList : repos) {
    for (RemoteRepository repo : repoList) {
      rangeRequest.addRepository(repo);
    }
  }

  VersionRangeResult rangeResult;
  try {
    rangeResult = repoSystem.resolveVersionRange(repoSession, rangeRequest);
  } catch (VersionRangeResolutionException e) {
    throw new MojoExecutionException(
        "Could not resolve latest version of the App Engine Java SDK", e);
  }

  List<Version> versions = rangeResult.getVersions();

  Collections.sort(versions);

  Version newest = Iterables.getLast(versions);

  version = newest.toString();
  return version;
}
 
开发者ID:GoogleCloudPlatform,项目名称:gcloud-maven-plugin,代码行数:30,代码来源:SdkResolver.java

示例12: getVersions

import org.eclipse.aether.resolution.VersionRangeRequest; //导入依赖的package包/类
public List<Version> getVersions(Artifact artifact) throws VersionRangeResolutionException {
    VersionRangeRequest rangeRequest = new VersionRangeRequest();
    rangeRequest.setArtifact( artifact );
    rangeRequest.setRepositories( repositories );

    VersionRangeResult rangeResult = system.resolveVersionRange( session, rangeRequest );

    List<Version> versions = new ArrayList<Version>(rangeResult.getVersions());
    Collections.sort(versions);
    
    return versions;
}
 
开发者ID:naver,项目名称:pinpoint,代码行数:13,代码来源:DependencyResolver.java

示例13: getLatestCapsuleVersion

import org.eclipse.aether.resolution.VersionRangeRequest; //导入依赖的package包/类
/**
 * Query the repositories to find the latest version of the capsule.
 *
 * @return latest version string found in repositories for capsule's artifact
 * @throws org.eclipse.aether.resolution.VersionRangeResolutionException
 *          if we cannot resolve the latest version of capsule
 */
private String getLatestCapsuleVersion() throws VersionRangeResolutionException {

    DefaultArtifact artifact = new DefaultArtifact("co.paralleluniverse", "capsule", null, null, "[0,)");
    VersionRangeRequest request = new VersionRangeRequest().setRepositories(getRemoteRepositories()).setArtifact(artifact);
    final VersionRangeResult result = getRepositorySystem().resolveVersionRange(getRepositorySystemSession(), request);

    return result.getHighestVersion() != null ? result.getHighestVersion().toString() : null;
}
 
开发者ID:pguedes,项目名称:capsule-maven-plugin,代码行数:16,代码来源:LatestCapsuleClass.java

示例14: getVersions

import org.eclipse.aether.resolution.VersionRangeRequest; //导入依赖的package包/类
private VersionRangeResult getVersions(RepositorySystem system, Settings settings, RepositorySystemSession session,
         List<RemoteRepository> repositories,
         String addonName,
         String version)
{
   try
   {
      String[] split = addonName.split(",");
      if (split.length == 2)
      {
         version = split[1];
      }
      if (version == null || version.isEmpty())
      {
         version = "[,)";
      }
      else if (!version.matches("(\\(|\\[).*?(\\)|\\])"))
      {
         version = "[" + version + "]";
      }

      Artifact artifact = new DefaultArtifact(toMavenCoords(AddonId.from(addonName, version)));
      VersionRangeRequest rangeRequest = new VersionRangeRequest(artifact, repositories, null);
      VersionRangeResult rangeResult = system.resolveVersionRange(session, rangeRequest);
      return rangeResult;
   }
   catch (Exception e)
   {
      throw new RuntimeException("Failed to look up versions for [" + addonName + "]", e);
   }
}
 
开发者ID:forge,项目名称:furnace,代码行数:32,代码来源:MavenAddonDependencyResolver.java

示例15: getVersions

import org.eclipse.aether.resolution.VersionRangeRequest; //导入依赖的package包/类
public List<Version> getVersions() throws VersionRangeResolutionException {
	Artifact artifact = dependency.getArtifact();
	VersionRangeRequest request = new VersionRangeRequest(artifact,
			remoteRepos, null);
	VersionRangeResult resolveVersionRange = repoSystem
			.resolveVersionRange(repoSession, request);
	List<Version> versions = resolveVersionRange.getVersions();
	return versions;

}
 
开发者ID:link-intersystems,项目名称:maven,代码行数:11,代码来源:RichDependency.java


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