org.eclipse.aether.resolution.ArtifactDescriptorException Java Examples

The following examples show how to use org.eclipse.aether.resolution.ArtifactDescriptorException. 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: DeployUtils.java    From vertx-deploy-tools with Apache License 2.0 6 votes vote down vote up
private boolean hasTransitiveSnapshots(Dependency dependency) throws MojoFailureException {
    ArtifactDescriptorRequest descriptorRequest = new ArtifactDescriptorRequest();
    descriptorRequest.setArtifact(
            new DefaultArtifact(dependency.getGroupId(), dependency.getArtifactId(), dependency.getClassifier(), dependency.getType(), dependency.getVersion()));
    descriptorRequest.setRepositories(remoteRepos);

    try {
        ArtifactDescriptorResult result = repoSystem.readArtifactDescriptor(repoSession, descriptorRequest);
        Optional<org.eclipse.aether.graph.Dependency> snapshotDependency = result.getDependencies().stream()
                .filter(d -> d.getArtifact().isSnapshot())
                .findFirst();
        return snapshotDependency.isPresent();
    } catch (ArtifactDescriptorException e) {
        throw new MojoFailureException(e.getMessage(), e);
    }
}
 
Example #2
Source File: BomTest.java    From cloud-opensource-java with Apache License 2.0 6 votes vote down vote up
@Test
public void testReadBom_path()
    throws MavenRepositoryException, ArtifactDescriptorException, URISyntaxException {
  Path pomFile = TestHelper.absolutePathOfResource("libraries-bom-2.7.0.pom");
  Bom bomFromFile = Bom.readBom(pomFile);
  ImmutableList<Artifact> artifactsFromFile = bomFromFile.getManagedDependencies();

  // Compare the result with readBom(String coordinates)
  String expectedBomCoordinates = "com.google.cloud:libraries-bom:2.7.0";
  Bom expectedBom = Bom.readBom(expectedBomCoordinates);
  ImmutableList<Artifact> expectedArtifacts = expectedBom.getManagedDependencies();

  Truth.assertThat(bomFromFile.getCoordinates()).isEqualTo(expectedBomCoordinates);
  Truth.assertThat(artifactsFromFile)
      .comparingElementsUsing(
          transforming(
              Artifacts::toCoordinates, Artifacts::toCoordinates, "has Maven coordinates"))
      .containsExactlyElementsIn(expectedArtifacts)
      .inOrder();
}
 
Example #3
Source File: Cadfael.java    From Poseidon with Apache License 2.0 6 votes vote down vote up
public Set<Artifact> getRejectedDependencies(Artifact artifact) throws ArtifactDescriptorException {
    Set<Dependency> allDependencies = getAllDependencies(artifact);

    Set<Artifact> rejected = new HashSet<>();
    for (Dependency dependency : allDependencies) {
        Scope scope = Scope.compile;
        try {
            scope = Scope.valueOf(dependency.getScope().toLowerCase());
        } catch (Throwable ignored) { }

        if (ignoredScopes.contains(scope)) {
            continue;
        }

        if ((dependency.getArtifact().isSnapshot() && rejectSnapshots) || notAllowed(allowedArtifacts, dependency)) {
            rejected.add(dependency.getArtifact());
        }
    }

    return rejected;
}
 
Example #4
Source File: ExtensionDescriptorMojo.java    From quarkus with Apache License 2.0 6 votes vote down vote up
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 #5
Source File: BootstrapMavenContext.java    From quarkus with Apache License 2.0 6 votes vote down vote up
private List<RemoteRepository> resolveCurrentProjectRepos(List<RemoteRepository> repos)
        throws BootstrapMavenException {
    final Model model = loadCurrentProjectModel();
    if (model == null) {
        return repos;
    }
    final Artifact projectArtifact = new DefaultArtifact(ModelUtils.getGroupId(model), model.getArtifactId(), "", "pom",
            ModelUtils.getVersion(model));
    final List<RemoteRepository> rawRepos;
    try {
        rawRepos = getRepositorySystem()
                .readArtifactDescriptor(getRepositorySystemSession(), new ArtifactDescriptorRequest()
                        .setArtifact(projectArtifact)
                        .setRepositories(repos))
                .getRepositories();
    } catch (ArtifactDescriptorException e) {
        throw new BootstrapMavenException("Failed to read artifact descriptor for " + projectArtifact, e);
    }
    return getRepositorySystem().newResolutionRepositories(getRepositorySystemSession(), rawRepos);
}
 
