Java Code Examples for org.eclipse.aether.graph.Dependency#isOptional()
The following examples show how to use
org.eclipse.aether.graph.Dependency#isOptional() .
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: ExtensionDescriptorMojo.java From quarkus with Apache License 2.0 | 6 votes |
private CollectRequest newCollectRequest(DefaultArtifact projectArtifact) throws MojoExecutionException { final ArtifactDescriptorResult projectDescr; try { projectDescr = repoSystem.readArtifactDescriptor(repoSession, new ArtifactDescriptorRequest() .setArtifact(projectArtifact) .setRepositories(repos)); } catch (ArtifactDescriptorException e) { throw new MojoExecutionException("Failed to read descriptor of " + projectArtifact, e); } final CollectRequest request = new CollectRequest().setRootArtifact(projectArtifact) .setRepositories(repos) .setManagedDependencies(projectDescr.getManagedDependencies()); for (Dependency dep : projectDescr.getDependencies()) { if ("test".equals(dep.getScope()) || "provided".equals(dep.getScope()) || dep.isOptional()) { continue; } request.addDependency(dep); } return request; }
Example 2
Source File: AddonDependencySelector.java From furnace with Eclipse Public License 1.0 | 6 votes |
@Override public boolean selectDependency(Dependency dependency) { boolean result = false; if (!isExcluded(dependency)) { boolean module = this.classifier.equals(dependency.getArtifact().getClassifier()); String scope = dependency.getScope(); if (dependency.isOptional() && depth > 1) result = false; else if ("test".equals(scope)) result = false; else result = (module && depth == 1) || (!module && !"provided".equals(scope)); } return result; }
Example 3
Source File: DependencyPath.java From cloud-opensource-java with Apache License 2.0 | 5 votes |
@Override public boolean equals(Object o) { if (!(o instanceof DependencyPath)) { return false; } DependencyPath other = (DependencyPath) o; if (!Objects.equals(other.root, root)) { return false; } if (other.path.size() != path.size()) { return false; } for (int i = 0; i < path.size(); i++) { Dependency thisNode = path.get(i); Dependency otherNode = other.path.get(i); if (!artifactsEqual(thisNode.getArtifact(), otherNode.getArtifact())) { return false; } if (!thisNode.getScope().equals(otherNode.getScope())) { return false; } if (thisNode.isOptional() != otherNode.isOptional()) { return false; } } return true; }
Example 4
Source File: DependencyPath.java From cloud-opensource-java with Apache License 2.0 | 4 votes |
private static String formatDependency(Dependency dependency) { String scopeAndOptional = dependency.getScope() + (dependency.isOptional() ? ", optional" : ""); String coordinates = Artifacts.toCoordinates(dependency.getArtifact()); return String.format("%s (%s)", coordinates, scopeAndOptional); }