Java Code Examples for org.eclipse.aether.artifact.Artifact

The following examples show how to use org.eclipse.aether.artifact.Artifact. These examples are extracted from open source projects. 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
private Set<ArtifactWithRepoType> getArtifactsFromCollectResult(CollectResult collectResult, RepositoryType context) {
    CollectAllDependenciesVisitor visitor = new CollectAllDependenciesVisitor();
    collectResult.getRoot().accept(visitor);
    Set<Artifact> visitorArtifacts = visitor.getArtifacts();
    Set<ArtifactWithRepoType> artifacts = new HashSet<>();
    for (Artifact visitorArtifact : visitorArtifacts) {
        if (!isReactorArtifact(visitorArtifact)) {
            artifacts.add(new ArtifactWithRepoType(visitorArtifact, context));
        }
    }
    Artifact rootArtifact = collectResult.getRoot().getArtifact();
    if (!isReactorArtifact(rootArtifact)) {
        artifacts.add(new ArtifactWithRepoType(rootArtifact, context));
    }
    return artifacts;
}
 
Example 2
Source Project: thorntail   Source File: ExtraArtifactsHandler.java    License: Apache License 2.0 6 votes vote down vote up
private void addDependencies(Function<Artifact, Boolean> duplicateFilter, Optional<String> extension, Optional<String> classifier) {
    List<Dependency> dependencies = input.stream()
            .map(DependencyNode::getDependency)
            .collect(Collectors.toList());

    Set<String> existingGavs = dependencies.stream()
            .map(Dependency::getArtifact)
            .filter(duplicateFilter::apply)
            .map(this::toGav)
            .collect(Collectors.toSet());

    List<DependencyNode> newNodes = input.stream()
            .filter(n -> !existingGavs.contains(toGav(n.getDependency().getArtifact())))
            .map(n -> createNode(n, extension, classifier))
            .collect(Collectors.toList());
    output.addAll(newNodes);
}
 
Example 3
Source Project: pinpoint   Source File: PinpointPluginTestSuite.java    License: Apache License 2.0 6 votes vote down vote up
private List<PinpointPluginTestInstance> createCasesWithDependencies(PinpointPluginTestContext context) throws ArtifactResolutionException, DependencyResolutionException {
    List<PinpointPluginTestInstance> cases = new ArrayList<PinpointPluginTestInstance>();

    DependencyResolver resolver = getDependencyResolver(repositories);
    Map<String, List<Artifact>> dependencyCases = resolver.resolveDependencySets(dependencies);

    for (Map.Entry<String, List<Artifact>> dependencyCase : dependencyCases.entrySet()) {
        List<String> libs = new ArrayList<String>();

        for (File lib : resolver.resolveArtifactsAndDependencies(dependencyCase.getValue())) {
            libs.add(lib.getAbsolutePath());
        }

        if (testOnSystemClassLoader) {
            cases.add(new NormalPluginTestCase(context, dependencyCase.getKey(), libs, true));
        }

        if (testOnChildClassLoader) {
            cases.add(new NormalPluginTestCase(context, dependencyCase.getKey(), libs, false));
        }
    }

    return cases;
}
 
Example 4
private DeployRequest createAutoDiscoverDeployRequest(List<Artifact> dependencies, boolean testScope) {
    List<DeployConfigRequest> configs = dependencies.stream()
            .filter(a -> ModuleRequest.CONFIG_TYPE.equals(a.getExtension()))
            .map(a -> DeployConfigRequest.build(a.getGroupId(), a.getArtifactId(), a.getVersion(), a.getClassifier()))
            .collect(Collectors.toList());

    List<DeployArtifactRequest> artifacts = dependencies.stream()
            .filter(a -> ModuleRequest.ZIP_TYPE.equals(a.getExtension()) || ModuleRequest.GZIP_TYPE.equals(a.getExtension()))
            .map(a -> DeployArtifactRequest.build(a.getGroupId(), a.getArtifactId(), a.getVersion(), a.getClassifier(), a.getExtension()))
            .collect(Collectors.toList());

    List<DeployApplicationRequest> applications = dependencies.stream()
            .filter(a -> "jar".equals(a.getExtension()))
            .map(a -> DeployApplicationRequest.build(a.getGroupId(), a.getArtifactId(), a.getVersion(), a.getClassifier(), testScope))
            .collect(Collectors.toList());

    return new DeployRequest(applications, artifacts, configs, false, false, "", false, testScope);
}
 