Example #6
Source File: GithubImporter.java    From scava with Eclipse Public License 2.0 6 votes vote down vote up
private List<String> getMavenParentDependencies(String parent)
		throws DependencyResolutionException, ArtifactDescriptorException {
	List<String> dependencies = new ArrayList<>();
	DefaultServiceLocator locator = MavenRepositorySystemUtils.newServiceLocator();
	RepositorySystem system = newRepositorySystem(locator);
	RepositorySystemSession session = newSession(system);

	RemoteRepository central = new RemoteRepository.Builder("central", "default", "http://repo1.maven.org/maven2/")
			.build();

	org.eclipse.aether.artifact.Artifact artifact = new DefaultArtifact(parent);
	ArtifactDescriptorRequest request = new ArtifactDescriptorRequest(artifact, Arrays.asList(central), null);
	try {
		ArtifactDescriptorResult result = system.readArtifactDescriptor(session, request);
		for (org.eclipse.aether.graph.Dependency dependency : result.getManagedDependencies()) {
			dependencies.add(dependency.getArtifact().getGroupId() + ":" + dependency.getArtifact().getGroupId());
		}
	} catch (Exception e) {
		logger.error(e.getMessage());
	}
	return dependencies;

}
 
Example #7
Source File: MavenArtifactResolver.java    From quarkus with Apache License 2.0 5 votes vote down vote up
private ArtifactDescriptorResult resolveDescriptorInternal(final Artifact artifact, List<RemoteRepository> aggregatedRepos)
        throws BootstrapMavenException {
    try {
        return repoSystem.readArtifactDescriptor(repoSession,
                new ArtifactDescriptorRequest()
                        .setArtifact(artifact)
                        .setRepositories(
                                aggregatedRepos));
    } catch (ArtifactDescriptorException e) {
        throw new BootstrapMavenException("Failed to read descriptor of " + artifact, e);
    }
}
 
Example #8
Source File: Resolver.java    From buck with Apache License 2.0 5 votes vote down vote up
private List<Dependency> getDependenciesOf(Artifact dep) throws ArtifactDescriptorException {
  ArtifactDescriptorRequest descriptorRequest = new ArtifactDescriptorRequest();
  descriptorRequest.setArtifact(dep);
  descriptorRequest.setRepositories(repos);
  descriptorRequest.setRequestContext(JavaScopes.RUNTIME);

  ArtifactDescriptorResult result = repoSys.readArtifactDescriptor(session, descriptorRequest);
  return result.getDependencies();
}
 
Example #9
Source File: Resolver.java    From buck with Apache License 2.0 5 votes vote down vote up
private MutableDirectedGraph<Artifact> buildDependencyGraph(Map<String, Artifact> knownDeps)
    throws ArtifactDescriptorException {
  MutableDirectedGraph<Artifact> graph;
  graph = new MutableDirectedGraph<>();
  for (Map.Entry<String, Artifact> entry : knownDeps.entrySet()) {
    String key = entry.getKey();
    Artifact artifact = entry.getValue();

    graph.addNode(artifact);

    List<Dependency> dependencies = getDependenciesOf(artifact);

    for (Dependency dependency : dependencies) {
      if (dependency.getArtifact() == null) {
        System.out.println("Skipping because artifact missing: " + dependency);
        continue;
      }

      String depKey = buildKey(dependency.getArtifact());
      Artifact actualDep = knownDeps.get(depKey);
      if (actualDep == null) {
        continue;
      }
      // It's possible that the runtime dep of an artifact is the test time dep of another.
      if (isTestTime(dependency)) {
        continue;
      }

      // TODO(simons): Do we always want optional dependencies?
      //        if (dependency.isOptional()) {
      //          continue;
      //        }

      Objects.requireNonNull(actualDep, key + " -> " + artifact + " in " + knownDeps.keySet());
      graph.addNode(actualDep);
      graph.addEdge(actualDep, artifact);
    }
  }
  return graph;
}
 
Example #10
Source File: MavenResolverDependencyManagementVersionResolver.java    From initializr with Apache License 2.0 5 votes vote down vote up
private ArtifactDescriptorResult resolveBom(String groupId, String artifactId, String version) {
	synchronized (this.monitor) {
		try {
			return this.repositorySystem.readArtifactDescriptor(this.repositorySystemSession,
					new ArtifactDescriptorRequest(new DefaultArtifact(groupId, artifactId, "pom", version),
							repositories, null));
		}
		catch (ArtifactDescriptorException ex) {
			throw new IllegalStateException(
					"Bom '" + groupId + ":" + artifactId + ":" + version + "' could not be resolved", ex);
		}
	}
}
 
