Java Code Examples for org.eclipse.aether.version.Version#toString()

The following examples show how to use org.eclipse.aether.version.Version#toString() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SdkResolver.java    From appengine-maven-plugin with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example 2
Source File: AbstractMavenArtifactRepositoryManager.java    From galleon with Apache License 2.0 5 votes vote down vote up
@Override
public List<String> getAllVersions(MavenArtifact mavenArtifact, Pattern includeVersion, Pattern excludeVersion) throws MavenUniverseException {
    Artifact artifact = new DefaultArtifact(mavenArtifact.getGroupId(),
            mavenArtifact.getArtifactId(), mavenArtifact.getExtension(), mavenArtifact.getVersionRange());
    VersionRangeResult rangeResult = getVersionRange(artifact);
    List<String> versions = new ArrayList<>();
    for (Version v : rangeResult.getVersions()) {
        String vString = v.toString();
        if ((includeVersion == null || includeVersion.matcher(vString).matches())
            && (excludeVersion == null || !excludeVersion.matcher(vString).matches())) {
            versions.add(vString);
        }
    }
    return versions;
}
 
Example 3
Source File: BootstrapAppModelResolver.java    From quarkus with Apache License 2.0 5 votes vote down vote up
private String getEarliest(final VersionRangeResult rangeResult) {
    final List<Version> versions = rangeResult.getVersions();
    if (versions.isEmpty()) {
        return null;
    }
    Version next = versions.get(0);
    for (int i = 1; i < versions.size(); ++i) {
        final Version candidate = versions.get(i);
        if (next.compareTo(candidate) > 0) {
            next = candidate;
        }
    }
    return next.toString();
}
 
Example 4
Source File: BootstrapAppModelResolver.java    From quarkus with Apache License 2.0 5 votes vote down vote up
private String getLatest(final VersionRangeResult rangeResult) {
    final List<Version> versions = rangeResult.getVersions();
    if (versions.isEmpty()) {
        return null;
    }
    Version next = versions.get(0);
    for (int i = 1; i < versions.size(); ++i) {
        final Version candidate = versions.get(i);
        if (candidate.compareTo(next) > 0) {
            next = candidate;
        }
    }
    return next.toString();
}
 
Example 5
Source File: SdkResolver.java    From yawp with MIT License 5 votes vote down vote up
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;
}
 
Example 6
Source File: SdkResolver.java    From gcloud-maven-plugin with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example 7
Source File: MavenPluginLocation.java    From BIMserver with GNU Affero General Public License v3.0 5 votes vote down vote up
private MavenPluginVersion createMavenVersion(Version version) throws ArtifactDescriptorException, FileNotFoundException, IOException, ArtifactResolutionException, XmlPullParserException {
	ArtifactDescriptorRequest descriptorRequest = new ArtifactDescriptorRequest();
	
	Artifact versionArtifact = new DefaultArtifact(groupId, artifactId, "pom", version.toString());
	
	descriptorRequest.setArtifact(versionArtifact);
	descriptorRequest.setRepositories(mavenPluginRepository.getRepositoriesAsList());
	
	MavenPluginVersion mavenPluginVersion = new MavenPluginVersion(versionArtifact, version);
	ArtifactDescriptorResult descriptorResult;
	descriptorResult = mavenPluginRepository.getSystem().readArtifactDescriptor(mavenPluginRepository.getSession(), descriptorRequest);
	
	try {
		ArtifactRequest request = new ArtifactRequest();
		request.setArtifact(descriptorResult.getArtifact());
		request.setRepositories(mavenPluginRepository.getRepositoriesAsList());
		ArtifactResult resolveArtifact = mavenPluginRepository.getSystem().resolveArtifact(mavenPluginRepository.getSession(), request);
		File pomFile = resolveArtifact.getArtifact().getFile();
		MavenXpp3Reader mavenreader = new MavenXpp3Reader();
		
		try (FileReader fileReader = new FileReader(pomFile)) {
			Model model = mavenreader.read(fileReader);
			mavenPluginVersion.setModel(model);
		}
	} catch (Exception e) {
		LOGGER.error(e.getMessage());
	}
	
	for (org.eclipse.aether.graph.Dependency dependency : descriptorResult.getDependencies()) {
		DefaultArtifactVersion artifactVersion = new DefaultArtifactVersion(dependency.getArtifact().getVersion());
		mavenPluginVersion.addDependency(new MavenDependency(dependency.getArtifact(), artifactVersion));
	}
	return mavenPluginVersion;
}
 
Example 8
Source File: DependencyResolver.java    From pinpoint with Apache License 2.0 3 votes vote down vote up
public String getNewestVersion(String groupId, String artifactId) throws VersionRangeResolutionException {
    Artifact artifact = new DefaultArtifact(groupId, artifactId, "jar", "[0,)");

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

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

    Version newestVersion = rangeResult.getHighestVersion();

    return newestVersion.toString();
}