Example 5
Source Project: vertx-stack   Source File: ResolverTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testThatExcludedDependenciesAndThereDependenciesAreResolvedWithATransitiveNotExcludedMentionedFirst() {
  new LocalRepoBuilder(LOCAL)
      .addArtifact(new LocalArtifact("com.acme", "acme-api", "1.0")
          .generateMainArtifact()
          .addDependency(new LocalDependency("com.acme", "acme-log", "1.0").type("txt")))

      .addArtifact(new LocalArtifact("com.acme", "acme-excluded", "1.0")
          .generateMainArtifact()
          .addDependency(new LocalDependency("com.acme", "acme-log", "1.0").type("txt")))

      .addArtifact(new LocalArtifact("com.acme", "acme-log", "1.0").generateMainArtifact())

      .addArtifact(new LocalArtifact("com.acme", "acme", "1.0")
          .generateMainArtifact()
          .addDependency(new LocalDependency("com.acme", "acme-api", "1.0").type("txt"))
          .addDependency(new LocalDependency("com.acme", "acme-excluded", "1.0").type("txt"))
      )
      .build();
  List<Artifact> artifacts = resolver.resolve("com.acme:acme:txt:1.0",
      new ResolutionOptions().setWithTransitive(true).addExclusion("com.acme:acme-excluded"));
  assertThat(artifacts.stream().map(Artifact::getArtifactId).collect(Collectors.toList()))
      .hasSize(3)
      .contains("acme", "acme-api", "acme-log");
}
 
Example 6
Source Project: vertx-stack   Source File: ResolverTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testResolutionWhenADependencyIsPresentTwiceInTheGraphWithVersion() {
  
  new LocalRepoBuilder(LOCAL)
      .addArtifact(new LocalArtifact("com.acme", "acme-api", "1.0").generateMainArtifact())
      .addArtifact(new LocalArtifact("com.acme", "acme-api", "1.1").generateMainArtifact())
      .addArtifact(new LocalArtifact("com.acme", "acme-lib", "1.0")
          .generateMainArtifact()
          .addDependency(new LocalDependency("com.acme", "acme-api", "1.0").type("txt"))
      )
      .addArtifact(new LocalArtifact("com.acme", "acme", "1.0")
          .generateMainArtifact()
          .addDependency(new LocalDependency("com.acme", "acme-lib", "1.0").type("txt"))
          .addDependency(new LocalDependency("com.acme", "acme-test", "1.0").type("txt").scope("test"))
          .addDependency(new LocalDependency("com.acme", "acme-api", "1.1").type("txt"))
      )
      .build();
  List<Artifact> artifacts = resolver.resolve("com.acme:acme:txt:1.0", new ResolutionOptions().setWithTransitive(true));
  assertThat(artifacts.stream().map(Artifact::toString).collect(Collectors.toList()))
      .hasSize(3)
      .contains("com.acme:acme:txt:1.0", "com.acme:acme-api:txt:1.1", "com.acme:acme-lib:txt:1.0");
}
 
Example 7
Source Project: pinpoint   Source File: DependencyResolverTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void resolveArtifactsAndDependencies() throws DependencyResolutionException, ArtifactResolutionException {
    DependencyResolverFactory factory = new DependencyResolverFactory();
    DependencyResolver resolver = factory.get();

    Map<String, List<Artifact>> sets = resolver.resolveDependencySets("org.eclipse.aether:aether-util:[0,)", "org.eclipse.aether:aether-spi");

    int i = 0;
    for (Map.Entry<String, List<Artifact>> set : sets.entrySet()) {
        logger.debug("{}", i++);
        List<File> results = resolver.resolveArtifactsAndDependencies(set.getValue());

        logger.debug(set.getKey());

        for (File result : results) {
            logger.debug("{}", result);
        }
    }
}
 
Example 8
Source Project: mvn2nix-maven-plugin   Source File: Mvn2NixMojo.java    License: MIT License 6 votes vote down vote up
private Dependency mavenDependencyToDependency(
		org.apache.maven.model.Dependency dep) {
	Artifact art = new DefaultArtifact(dep.getGroupId(),
		dep.getArtifactId(),
		dep.getClassifier(),
		dep.getType(),
		dep.getVersion());
	Collection<Exclusion> excls = new HashSet<Exclusion>();
	for (org.apache.maven.model.Exclusion excl :
		dep.getExclusions()) {
		excls.add(mavenExclusionToExclusion(excl));
	}
	return new Dependency(art,
		dep.getScope(),
		new Boolean(dep.isOptional()),
		excls);
}
 