Example #11
Source File: MavenAddonDependencyResolver.java    From furnace with Eclipse Public License 1.0 5 votes vote down vote up
private ArtifactDescriptorResult readArtifactDescriptor(AddonId addonId) throws ArtifactDescriptorException
{
   String coords = toMavenCoords(addonId);
   RepositorySystem system = container.getRepositorySystem();
   Settings settings = getSettings();
   DefaultRepositorySystemSession session = container.setupRepoSession(system, settings);
   List<RemoteRepository> repositories = MavenRepositories.getRemoteRepositories(container, settings);
   ArtifactDescriptorRequest request = new ArtifactDescriptorRequest();
   request.setArtifact(new DefaultArtifact(coords));
   request.setRepositories(repositories);

   ArtifactDescriptorResult result = system.readArtifactDescriptor(session, request);
   return result;
}
 
Example #12
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 #13
Source File: MavenResolver.java    From Orienteer with Apache License 2.0 5 votes vote down vote up
private List<Artifact> resolveDependencies(String groupArtifactVersion) throws ArtifactDescriptorException,
        DependencyCollectionException, DependencyResolutionException {
    if (Strings.isNullOrEmpty(groupArtifactVersion)) return Lists.newArrayList();

    Artifact artifact = new DefaultArtifact(groupArtifactVersion);
    return OrienteerClassLoaderUtil.resolveAndGetArtifactDependencies(artifact);
}
 
Example #14
Source File: MavenResolver.java    From Orienteer with Apache License 2.0 5 votes vote down vote up
private List<Artifact> resolveDependenciesInArtifacts(String groupArtifactVersion) {
    List<Artifact> results = null;
    try {
        results = resolveDependencies(groupArtifactVersion);
    } catch (ArtifactDescriptorException | DependencyCollectionException | DependencyResolutionException e) {
    	LOG.debug(e.getMessage(), e);
    }
    return results != null ? results : Lists.<Artifact>newArrayList();
}
 
Example #15
Source File: Cadfael.java    From Poseidon with Apache License 2.0 5 votes vote down vote up
public Set<Dependency> getAllDependencies(Artifact artifact) throws ArtifactDescriptorException {
    ArtifactDescriptorRequest request = new ArtifactDescriptorRequest(artifact, repositories, null);
    ArtifactDescriptorResult result = system.readArtifactDescriptor(session, request);

    Set<Dependency> dependencies = new HashSet<>(result.getManagedDependencies());
    dependencies.addAll(result.getDependencies());

    return dependencies;
}
 
Example #16
Source File: RepackageExtensionMojo.java    From syndesis with Apache License 2.0 5 votes vote down vote up
private List<Dependency> obtainBomDependencies(final String urlLocation) {
    final Artifact artifact = downloadAndInstallArtifact(urlLocation).getArtifact();

    final Dependency dependency = new Dependency(artifact, JavaScopes.RUNTIME);

    final List<RemoteRepository> remoteRepositories = project.getRepositories().stream()
        .map(r -> new RemoteRepository.Builder(r.getId(), r.getLayout(), r.getUrl()).build())
        .collect(Collectors.toList());

    CollectResult result;
    try {
        final ArtifactDescriptorRequest descriptorRequest = new ArtifactDescriptorRequest(artifact, remoteRepositories, null);
        final ArtifactDescriptorResult descriptor = repository.readArtifactDescriptor(session, descriptorRequest);

        final List<Dependency> dependencies = Stream.concat(
            descriptor.getDependencies().stream(),
            descriptor.getManagedDependencies().stream())
            .collect(Collectors.toList());

        final DefaultRepositorySystemSession sessionToUse = new DefaultRepositorySystemSession(session);
        sessionToUse.setDependencyGraphTransformer(new NoopDependencyGraphTransformer());

        final CollectRequest request = new CollectRequest(dependency, dependencies, remoteRepositories);
        result = repository.collectDependencies(sessionToUse, request);
    } catch (final DependencyCollectionException | ArtifactDescriptorException e) {
        throw new IllegalStateException("Unabele to obtain BOM dependencies for: " + urlLocation, e);
    }

    final DependencyNode root = result.getRoot();

    final PostorderNodeListGenerator visitor = new PostorderNodeListGenerator();
    root.accept(visitor);

    return visitor.getDependencies(true);
}
 
