Search in sources :

Example 51 with DefaultArtifact

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);
}
Also used : ArrayList(java.util.ArrayList) Dependency(org.eclipse.aether.graph.Dependency) DependencyManagementArtifactCoordinatesResolver(org.springframework.boot.cli.compiler.dependencies.DependencyManagementArtifactCoordinatesResolver) Exclusion(org.eclipse.aether.graph.Exclusion) CompositeDependencyManagement(org.springframework.boot.cli.compiler.dependencies.CompositeDependencyManagement) DefaultArtifact(org.eclipse.aether.artifact.DefaultArtifact)

Example 52 with DefaultArtifact

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);
    }
}
Also used : DependencyRequest(org.eclipse.aether.resolution.DependencyRequest) DependencyFilter(org.eclipse.aether.graph.DependencyFilter) PatternExclusionsDependencyFilter(org.eclipse.aether.util.filter.PatternExclusionsDependencyFilter) RemoteRepository(org.eclipse.aether.repository.RemoteRepository) DependencyResolutionException(org.eclipse.aether.resolution.DependencyResolutionException) RepositoryException(org.eclipse.aether.RepositoryException) Dependency(org.eclipse.aether.graph.Dependency) CollectRequest(org.eclipse.aether.collection.CollectRequest) DefaultArtifact(org.eclipse.aether.artifact.DefaultArtifact) Artifact(org.eclipse.aether.artifact.Artifact) DefaultArtifact(org.eclipse.aether.artifact.DefaultArtifact) PatternExclusionsDependencyFilter(org.eclipse.aether.util.filter.PatternExclusionsDependencyFilter)

Example 53 with DefaultArtifact

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" + ")");
}
Also used : Rule(com.google.devtools.build.workspace.maven.Rule) DefaultArtifact(org.eclipse.aether.artifact.DefaultArtifact) Test(org.junit.Test)

Example 54 with DefaultArtifact

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));
}
Also used : Path(java.nio.file.Path) Artifact(org.eclipse.aether.artifact.Artifact) DefaultArtifact(org.eclipse.aether.artifact.DefaultArtifact) DefaultArtifact(org.eclipse.aether.artifact.DefaultArtifact) Test(org.junit.Test)

Example 55 with DefaultArtifact

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();
}
Also used : Path(java.nio.file.Path) UnflavoredBuildTarget(com.facebook.buck.model.UnflavoredBuildTarget) IOException(java.io.IOException) MavenPublishable(com.facebook.buck.jvm.java.MavenPublishable) ImmutableSet(com.google.common.collect.ImmutableSet) DeployResult(org.eclipse.aether.deployment.DeployResult) DeploymentException(org.eclipse.aether.deployment.DeploymentException) File(java.io.File) DefaultArtifact(org.eclipse.aether.artifact.DefaultArtifact)

Aggregations

DefaultArtifact (org.eclipse.aether.artifact.DefaultArtifact)110 Artifact (org.eclipse.aether.artifact.Artifact)70 ArtifactResult (org.eclipse.aether.resolution.ArtifactResult)42 File (java.io.File)39 ArtifactRequest (org.eclipse.aether.resolution.ArtifactRequest)34 ArtifactResolutionException (org.eclipse.aether.resolution.ArtifactResolutionException)29 IOException (java.io.IOException)24 Dependency (org.eclipse.aether.graph.Dependency)23 ArrayList (java.util.ArrayList)16 RemoteRepository (org.eclipse.aether.repository.RemoteRepository)13 CollectRequest (org.eclipse.aether.collection.CollectRequest)12 VersionRangeRequest (org.eclipse.aether.resolution.VersionRangeRequest)12 VersionRangeResolutionException (org.eclipse.aether.resolution.VersionRangeResolutionException)12 VersionRangeResult (org.eclipse.aether.resolution.VersionRangeResult)12 SubArtifact (org.eclipse.aether.util.artifact.SubArtifact)12 DefaultRepositorySystemSession (org.eclipse.aether.DefaultRepositorySystemSession)11 ArtifactDescriptorException (org.eclipse.aether.resolution.ArtifactDescriptorException)10 Version (org.eclipse.aether.version.Version)10 Model (org.apache.maven.model.Model)9 RepositorySystem (org.eclipse.aether.RepositorySystem)9