Example 9
Source Project: vertx-stack   Source File: CacheTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testCachingOfReleaseAndUpdate() throws IOException {
  String gacv = "org.acme:acme:jar:1.0";
  ResolutionOptions options = new ResolutionOptions();
  List<Artifact> list = cache.get(gacv, options);
  assertThat(list).isNull();

  Artifact artifact = new DefaultArtifact("org.acme:acme:jar:1.0").setFile(TEMP_FILE);
  Artifact artifact2 = new DefaultArtifact("org.acme:acme-dep:jar:1.0").setFile(TEMP_FILE);

  cache.put(gacv, options, Collections.singletonList(artifact));
  list = cache.get(gacv, options);
  assertThat(list).hasSize(1);

  cache.put(gacv, options, Collections.singletonList(artifact));
  list = cache.get(gacv, options);
  assertThat(list).hasSize(1);

  cache.put(gacv, options, Arrays.asList(artifact, artifact2));
  list = cache.get(gacv, options);
  assertThat(list).hasSize(2);
}
 
Example 10
Source Project: takari-lifecycle   Source File: AetherUtils.java    License: Eclipse Public License 1.0 6 votes vote down vote up
public static Artifact toArtifact(org.apache.maven.artifact.Artifact artifact) {
  if (artifact == null) {
    return null;
  }

  String version = artifact.getVersion();
  if (version == null && artifact.getVersionRange() != null) {
    version = artifact.getVersionRange().toString();
  }

  Map<String, String> props = null;
  if (org.apache.maven.artifact.Artifact.SCOPE_SYSTEM.equals(artifact.getScope())) {
    String localPath = (artifact.getFile() != null) ? artifact.getFile().getPath() : "";
    props = Collections.singletonMap(ArtifactProperties.LOCAL_PATH, localPath);
  }

  Artifact result = new DefaultArtifact(artifact.getGroupId(), artifact.getArtifactId(), artifact.getClassifier(), artifact.getArtifactHandler().getExtension(), version, props,
      newArtifactType(artifact.getType(), artifact.getArtifactHandler()));
  result = result.setFile(artifact.getFile());

  return result;
}
 
Example 11
private SimpleReactorReader(Collection<MavenProject> projects, Collection<Artifact> artifacts) {
  repository = new WorkspaceRepository("reactor", new Object());

  Map<String, MavenProject> projectsByGAV = new LinkedHashMap<>();
  for (MavenProject project : projects) {
    String projectKey = ArtifactUtils.key(project.getGroupId(), project.getArtifactId(), project.getVersion());
    projectsByGAV.put(projectKey, project);
  }
  this.projectsByGAV = ImmutableMap.copyOf(projectsByGAV);

  Map<String, Artifact> artifactsByGAVCE = new LinkedHashMap<>();
  for (Artifact artifact : artifacts) {
    artifactsByGAVCE.put(keyGAVCE(artifact), artifact);
  }
  this.artifactsByGAVCE = ImmutableMap.copyOf(artifactsByGAVCE);
}
 
Example 12
public static void main(String args[]) throws Exception {

    for(RemoteRepository repo : Utils.getRepositoryList()) {
      System.out.println(repo);
    }

    Artifact artifactObj = new DefaultArtifact("uk.ac.gate.plugins", "annie",
        "jar", "8.5-SNAPSHOT");
    // artifactObj = artifactObj.setFile(
    // new
    // File("/home/mark/.m2/repository/uk/ac/gate/plugins/annie/8.5-SNAPSHOT/annie-8.5-SNAPSHOT.jar"));

    SimpleMavenCache reader = new SimpleMavenCache(new File("repo"));
    System.out.println(reader.findArtifact(artifactObj));
    System.out.println(reader.findVersions(artifactObj));
    reader.cacheArtifact(artifactObj);
    System.out.println(reader.findArtifact(artifactObj));
    System.out.println(reader.findVersions(artifactObj));

    reader = new SimpleMavenCache(new File("repo2"), new File("repo"));
    System.out.println(reader.findArtifact(artifactObj));
    System.out.println(reader.findVersions(artifactObj));
  }
 