Example #17
Source File: DependencyResolver.java    From start.spring.io with Apache License 2.0 5 votes vote down vote up
private List<org.eclipse.aether.graph.Dependency> resolveManagedDependencies(String groupId, String artifactId,
		String version, List<RemoteRepository> repositories) {
	try {
		return this.repositorySystem
				.readArtifactDescriptor(this.repositorySystemSession, new ArtifactDescriptorRequest(
						new DefaultArtifact(groupId, artifactId, "pom", version), repositories, null))
				.getManagedDependencies();
	}
	catch (ArtifactDescriptorException ex) {
		throw new RuntimeException(ex);
	}
}
 
Example #18
Source File: BotsingMojo.java    From botsing with Apache License 2.0 5 votes vote down vote up
private void downloadArtifactDescriptorFile(DefaultArtifact aetherArtifact) throws MojoExecutionException {

		ArtifactDescriptorRequest descReq = new ArtifactDescriptorRequest().setRepositories(this.repositories).setArtifact(aetherArtifact);
		try {
			this.repoSystem.readArtifactDescriptor(this.repoSession, descReq);

		} catch ( ArtifactDescriptorException e) {
			throw new MojoExecutionException("Artifact Descriptor for " + aetherArtifact.getArtifactId() + " could not be resolved.", e);
		}
	}
 
Example #19
Source File: BomTest.java    From cloud-opensource-java with Apache License 2.0 5 votes vote down vote up
@Test
public void testReadBom_coordinates_invalidRepository() {
  // This version is so old that it's very unlikely we have it in the Maven local cache,
  // but it exists in Maven central.
  String coordinates = "com.google.cloud:google-cloud-bom:pom:0.32.0-alpha";
  try {
    Bom.readBom(coordinates, ImmutableList.of("http://nonexistent.example.com"));
    fail("readBom should not access Maven Central when it's not in the repository list.");
  } catch (ArtifactDescriptorException ex) {
    assertEquals("Failed to read artifact descriptor for " + coordinates, ex.getMessage());
  }
}
 
Example #20
Source File: BomTest.java    From cloud-opensource-java with Apache License 2.0 5 votes vote down vote up
@Test
public void testReadBom_coordinates() throws ArtifactDescriptorException {
  Bom bom = Bom.readBom("com.google.cloud:google-cloud-bom:0.61.0-alpha");
  List<Artifact> managedDependencies = bom.getManagedDependencies();
  // Characterization test. As long as the artifact doesn't change (and it shouldn't)
  // the answer won't change.
  Assert.assertEquals(134, managedDependencies.size());
  Assert.assertEquals("com.google.cloud:google-cloud-bom:0.61.0-alpha", bom.getCoordinates());
}
 
Example #21
Source File: Bom.java    From cloud-opensource-java with Apache License 2.0 5 votes vote down vote up
/**
 * Parses the dependencyManagement section of an artifact and returns
 * the artifacts included there.
 *
 * @param mavenRepositoryUrls URLs of Maven repositories to search for BOM members
 */
public static Bom readBom(String coordinates, List<String> mavenRepositoryUrls)
    throws ArtifactDescriptorException {
  Artifact artifact = new DefaultArtifact(coordinates);

  RepositorySystem system = RepositoryUtility.newRepositorySystem();
  RepositorySystemSession session = RepositoryUtility.newSession(system);

  ArtifactDescriptorRequest request = new ArtifactDescriptorRequest();

  for (String repositoryUrl : mavenRepositoryUrls) {
    request.addRepository(RepositoryUtility.mavenRepositoryFromUrl(repositoryUrl));
  }

  request.setArtifact(artifact);

  ArtifactDescriptorResult resolved = system.readArtifactDescriptor(session, request);
  List<Exception> exceptions = resolved.getExceptions();
  if (!exceptions.isEmpty()) {
    throw new ArtifactDescriptorException(resolved, exceptions.get(0).getMessage());
  }
  
  List<Artifact> managedDependencies = new ArrayList<>();
  for (Dependency dependency : resolved.getManagedDependencies()) {
    Artifact managed = dependency.getArtifact();
    if (!shouldSkipBomMember(managed) && !managedDependencies.contains(managed)) {
      managedDependencies.add(managed);
    }
  }
  
  Bom bom = new Bom(coordinates, ImmutableList.copyOf(managedDependencies));
  return bom;
}
 
