org.eclipse.aether.version.Version Java Examples
The following examples show how to use
org.eclipse.aether.version.Version.
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: MavenDependencyResolver.java From spring-cloud-formula with Apache License 2.0 | 6 votes |
public List<Version> getAllVersions(String groupId, String artifactId) { String repositoryUrl = "http://maven.repo/nexus/content/groups/public"; RepositorySystem repoSystem = newRepositorySystem(); RepositorySystemSession session = newSession(repoSystem); RemoteRepository central = null; central = new RemoteRepository.Builder("central", "default", repositoryUrl).build(); Artifact artifact = new DefaultArtifact(groupId + ":" + artifactId + ":[0,)"); VersionRangeRequest rangeRequest = new VersionRangeRequest(); rangeRequest.setArtifact(artifact); rangeRequest.addRepository(central); VersionRangeResult rangeResult; try { rangeResult = repoSystem.resolveVersionRange(session, rangeRequest); } catch (VersionRangeResolutionException e) { throw new RuntimeException(e); } List<Version> versions = rangeResult.getVersions().stream() .filter(v -> !v.toString().toLowerCase().endsWith("-snapshot")) .filter(v -> !groupId.contains("org.springframework") || v.toString().equals("2.0.0.RELEASE")) .collect(Collectors.toList()); logger.info("artifact: {}, Available versions: {}", artifact, versions); return versions; }
Example #2
Source File: AetherUtils.java From Orienteer with Apache License 2.0 | 6 votes |
public List<String> requestArtifactVersions(Artifact artifact) { List<String> versions = Lists.newArrayList(); VersionRangeRequest rangeRequest = new VersionRangeRequest(); rangeRequest.setArtifact(artifact); rangeRequest.setRepositories(repositories); try { VersionRangeResult versionResult = system.resolveVersionRange(session, rangeRequest); if (!versionResult.getVersions().isEmpty()) { String highest = versionResult.getHighestVersion().toString(); versions.add(highest); for (Version version : versionResult.getVersions()) { if (!highest.equals(version.toString())) versions.add(version.toString()); } } } catch (VersionRangeResolutionException e) { LOG.error("Can't create version request: {}", e); } return versions; }
Example #3
Source File: SdkResolver.java From appengine-maven-plugin with Apache License 2.0 | 6 votes |
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 #4
Source File: VersionComparator.java From nexus-public with Eclipse Public License 1.0 | 6 votes |
@Override public int compare(final String o1, final String o2) { boolean firstObjectLooksLikeVersion = isVersionLike(o1); boolean secondObjectLooksLikeVersion = isVersionLike(o2); if (firstObjectLooksLikeVersion ^ secondObjectLooksLikeVersion) { if (firstObjectLooksLikeVersion) { return 1; } else { return -1; } } else if (firstObjectLooksLikeVersion) { Version v1 = version(o1); Version v2 = version(o2); return v1.compareTo(v2); } else { return o1.compareTo(o2); } }
Example #5
Source File: VersionUtils.java From rug-cli with GNU General Public License v3.0 | 6 votes |
public static void validateRugCompatibility(ArtifactDescriptor artifact, List<ArtifactDescriptor> dependencies) { Optional<ArtifactDescriptor> rugArtifact = dependencies.stream() .filter(f -> f.group().equals(Constants.GROUP) && f.artifact().equals(Constants.RUG_ARTIFACT)) .findAny(); if (rugArtifact.isPresent()) { try { Version version = VERSION_SCHEME.parseVersion(rugArtifact.get().version()); VersionRange range = VERSION_SCHEME.parseVersionRange(Constants.RUG_VERSION_RANGE); if (!range.containsVersion(version)) { throw new VersionException(String.format( "Installed version of Rug CLI is not compatible with archive %s.\n\n" + "The archive depends on %s:%s (%s) which is incompatible with Rug CLI (compatible version range %s).\n" + "Please update to a more recent version of Rug CLI or change the Rug archive to use a supported Rug version.", ArtifactDescriptorUtils.coordinates(artifact), Constants.GROUP, Constants.RUG_ARTIFACT, version.toString(), range.toString())); } } catch (InvalidVersionSpecificationException e) { // Since we were able to resolve the version it is impossible for this to happen } } }
Example #6
Source File: UpgradeXGAPP.java From gate-core with GNU Lesser General Public License v3.0 | 6 votes |
public static Version getDefaultSelection(VersionRangeResult vrr) { if(vrr == null) { return null; } List<Version> versions = vrr.getVersions(); // is the version of GATE we are running a SNAPSHOT? boolean isSnapshot = Main.version.toUpperCase().endsWith("-SNAPSHOT"); int i = versions.size() - 1; while(i >= 0 && !isSnapshot) { // if GATE isn't a SNAPSHOT then work back through the versions until... Version v = versions.get(i); if(!v.toString().toUpperCase().endsWith("-SNAPSHOT")) { // we find one that isn't a SNAPSHOT return v; } --i; } // either GATE is a SNAPSHOT release or all the versions are SNAPSHOTS and // in either case we just return the latest return versions.get(versions.size() - 1); }
Example #7
Source File: MavenArtifactVersionRangeParser.java From galleon with Apache License 2.0 | 6 votes |
public static void main(String[] args) throws Exception { GenericVersionScheme scheme = new GenericVersionScheme(); //ComparableVersion v = new ComparableVersion("1.0.0.Alpha-SNAPSHOT"); //ComparableVersion v2 = new ComparableVersion("1.0-alpha"); Version v = scheme.parseVersion("1.0.0.Deta3"); Version v2 = scheme.parseVersion("1.0.0.Beta2"); System.out.println(v2.compareTo(v)); MavenArtifactVersion v1 = new MavenArtifactVersion("1.0.0.Alpha1-SNAPSHOT"); final MavenArtifactVersionRangeParser parser = new MavenArtifactVersionRangeParser(); MavenArtifactVersionRange range = parser.parseRange("[1.0-alpha,2.0-alpha)"); System.out.println(range); System.out.println(range.includesVersion(v1)); }
Example #8
Source File: RepositoryUtilityTest.java From cloud-opensource-java with Apache License 2.0 | 6 votes |
@Test public void testFindHighestVersions() throws MavenRepositoryException, InvalidVersionSpecificationException { RepositorySystem system = RepositoryUtility.newRepositorySystem(); // FindHighestVersion should work for both jar and pom (extension:pom) artifacts for (String artifactId : ImmutableList.of("guava", "guava-bom")) { String guavaHighestVersion = RepositoryUtility.findHighestVersion( system, RepositoryUtility.newSession(system), "com.google.guava", artifactId); Assert.assertNotNull(guavaHighestVersion); // Not comparing alphabetically; otherwise "100.0" would be smaller than "28.0" VersionScheme versionScheme = new GenericVersionScheme(); Version highestGuava = versionScheme.parseVersion(guavaHighestVersion); Version guava28 = versionScheme.parseVersion("28.0"); Truth.assertWithMessage("Latest guava release is greater than or equal to 28.0") .that(highestGuava) .isAtLeast(guava28); } }
Example #9
Source File: SdkResolver.java From gcloud-maven-plugin with Apache License 2.0 | 5 votes |
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 #10
Source File: MetadataBuilder.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
@Nullable private Version parseVersion(final String version) { try { return versionScheme.parseVersion(version); } catch (InvalidVersionSpecificationException e) { log.warn("Invalid version: {}", version, e); return null; } }
Example #11
Source File: AbstractMavenArtifactRepositoryManager.java From galleon with Apache License 2.0 | 5 votes |
@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 #12
Source File: MetadataBuilder.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
@Nullable public Maven2Metadata onExitArtifactId() { checkState(artifactId != null); log.debug("<- GA: {}:{}", groupId, artifactId); if (baseVersions.isEmpty()) { log.debug("Nothing to generate: {}:{}", groupId, artifactId); return null; } Iterator<Version> vi = baseVersions.descendingIterator(); String latest = vi.next().toString(); String release = latest; while (release.endsWith(Constants.SNAPSHOT_VERSION_SUFFIX) && vi.hasNext()) { release = vi.next().toString(); } if (release.endsWith(Constants.SNAPSHOT_VERSION_SUFFIX)) { release = null; } return Maven2Metadata.newArtifactLevel( DateTime.now(), groupId, artifactId, latest, release, Iterables.transform(baseVersions, new Function<Version, String>() { @Override public String apply(final Version input) { return input.toString(); } })); }
Example #13
Source File: ArtifactResolver.java From revapi with Apache License 2.0 | 5 votes |
/** * 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 */ 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; } }; }
Example #14
Source File: NewestVersionSelector.java From wildfly-swarm with Apache License 2.0 | 5 votes |
private boolean isAcceptable(ConflictGroup group, Version version) { for (VersionConstraint constraint : group.constraints) { if (!constraint.containsVersion(version)) { return false; } } return true; }
Example #15
Source File: PublishCommand.java From rug-cli with GNU General Public License v3.0 | 5 votes |
protected void doWithRepositorySession(RepositorySystem system, RepositorySystemSession session, ArtifactSource source, Manifest manifest, Artifact zip, Artifact pom, Artifact metadata, CommandLine commandLine) { Set<String> ids = org.springframework.util.StringUtils .commaDelimitedListToSet(CommandLineOptions.getOptionValue("id").orElse("")); if (CommandLineOptions.hasOption("U")) { String group = manifest.group(); String artifact = manifest.artifact(); Version version = VersionUtils.parseVersion(manifest.version()); SearchCommand search = new SearchCommand(); Map<String, List<Operation>> operations = search.search(SettingsReader.read(), null, new Properties(), null); operations.values().stream().filter(ops -> ops.size() > 0).forEach(ops -> { Archive archive = ops.get(0).archive(); if (archive.group().equals(group) && archive.artifact().equals(artifact) && !"global".equals(archive.scope())) { if (version .compareTo(VersionUtils.parseVersion(archive.version().value())) > 0) { ids.add(archive.scope()); } } }); } List<org.eclipse.aether.repository.RemoteRepository> deployRepositorys = getDeployRepositories( ids); deployRepositorys.forEach( r -> publishToRepository(system, session, source, manifest, zip, pom, metadata, r)); }
Example #16
Source File: SdkResolver.java From yawp with MIT License | 5 votes |
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 #17
Source File: VersionUtils.java From rug-cli with GNU General Public License v3.0 | 5 votes |
public static Version parseVersion(String version) { try { return VERSION_SCHEME.parseVersion(version); } catch (InvalidVersionSpecificationException e) { throw new CommandException( String.format("Unable to parse version number '%s'", version), e); } }
Example #18
Source File: VersionUtils.java From rug-cli with GNU General Public License v3.0 | 5 votes |
public static Optional<String> newerVersion() { try { VersionScheme scheme = new GenericVersionScheme(); Version runningVersion = scheme.parseVersion(readVersion().orElse("0.0.0")); Version onlineVersion = scheme.parseVersion(readOnlineVersion().orElse("0.0.0")); return (onlineVersion.compareTo(runningVersion) > 0 ? Optional.of(onlineVersion.toString()) : Optional.empty()); } catch (InvalidVersionSpecificationException e) { } return Optional.empty(); }
Example #19
Source File: XgappUpgradeSelector.java From gate-core with GNU Lesser General Public License v3.0 | 5 votes |
@Override @SuppressWarnings("unchecked") public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { JComboBox<Version> combo = (JComboBox<Version>)super.getTableCellEditorComponent(table, value, isSelected, row, column); DefaultComboBoxModel<Version> model = (DefaultComboBoxModel<Version>)combo.getModel(); model.removeAllElements(); UpgradeXGAPP.UpgradePath path = (UpgradeXGAPP.UpgradePath)table.getValueAt(row, -1); for(Version v : path.getVersions()) { model.addElement(v); } combo.setSelectedItem(value); // which must be one of the available ones return combo; }
Example #20
Source File: XgappUpgradeSelector.java From gate-core with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void setValueAt(Object aValue, int rowIndex, int columnIndex) { UpgradeXGAPP.UpgradePath path = upgrades.get(rowIndex); if(columnIndex == 1) { PluginCoordinates coords = (PluginCoordinates)aValue; VersionRangeResult vrr = UpgradeXGAPP.getPluginVersions(coords.groupId, coords.artifactId); List<Version> versions = (vrr == null ? null : vrr.getVersions()); if(versions != null && !versions.isEmpty()) { path.setGroupID(coords.groupId); path.setArtifactID(coords.artifactId); path.setVersionRangeResult(vrr); path.setUpgradeStrategy(UpgradeXGAPP.UpgradePath.UpgradeStrategy.UPGRADE); fireTableCellUpdated(rowIndex, 2); if(!versions.contains(path.getSelectedVersion())) { path.setSelectedVersion(UpgradeXGAPP.getDefaultSelection(vrr)); fireTableCellUpdated(rowIndex, 3); } } else { statusLabel.setIcon(warningIcon); statusLabel.setText(coords + " is not a valid GATE plugin"); } } else if(columnIndex == 2) { path.setUpgradeStrategy((UpgradeXGAPP.UpgradePath.UpgradeStrategy) aValue); // may need to re-render the version column fireTableCellUpdated(rowIndex, 3); } else if(columnIndex == 3) { path.setSelectedVersion((Version) aValue); } }
Example #21
Source File: XgappUpgradeSelector.java From gate-core with GNU Lesser General Public License v3.0 | 5 votes |
@Override public Class<?> getColumnClass(int columnIndex) { switch(columnIndex) { case 0: return String.class; case 1: return PluginCoordinates.class; case 2: return UpgradeXGAPP.UpgradePath.UpgradeStrategy.class; case 3: return Version.class; default: return null; } }
Example #22
Source File: DependencyResolver.java From pinpoint with Apache License 2.0 | 5 votes |
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; }
Example #23
Source File: UpgradeXGAPP.java From gate-core with GNU Lesser General Public License v3.0 | 5 votes |
public void setSelectedVersion(Version version) { if(versions == null) { if(version == null) { this.selected = null; } else { throw new IllegalArgumentException("Supplied version isn't valid"); } } else if(!versions.getVersions().contains(version)) { throw new IllegalArgumentException("Supplied version isn't valid"); } this.selected = version; }
Example #24
Source File: UpgradeXGAPP.java From gate-core with GNU Lesser General Public License v3.0 | 5 votes |
public UpgradePath(Element oldEntry, String oldPath, String groupID, String artifactID, VersionRangeResult versions, Version current, Version selected) { this.oldEntry = oldEntry; this.oldPath = oldPath.endsWith("/") ? oldPath : oldPath + "/"; this.groupID = groupID; this.artifactID = artifactID; this.versions = versions; this.selected = selected; this.current = current; this.upgradeStrategy = (versions == null ? UpgradeStrategy.SKIP : UpgradeStrategy.UPGRADE); }
Example #25
Source File: MavenPluginLocation.java From BIMserver with GNU Affero General Public License v3.0 | 5 votes |
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 #26
Source File: BootstrapAppModelResolver.java From quarkus with Apache License 2.0 | 5 votes |
@Override public List<String> listLaterVersions(AppArtifact appArtifact, String upToVersion, boolean inclusive) throws AppModelResolverException { final VersionRangeResult rangeResult = resolveVersionRangeResult(appArtifact, appArtifact.getVersion(), false, upToVersion, inclusive); final List<Version> resolvedVersions = rangeResult.getVersions(); final List<String> versions = new ArrayList<>(resolvedVersions.size()); for (Version v : resolvedVersions) { versions.add(v.toString()); } return versions; }
Example #27
Source File: Plugin.java From gate-core with GNU Lesser General Public License v3.0 | 5 votes |
public boolean isValid() { // we need to ensure parseCreole() has been called before we can know if the // valid flag is .... valid getResourceInfoList(); //Main.version if (Gate.VERSION == null || minGateVersion == null || minGateVersion.isEmpty()) { Utils.logOnce(log, Level.DEBUG, "unable to check minimum GATE version, plugins may not load or might produce errors"); return valid; } try { Version pluginVersion = versionScheme.parseVersion(minGateVersion); boolean validGateVersion = Gate.VERSION.compareTo(pluginVersion) >= 0; if(!validGateVersion) { Utils.logOnce(log, Level.WARN, getName() + " is not compatible with this version of GATE, requires at least GATE" + pluginVersion.toString()); } valid = valid && validGateVersion; } catch(InvalidVersionSpecificationException e) { Utils.logOnce(log, Level.DEBUG, "unable to parse minimum GATE version, plugin, " + getName() + ", may not load or might produce errors"); } return valid; }
Example #28
Source File: BootstrapAppModelResolver.java From quarkus with Apache License 2.0 | 5 votes |
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 #29
Source File: BootstrapAppModelResolver.java From quarkus with Apache License 2.0 | 5 votes |
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 #30
Source File: MavenAddonDependencyResolver.java From furnace with Eclipse Public License 1.0 | 4 votes |
@Override public Response<AddonId[]> resolveVersions(final String addonName) { String addonNameSplit; String version; String[] split = addonName.split(","); if (split.length == 2) { addonNameSplit = split[0]; version = split[1]; } else { addonNameSplit = addonName; version = null; } RepositorySystem system = container.getRepositorySystem(); Settings settings = getSettings(); DefaultRepositorySystemSession session = container.setupRepoSession(system, settings); List<RemoteRepository> repositories = MavenRepositories.getRemoteRepositories(container, settings); VersionRangeResult versions = getVersions(system, settings, session, repositories, addonNameSplit, version); List<Exception> exceptions = versions.getExceptions(); List<Version> versionsList = versions.getVersions(); List<AddonId> addons = new ArrayList<AddonId>(); List<AddonId> snapshots = new ArrayList<AddonId>(); for (Version artifactVersion : versionsList) { AddonId addonId = AddonId.from(addonName, artifactVersion.toString()); if (Versions.isSnapshot(addonId.getVersion())) { snapshots.add(addonId); } else { addons.add(addonId); } } if (addons.isEmpty()) { addons = snapshots; } return new MavenResponseBuilder<AddonId[]>(addons.toArray(new AddonId[addons.size()])).setExceptions(exceptions); }