Example 13
Source Project: onos   Source File: AetherResolver.java    License: Apache License 2.0 6 votes vote down vote up
private String getSha(Artifact artifact) throws Exception {
    String directory = artifact.getFile().getParent();
    StringBuilder file = new StringBuilder();

    // artifactId-version[-classifier].version.sha1
    file.append(artifact.getArtifactId())
            .append('-').append(artifact.getVersion());

    if (!artifact.getClassifier().isEmpty()) {
        file.append('-').append(artifact.getClassifier());
    }
    file.append('.').append(artifact.getExtension())
            .append(".sha1");

    String shaPath = Paths.get(directory, file.toString()).toString();

    try (Reader reader = new FileReader(shaPath)) {
        return new BufferedReader(reader).readLine().trim().split(" ", 2)[0];
    }
}
 
Example 14
Source Project: component-runtime   Source File: SingerMojo.java    License: Apache License 2.0 6 votes vote down vote up
private Path findMain() {
    final LocalRepositoryManager lrm = repositorySystemSession.getLocalRepositoryManager();
    final Artifact artifact = new DefaultArtifact(GAV.GROUP, "component-kitap", "fatjar", "jar", GAV.VERSION);
    final File location = new File(lrm.getRepository().getBasedir(), lrm.getPathForLocalArtifact(artifact));
    if (!location.exists()) {
        final ArtifactRequest artifactRequest =
                new ArtifactRequest().setArtifact(artifact).setRepositories(remoteRepositories);
        try {
            final ArtifactResult result =
                    repositorySystem.resolveArtifact(repositorySystemSession, artifactRequest);
            if (result.isMissing()) {
                throw new IllegalStateException("Can't find " + artifact);
            }
            return result.getArtifact().getFile().toPath();
        } catch (final ArtifactResolutionException e) {
            throw new IllegalStateException(e.getMessage(), e);
        }
    }
    return location.toPath();
}
 
Example 15
Source Project: google-cloud-eclipse   Source File: LibraryFactory.java    License: Apache License 2.0 6 votes vote down vote up
static Collection<LibraryFile> loadTransitiveDependencies(MavenCoordinates root)
    throws CoreException {
  Set<LibraryFile> dependencies = new HashSet<>();
  Collection<Artifact> artifacts = DependencyResolver.getTransitiveDependencies(
      root.getGroupId(), root.getArtifactId(), root.getVersion(), null);
  for (Artifact artifact : artifacts) {
    MavenCoordinates coordinates = new MavenCoordinates.Builder()
        .setGroupId(artifact.getGroupId())
        .setArtifactId(artifact.getArtifactId())
        .setVersion(artifact.getVersion())
        .build();
    LibraryFile file = new LibraryFile(coordinates);
    dependencies.add(file);
  }
  return dependencies;
}
 
Example 16
@Override
public File findArtifact(Artifact artifact) {
  MavenProject project = getProject(artifact);
  if (project != null) {
    if ("pom".equals(artifact.getExtension())) {
      return project.getFile();
    } else if ("jar".equals(artifact.getExtension()) && "".equals(artifact.getClassifier())) {
      return new File(project.getBuild().getOutputDirectory());
    }
  }
  Artifact _artifact = getArtifact(artifact);
  if (_artifact != null) {
    return _artifact.getFile();
  }
  return null;
}
 
Example 17
@Override
public void execute(ExecutionContext context) throws MojoExecutionException, MojoFailureException {
  this.log.info("Deploying the release artifacts into the distribution repository");

  try {
    Collection<Artifact> deployedArtifacts = this.deployer.deployArtifacts(this.metadata.getReleaseArtifacts());
    if (!deployedArtifacts.isEmpty()) {
      this.log.debug("\tDeployed the following release artifacts to the remote repository:");
      for (Artifact a : deployedArtifacts) {
        this.log.debug("\t\t" + a);
      }
    }
  } catch (DeploymentException e) {
    throw new MojoFailureException("Unable to deploy artifacts into remote repository.", e);
  }
}
 
Example 18
Source Project: vertx-stack   Source File: Actions.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Action to copy an artifact to a directory.
 *
 * @param artifact  the artifact
 * @param directory the directory
 * @return the created {@link Action}
 */