Example #22
Source File: ManagedDependencyLister.java    From cloud-opensource-java with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) throws ArtifactDescriptorException {
  DefaultArtifact artifact =
      new DefaultArtifact("com.google.cloud:libraries-bom:pom:1.0.0");

  RepositorySystemSession session = RepositoryUtility.newSession(system);

  ArtifactDescriptorRequest request = new ArtifactDescriptorRequest();
  request.addRepository(RepositoryUtility.CENTRAL);
  request.setArtifact(artifact);

  ArtifactDescriptorResult resolved = system.readArtifactDescriptor(session, request);
  for (Dependency dependency : resolved.getManagedDependencies()) {
    System.out.println(dependency);
  }
}
 
Example #23
Source File: LinkageMonitorTest.java    From cloud-opensource-java with Apache License 2.0 5 votes vote down vote up
@Test
public void testBomSnapshot()
    throws ModelBuildingException, ArtifactResolutionException, ArtifactDescriptorException {

  Bom bom = Bom.readBom("com.google.cloud:libraries-bom:1.2.0");
  Bom snapshotBom =
      LinkageMonitor.copyWithSnapshot(
          system,
          session,
          bom,
          ImmutableMap.of("com.google.protobuf:protobuf-java", "3.8.0-SNAPSHOT"));

  assertWithMessage(
          "The first element of the SNAPSHOT BOM should be the same as the original BOM")
      .that(toCoordinates(snapshotBom.getManagedDependencies().get(0)))
      .isEqualTo("com.google.protobuf:protobuf-java:3.8.0-SNAPSHOT");

  assertWithMessage("Artifacts other than protobuf-java should have the original version")
      .that(skip(snapshotBom.getManagedDependencies(), 1))
      .comparingElementsUsing(
          transforming(
              Artifacts::toCoordinates,
              Artifacts::toCoordinates,
              "has the same Maven coordinates as"))
      .containsExactlyElementsIn(skip(bom.getManagedDependencies(), 1))
      .inOrder();
}
 
Example #24
Source File: DashboardTest.java    From cloud-opensource-java with Apache License 2.0 5 votes vote down vote up
@Test
public void testArtifactDetails() throws IOException, ArtifactDescriptorException {
  List<Artifact> artifacts = Bom.readBom("com.google.cloud:libraries-bom:1.0.0")
      .getManagedDependencies();
  Assert.assertTrue("Not enough artifacts found", artifacts.size() > 1);

  Assert.assertEquals("en-US", dashboard.getRootElement().getAttribute("lang").getValue());

  Nodes tr = details.query("//tr");
  Assert.assertEquals(artifacts.size() + 1, tr.size()); // header row adds 1
  for (int i = 1; i < tr.size(); i++) { // start at 1 to skip header row
    Nodes td = tr.get(i).query("td");
    Assert.assertEquals(Artifacts.toCoordinates(artifacts.get(i - 1)), td.get(0).getValue());
    for (int j = 1; j < 5; ++j) { // start at 1 to skip the leftmost artifact coordinates column
      assertValidCellValue((Element) td.get(j));
    }
  }
  Nodes href = details.query("//tr/td[@class='artifact-name']/a/@href");
  for (int i = 0; i < href.size(); i++) {
    String fileName = href.get(i).getValue();
    Artifact artifact = artifacts.get(i);
    Assert.assertEquals(
        Artifacts.toCoordinates(artifact).replace(':', '_') + ".html",
        URLDecoder.decode(fileName, "UTF-8"));
    Path componentReport = outputDirectory.resolve(fileName);
    Assert.assertTrue(fileName + " is missing", Files.isRegularFile(componentReport));
    try {
      Document report = builder.build(componentReport.toFile());
      Assert.assertEquals("en-US", report.getRootElement().getAttribute("lang").getValue());
    } catch (ParsingException ex) {
      byte[] data = Files.readAllBytes(componentReport);
      String message = "Could not parse " + componentReport + " at line " +
          ex.getLineNumber() + ", column " + ex.getColumnNumber() + "\r\n";
      message += ex.getMessage() + "\r\n";
      message += new String(data, StandardCharsets.UTF_8);
      Assert.fail(message);
    }
  }
}
 
