this.plugins = ImmutableList.copyOf(config.getPlugins()); this.resolver = new ArtifactResolver(config.getMavenLocalRepository(), config.getMavenRemoteRepository());
private URLClassLoader buildClassLoaderFromCoordinates(String coordinates) throws Exception { Artifact rootArtifact = new DefaultArtifact(coordinates); List<Artifact> artifacts = resolver.resolveArtifacts(rootArtifact); return createClassLoader(artifacts, rootArtifact.toString()); }
private URLClassLoader buildClassLoaderFromPom(File pomFile) throws Exception { List<Artifact> artifacts = resolver.resolvePom(pomFile); URLClassLoader classLoader = createClassLoader(artifacts, pomFile.getPath()); Artifact artifact = artifacts.get(0); Set<String> plugins = discoverPlugins(artifact, classLoader); if (!plugins.isEmpty()) { writePluginServices(plugins, artifact.getFile()); } return classLoader; }
ArtifactResolver artifactResolver = new ArtifactResolver(localRepo, remoteRepos); artifacts = artifactResolver.resolvePom(pomFile); artifacts = artifactResolver.resolveArtifacts(new DefaultArtifact(args[0]));
@Test public void testResolveArtifacts() throws Exception { ArtifactResolver artifactResolver = new ArtifactResolver(USER_LOCAL_REPO, MAVEN_CENTRAL_URI); List<Artifact> artifacts = artifactResolver.resolveArtifacts(ImmutableList.of(new DefaultArtifact("org.apache.maven:maven-core:3.0.4"))); Assert.assertNotNull(artifacts, "artifacts is null"); for (Artifact artifact : artifacts) { Assert.assertNotNull(artifact.getFile(), "Artifact " + artifact + " is not resolved"); } }
@Test public void testResolvePom() throws DependencyResolutionException { File pomFile = new File("src/test/poms/maven-core-3.0.4.pom"); Assert.assertTrue(pomFile.canRead()); ArtifactResolver artifactResolver = new ArtifactResolver(USER_LOCAL_REPO, MAVEN_CENTRAL_URI); List<Artifact> artifacts = artifactResolver.resolvePom(pomFile); Assert.assertNotNull(artifacts, "artifacts is null"); for (Artifact artifact : artifacts) { Assert.assertNotNull(artifact.getFile(), "Artifact " + artifact + " is not resolved"); } } }
PlexusContainer container = container(); org.apache.maven.repository.RepositorySystem lrs = container.lookup(org.apache.maven.repository.RepositorySystem.class); ProjectBuilder projectBuilder = container.lookup(ProjectBuilder.class); ProjectBuildingRequest request = new DefaultProjectBuildingRequest(); request.setSystemProperties(requiredSystemProperties()); request.setRepositorySession(repositorySystemSession); request.setProcessPlugins(false); collectRequest.addDependency(toAetherDependency(dependency)); collectRequest.addManagedDependency(toAetherDependency(managedDependency)); List<Artifact> artifacts = resolveArtifacts(dependencyRequest); return ImmutableList.<Artifact>builder().add(rootArtifact).addAll(artifacts).build();
public List<Artifact> resolveArtifacts(Artifact... sourceArtifacts) { return resolveArtifacts(Arrays.asList(sourceArtifacts)); }
private URLClassLoader buildClassLoaderFromPom(File pomFile) throws Exception { List<Artifact> artifacts = resolver.resolvePom(pomFile); URLClassLoader classLoader = createClassLoader(artifacts, pomFile.getPath()); Artifact artifact = artifacts.get(0); Set<String> plugins = discoverPlugins(artifact, classLoader); if (!plugins.isEmpty()) { writePluginServices(plugins, artifact.getFile()); } return classLoader; }
this.plugins = ImmutableList.copyOf(config.getPlugins()); this.resolver = new ArtifactResolver(config.getMavenLocalRepository(), config.getMavenRemoteRepository());
private URLClassLoader buildClassLoaderFromCoordinates(String coordinates) throws Exception { Artifact rootArtifact = new DefaultArtifact(coordinates); List<Artifact> artifacts = resolver.resolveArtifacts(rootArtifact); return createClassLoader(artifacts, rootArtifact.toString()); }
private URLClassLoader buildClassLoaderFromPom(File pomFile) throws Exception { List<Artifact> artifacts = resolver.resolvePom(pomFile); URLClassLoader classLoader = createClassLoader(artifacts, pomFile.getPath()); Artifact artifact = artifacts.get(0); Set<String> plugins = discoverPlugins(artifact, classLoader); if (!plugins.isEmpty()) { writePluginServices(plugins, artifact.getFile()); } return classLoader; }
this.plugins = ImmutableList.copyOf(config.getPlugins()); this.resolver = new ArtifactResolver(config.getMavenLocalRepository(), config.getMavenRemoteRepository());
private URLClassLoader buildClassLoaderFromCoordinates(String coordinates) throws Exception { Artifact rootArtifact = new DefaultArtifact(coordinates); List<Artifact> artifacts = resolver.resolveArtifacts(rootArtifact); return createClassLoader(artifacts, rootArtifact.toString()); }
private URLClassLoader buildClassLoaderFromPom(File pomFile) throws Exception { List<Artifact> artifacts = resolver.resolvePom(pomFile); URLClassLoader classLoader = createClassLoader(artifacts, pomFile.getPath()); Artifact artifact = artifacts.get(0); Set<String> plugins = discoverPlugins(artifact, classLoader); if (!plugins.isEmpty()) { writePluginServices(plugins, artifact.getFile()); } return classLoader; }
this.plugins = ImmutableList.copyOf(config.getPlugins()); this.resolver = new ArtifactResolver(config.getMavenLocalRepository(), config.getMavenRemoteRepository());
private URLClassLoader buildClassLoaderFromCoordinates(String coordinates) throws Exception { Artifact rootArtifact = new DefaultArtifact(coordinates); List<Artifact> artifacts = resolver.resolveArtifacts(rootArtifact); return createClassLoader(artifacts, rootArtifact.toString()); }
public List<Artifact> resolveArtifacts(Iterable<? extends Artifact> sourceArtifacts) { CollectRequest collectRequest = new CollectRequest(); for (Artifact sourceArtifact : sourceArtifacts) { collectRequest.addDependency(new Dependency(sourceArtifact, JavaScopes.RUNTIME)); } for (RemoteRepository repository : repositories) { collectRequest.addRepository(repository); } DependencyRequest dependencyRequest = new DependencyRequest(collectRequest, DependencyFilterUtils.classpathFilter(JavaScopes.RUNTIME)); return resolveArtifacts(dependencyRequest); }