public static Action copy(Artifact artifact, File directory) {
  return () -> {
    Path source = artifact.getFile().toPath();
    Path output = directory.toPath().resolve(source.getFileName());
    LOGGER.info("Copying " + source.getFileName());
    try {
      Files.copy(source, output);
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
  };
}
 
Example 19
public Path getVersionJar(String version) throws ArtifactResolutionException {
	Artifact versionArtifact = new DefaultArtifact(groupId, artifactId, "jar", version.toString());
	
	ArtifactRequest request = new ArtifactRequest();
	request.setArtifact(versionArtifact);
	request.setRepositories(mavenPluginRepository.getRepositoriesAsList());
	ArtifactResult resolveArtifact = mavenPluginRepository.getSystem().resolveArtifact(mavenPluginRepository.getSession(), request);
	
	return resolveArtifact.getArtifact().getFile().toPath();
}
 
Example 20
private void getArtifact( Gav gav, String packagingOverride, String classifier )
{
    String packaging;
    if ( StringUtils.isNotEmpty( packagingOverride ) )
    {
      packaging = packagingOverride;
    }
    else
    {
      packaging = gav.getPackaging();
    }

    Artifact artifact = new DefaultArtifact( gav.getGroupId(), gav.getArtifactId(), classifier, packaging,
                                             gav.getVersion() );
    // avoid download if we got it locally already? or not bother and just get it again? 
    ArtifactRequest artifactRequest = new ArtifactRequest();
    artifactRequest.setArtifact( artifact );
    artifactRequest.addRepository( sourceRepository );

    try
    {
        ArtifactResult artifactResult = system.resolveArtifact( session, artifactRequest );
        logger.info( "Retrieved " + artifactResult.getArtifact().getFile() );

        successfulRetrievals.add( artifact.toString() );
    }
    catch ( ArtifactResolutionException e )
    {
        if ( MavenConstants.BUNDLE.equals( packaging ) )
        {
          logger.info( "Ignoring failure to retrieve " + gav + " with " + packaging + " and " + classifier );
        }
        logger.info( "ArtifactResolutionException when retrieving " + gav + " with " + classifier );
        failedRetrievals.add( e.getMessage() );
    }
}
 
Example 21
Source Project: revapi   Source File: ArtifactResolver.java    License: Apache License 2.0 5 votes vote down vote up
private Artifact resolveArtifact(Artifact artifact, RepositorySystemSession session) throws ArtifactResolutionException {
    ArtifactRequest request = new ArtifactRequest().setArtifact(artifact)
            .setRepositories(repositories);

    ArtifactResult result = repositorySystem.resolveArtifact(session, request);

    if (!result.isResolved() || result.isMissing()) {
        throw new ArtifactResolutionException(Collections.singletonList(result), "The artifact was not" +
                " resolved or is missing: '" + artifact.toString() + "'.");
    }

    return result.getArtifact();
}
 
Example 22
Source Project: cloud-opensource-java   Source File: SerializeGraph.java    License: Apache License 2.0 5 votes vote down vote up
private static String getVersionlessCoordinate( DependencyNode node )
{
    Artifact artifact = node.getArtifact();

    // scope not included because we check for scope conflicts separately
    return artifact.getGroupId() + ":" + artifact.getArtifactId() + ":" + artifact.getExtension();
}
 
Example 23
public GregorianCalendar getVersionDate(String version) throws ArtifactResolutionException, ParseException, IOException {
//		byte[] jarContent = getJarContent(version, "plugin/version.properties");
//		if (jarContent != null) {
//			Properties properties = new Properties();
//			properties.load(new ByteArrayInputStream(jarContent));
//			String buildDate = properties.getProperty("build.date");
//			DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
//			try {
//				Date parse = dateFormat.parse(buildDate);
//				GregorianCalendar gregorianCalendar = new GregorianCalendar();
//				gregorianCalendar.setTimeInMillis(parse.getTime());
//				return gregorianCalendar;
//			} catch (ParseException e) {
//				return null;
//			}
//		}
//		return null;

		Artifact versionArtifact = new DefaultArtifact(groupId, artifactId, "version", "properties", version.toString());
		
		ArtifactRequest request = new ArtifactRequest();
		request.setArtifact(versionArtifact);
		request.setRepositories(mavenPluginRepository.getRepositoriesAsList());
		ArtifactResult resolveArtifact = mavenPluginRepository.getSystem().resolveArtifact(mavenPluginRepository.getSession(), request);
		
		byte[] bytes = FileUtils.readFileToByteArray(resolveArtifact.getArtifact().getFile());
		
		Properties properties = new Properties();
		properties.load(new ByteArrayInputStream(bytes));
		String buildDate = properties.getProperty("build.date");
		DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
		try {
			Date parse = dateFormat.parse(buildDate);
			GregorianCalendar gregorianCalendar = new GregorianCalendar();
			gregorianCalendar.setTimeInMillis(parse.getTime());
			return gregorianCalendar;
		} catch (ParseException e) {
			return null;
		}
	}
 
Example 24
Source Project: quarkus   Source File: GenerateExtensionsJsonMojo.java    License: Apache License 2.0 5 votes vote down vote up
private JsonObject processDependency(Artifact artifact) throws IOException {
    JsonNode onode = processDependencyToObjectNode(artifact);

    if (onode != null) {
        // TODO: this is a dirty hack to avoid redoing existing javax.json code
        String json = getMapper(false).writeValueAsString(onode);
        try (JsonReader jsonReader = Json.createReader(new StringReader(json))) {
            return jsonReader.readObject();
        }
    } else {
        return null;
    }
}
 
Example 25
Source Project: vertx-stack   Source File: CacheTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testWithInvalidArtifact() throws IOException {
  String gacv = "org.acme:acme:jar:1.0";
  ResolutionOptions options = new ResolutionOptions();
  List<Artifact> list = cache.get(gacv, options);
  assertThat(list).isNull();

  Artifact artifact = new DefaultArtifact("org.acme:acme:jar:1.0").setFile(new File("does not exist.jar"));

  cache.put(gacv, options, Collections.singletonList(artifact));
  list = cache.get(gacv, options);
  assertThat(list).isNull();
}
 
Example 26
Source Project: Poseidon   Source File: Cadfael.java    License: 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 27
Source Project: buck   Source File: Pom.java    License: Apache License 2.0 5 votes vote down vote up
private void applyBuildRule() {
  if (!HasMavenCoordinates.isMavenCoordsPresent(publishable)) {
    throw new IllegalArgumentException(
        "Cannot retrieve maven coordinates for target"
            + publishable.getBuildTarget().getFullyQualifiedName());
  }
  DefaultArtifact artifact = new DefaultArtifact(getMavenCoords(publishable).get());

  Iterable<Artifact> deps =
      FluentIterable.from(publishable.getMavenDeps())
          .filter(HasMavenCoordinates::isMavenCoordsPresent)
          .transform(input -> new DefaultArtifact(input.getMavenCoords().get()));

  updateModel(artifact, deps);
}
 
Example 28
Source Project: furnace   Source File: ClasspathWorkspaceReader.java    License: Eclipse Public License 1.0 5 votes vote down vote up
private Artifact getFoundArtifact(final File pomFile)
{
   Artifact foundArtifact = foundArtifactCache.get(pomFile);
   if (foundArtifact == null)
   {
      foundArtifact = createFoundArtifact(pomFile);
      foundArtifactCache.put(pomFile, foundArtifact);
   }
   return foundArtifact;
}
 
Example 29
Source Project: pinpoint   Source File: PinpointPluginTestSuite.java    License: Apache License 2.0 5 votes vote down vote up
private List<PinpointPluginTestInstance> createSharedCasesWithDependencies(PinpointPluginTestContext context) throws ArtifactResolutionException, DependencyResolutionException {
    List<PinpointPluginTestInstance> cases = new ArrayList<PinpointPluginTestInstance>();

    DependencyResolver resolver = getDependencyResolver(this.repositories);

    Map<String, List<Artifact>> dependencyMap = resolver.resolveDependencySets(dependencies);

    SharedProcessManager sharedProcessManager = new SharedProcessManager(context);
    for (Map.Entry<String, List<Artifact>> artifactEntry : dependencyMap.entrySet()) {
        final String testKey = artifactEntry.getKey();
        final List<Artifact> artifacts = artifactEntry.getValue();

        List<String> libs = new ArrayList<String>();
        for (File lib : resolver.resolveArtifactsAndDependencies(artifacts)) {
            libs.add(lib.getAbsolutePath());
        }

        PinpointPluginTestInstance testInstance = null;
        if (testOnSystemClassLoader) {
            testInstance = new SharedProcessPluginTestCase(context, testKey, libs, true, sharedProcessManager);
        }

        if (testOnChildClassLoader) {
            testInstance = new SharedProcessPluginTestCase(context, testKey, libs, false, sharedProcessManager);
        }

        if (testInstance != null) {
            cases.add(testInstance);
            sharedProcessManager.registerTest(testInstance.getTestId(), artifacts);
        }
    }

    return cases;
}
 
Example 30
private Path resolve(Artifact artifact) {
    File file = artifact.getFile();
    if (file != null) {
        return file.toPath();
    }
    try {
        return resolver.resolve(artifact).getArtifact().getFile().toPath();
    } catch (AppModelResolverException e) {
        throw new DeploymentInjectionException(e);
    }
}