use of org.eclipse.aether.artifact.DefaultArtifact in project spring-boot by spring-projects.
the class DependencyResolutionContext method addDependencyManagement.
public void addDependencyManagement(DependencyManagement dependencyManagement) {
for (org.springframework.boot.cli.compiler.dependencies.Dependency dependency : dependencyManagement.getDependencies()) {
List<Exclusion> aetherExclusions = new ArrayList<>();
for (org.springframework.boot.cli.compiler.dependencies.Dependency.Exclusion exclusion : dependency.getExclusions()) {
aetherExclusions.add(new Exclusion(exclusion.getGroupId(), exclusion.getArtifactId(), "*", "*"));
}
Dependency aetherDependency = new Dependency(new DefaultArtifact(dependency.getGroupId(), dependency.getArtifactId(), "jar", dependency.getVersion()), JavaScopes.COMPILE, false, aetherExclusions);
this.managedDependencies.add(0, aetherDependency);
this.managedDependencyByGroupAndArtifact.put(getIdentifier(aetherDependency), aetherDependency);
}
this.dependencyManagement = (this.dependencyManagement != null) ? new CompositeDependencyManagement(dependencyManagement, this.dependencyManagement) : dependencyManagement;
this.artifactCoordinatesResolver = new DependencyManagementArtifactCoordinatesResolver(this.dependencyManagement);
}
use of org.eclipse.aether.artifact.DefaultArtifact in project zeppelin by apache.
the class DependencyResolver method getArtifactsWithDep.
/**
* @param dependency
* @param excludes list of pattern can either be of the form groupId:artifactId
* @return
* @throws Exception
*/
@Override
public List<ArtifactResult> getArtifactsWithDep(String dependency, Collection<String> excludes) throws RepositoryException {
Artifact artifact = new DefaultArtifact(dependency);
DependencyFilter classpathFilter = DependencyFilterUtils.classpathFilter(JavaScopes.COMPILE);
PatternExclusionsDependencyFilter exclusionFilter = new PatternExclusionsDependencyFilter(excludes);
CollectRequest collectRequest = new CollectRequest();
collectRequest.setRoot(new Dependency(artifact, JavaScopes.COMPILE));
synchronized (repos) {
for (RemoteRepository repo : repos) {
collectRequest.addRepository(repo);
}
}
DependencyRequest dependencyRequest = new DependencyRequest(collectRequest, DependencyFilterUtils.andFilter(exclusionFilter, classpathFilter));
try {
return system.resolveDependencies(session, dependencyRequest).getArtifactResults();
} catch (NullPointerException | DependencyResolutionException ex) {
throw new RepositoryException(String.format("Cannot fetch dependencies for %s", dependency), ex);
}
}
use of org.eclipse.aether.artifact.DefaultArtifact in project bazel by bazelbuild.
the class ResultWriterTest method testArtifacts.
@Test
public void testArtifacts() throws Exception {
Set<Rule> rules = ImmutableSet.of(new Rule(new DefaultArtifact("x:y:1.2.3")));
String content = getWorkspaceFileContent(ImmutableList.<String>of(), rules);
assertThat(content).contains("maven_jar(\n" + " name = \"x_y\",\n" + " artifact = \"x:y:1.2.3\",\n" + ")");
}
use of org.eclipse.aether.artifact.DefaultArtifact in project buck by facebook.
the class ResolverIntegrationTest method shouldDetectNewestJar.
@Test
public void shouldDetectNewestJar() throws Exception {
Path groupDir = thirdParty.resolve("example");
Path existingNewerJar = groupDir.resolve("no-deps-1.1.jar");
Path existingNewestJar = groupDir.resolve("no-deps-1.2.jar");
Files.createDirectories(groupDir);
Path sourceJar = repo.resolve("com/example/no-deps/1.0/no-deps-1.0.jar");
Files.copy(sourceJar, existingNewerJar);
Files.copy(sourceJar, existingNewestJar);
Artifact artifact = new DefaultArtifact("com.example", "no-deps", "jar", "1.0");
Optional<Path> result = new Resolver(newConfig()).getNewerVersionFile(artifact, groupDir);
assertTrue(result.isPresent());
assertThat(result.get(), equalTo(existingNewestJar));
}
use of org.eclipse.aether.artifact.DefaultArtifact in project buck by facebook.
the class Publisher method publish.
public ImmutableSet<DeployResult> publish(SourcePathResolver pathResolver, ImmutableSet<MavenPublishable> publishables) throws DeploymentException {
ImmutableListMultimap<UnflavoredBuildTarget, UnflavoredBuildTarget> duplicateBuiltinBuileRules = checkForDuplicatePackagedDeps(publishables);
if (duplicateBuiltinBuileRules.size() > 0) {
StringBuilder sb = new StringBuilder();
sb.append("Duplicate transitive dependencies for publishable libraries found! This means");
sb.append(StandardSystemProperty.LINE_SEPARATOR);
sb.append("that the following libraries would have multiple copies if these libraries were");
sb.append(StandardSystemProperty.LINE_SEPARATOR);
sb.append("used together. The can be resolved by adding a maven URL to each target listed");
sb.append(StandardSystemProperty.LINE_SEPARATOR);
sb.append("below:");
for (UnflavoredBuildTarget unflavoredBuildTarget : duplicateBuiltinBuileRules.keySet()) {
sb.append(StandardSystemProperty.LINE_SEPARATOR);
sb.append(unflavoredBuildTarget.getFullyQualifiedName());
sb.append(" (referenced by these build targets: ");
Joiner.on(", ").appendTo(sb, duplicateBuiltinBuileRules.get(unflavoredBuildTarget));
sb.append(")");
}
throw new DeploymentException(sb.toString());
}
ImmutableSet.Builder<DeployResult> deployResultBuilder = ImmutableSet.builder();
for (MavenPublishable publishable : publishables) {
DefaultArtifact coords = new DefaultArtifact(Preconditions.checkNotNull(publishable.getMavenCoords().get(), "No maven coordinates specified for published rule ", publishable));
Path relativePathToOutput = pathResolver.getRelativePath(Preconditions.checkNotNull(publishable.getSourcePathToOutput(), "No path to output present in ", publishable));
File mainItem = publishable.getProjectFilesystem().resolve(relativePathToOutput).toFile();
if (!coords.getClassifier().isEmpty()) {
deployResultBuilder.add(publish(coords, ImmutableList.of(mainItem)));
}
try {
// If this is the "main" artifact (denoted by lack of classifier) generate and publish
// pom alongside
File pom = Pom.generatePomFile(pathResolver, publishable).toFile();
deployResultBuilder.add(publish(coords, ImmutableList.of(mainItem, pom)));
} catch (IOException e) {
throw new RuntimeException(e);
}
}
return deployResultBuilder.build();
}
Aggregations