Example #25
Source File: MavenProjectUtil.java    From microprofile-sandbox with Apache License 2.0 4 votes vote down vote up
public static Map<String, String> getAllDependencies(MavenProject project, RepositorySystem repoSystem,
        RepositorySystemSession repoSession, List<RemoteRepository> remoteRepos, BoostLogger logger)
        throws ArtifactDescriptorException {
    logger.debug("Processing project for dependencies.");
    Map<String, String> dependencies = new HashMap<String, String>();

    for (Artifact artifact : project.getArtifacts()) {
        logger.debug("Found dependency while processing project: " + artifact.getGroupId() + ":"
                + artifact.getArtifactId() + ":" + artifact.getVersion() + ":" + artifact.getType() + ":"
                + artifact.getScope());

        if (artifact.getType().equals("war")) {
            logger.debug("Resolving transitive booster dependencies for war");
            org.eclipse.aether.artifact.Artifact pomArtifact = new DefaultArtifact(artifact.getGroupId(),
                    artifact.getArtifactId(), "pom", artifact.getVersion());

            List<org.eclipse.aether.artifact.Artifact> warArtifacts = getWarArtifacts(pomArtifact, repoSystem,
                    repoSession, remoteRepos);

            for (org.eclipse.aether.artifact.Artifact warArtifact : warArtifacts) {
                // Only add booster dependencies for this war. Anything else
                // like datasource
                // dependencies must be explicitly defined by this project.
                // This is to allow the
                // current project to have full control over those optional
                // dependencies.
                if (warArtifact.getGroupId().equals(AbstractBoosterConfig.BOOSTERS_GROUP_ID)) {
                    logger.debug("Found booster dependency: " + warArtifact.getGroupId() + ":"
                            + warArtifact.getArtifactId() + ":" + warArtifact.getVersion());

                    dependencies.put(warArtifact.getGroupId() + ":" + warArtifact.getArtifactId(),
                            warArtifact.getVersion());
                }
            }

        } else {
            dependencies.put(artifact.getGroupId() + ":" + artifact.getArtifactId(), artifact.getVersion());
        }
    }

    return dependencies;
}
 
Example #26
Source File: MavenProjectUtil.java    From boost with Eclipse Public License 1.0 4 votes vote down vote up
public static Map<String, String> getAllDependencies(MavenProject project, RepositorySystem repoSystem,
        RepositorySystemSession repoSession, List<RemoteRepository> remoteRepos, BoostLogger logger)
        throws ArtifactDescriptorException {
    logger.debug("Processing project for dependencies.");
    Map<String, String> dependencies = new HashMap<String, String>();

    for (Artifact artifact : project.getArtifacts()) {
        logger.debug("Found dependency while processing project: " + artifact.getGroupId() + ":"
                + artifact.getArtifactId() + ":" + artifact.getVersion() + ":" + artifact.getType() + ":"
                + artifact.getScope());

        if (artifact.getType().equals("war")) {
            logger.debug("Resolving transitive booster dependencies for war");
            org.eclipse.aether.artifact.Artifact pomArtifact = new DefaultArtifact(artifact.getGroupId(),
                    artifact.getArtifactId(), "pom", artifact.getVersion());

            List<org.eclipse.aether.artifact.Artifact> warArtifacts = getWarArtifacts(pomArtifact, repoSystem,
                    repoSession, remoteRepos);

            for (org.eclipse.aether.artifact.Artifact warArtifact : warArtifacts) {
                // Only add booster dependencies for this war. Anything else
                // like datasource
                // dependencies must be explicitly defined by this project.
                // This is to allow the
                // current project to have full control over those optional
                // dependencies.
                if (warArtifact.getGroupId().equals(AbstractBoosterConfig.BOOSTERS_GROUP_ID)) {
                    logger.debug("Found booster dependency: " + warArtifact.getGroupId() + ":"
                            + warArtifact.getArtifactId() + ":" + warArtifact.getVersion());

                    dependencies.put(warArtifact.getGroupId() + ":" + warArtifact.getArtifactId(),
                            warArtifact.getVersion());
                }
            }

        } else {
            dependencies.put(artifact.getGroupId() + ":" + artifact.getArtifactId(), artifact.getVersion());
        }
    }

    return dependencies;
}
 
Example #27
Source File: Bom.java    From cloud-opensource-java with Apache License 2.0 2 votes vote down vote up
/**
 * Parses the dependencyManagement section of an artifact and returns the artifacts
 * included there.
 */
public static Bom readBom(String coordinates) throws ArtifactDescriptorException {
  return Bom.readBom(coordinates, ImmutableList.of(RepositoryUtility.CENTRAL.getUrl()));
}