pluginSession.setDependencyGraphTransformer( transformer ); CollectRequest request = new CollectRequest(); request.setRequestContext( REPOSITORY_CONTEXT ); request.setRepositories( repositories ); request.setRoot( new org.eclipse.aether.graph.Dependency( pluginArtifact, null ) ); for ( Dependency dependency : plugin.getDependencies() ) if ( !JavaScopes.SYSTEM.equals( pluginDep.getScope() ) ) pluginDep = pluginDep.setScope( JavaScopes.RUNTIME ); request.addDependency( pluginDep ); DependencyRequest depRequest = new DependencyRequest( request, resolutionFilter ); depRequest.setTrace( trace ); request.setTrace( RequestTrace.newChild( trace, depRequest ) ); node = repoSystem.collectDependencies( pluginSession, request ).getRoot(); node.accept( new GraphLogger() ); depRequest.setRoot( node ); repoSystem.resolveDependencies( session, depRequest );
Collection<Exclusion> exclusions = dependency != null ? dependency.getExclusions() : null; org.eclipse.aether.graph.Dependency dep = RepositoryUtils.toDependency( artifact, exclusions ); if ( !JavaScopes.SYSTEM.equals( dep.getScope() ) && dep.getArtifact().getFile() != null ) org.eclipse.aether.artifact.Artifact art = dep.getArtifact(); art = art.setFile( null ).setVersion( art.getBaseVersion() ); dep = dep.setArtifact( art ); collect.addDependency( dep ); DependencyRequest depRequest = new DependencyRequest( collect, filter ); depRequest.setTrace( trace ); collect.setTrace( RequestTrace.newChild( trace, depRequest ) ); node = repoSystem.collectDependencies( session, collect ).getRoot(); result.setDependencyGraph( node ); depRequest.setRoot( node ); for ( DependencyNode child : node.getChildren() ) if ( !child.getRelocations().isEmpty() ) logger.warn( "The artifact " + child.getRelocations().get( 0 ) + " has been relocated to " + child.getDependency().getArtifact() ); process( result, repoSystem.resolveDependencies( session, depRequest ).getArtifactResults() );
private static org.apache.maven.artifact.Artifact toArtifact( Dependency dependency ) { if ( dependency == null ) { return null; } org.apache.maven.artifact.Artifact result = toArtifact( dependency.getArtifact() ); result.setScope( dependency.getScope() ); result.setOptional( dependency.isOptional() ); return result; }
public boolean visitEnter( DependencyNode node ) { StringBuilder buffer = new StringBuilder( 128 ); buffer.append( indent ); org.eclipse.aether.graph.Dependency dep = node.getDependency(); if ( dep != null ) { Artifact art = dep.getArtifact(); buffer.append( art ); buffer.append( ':' ).append( dep.getScope() ); } logger.debug( buffer.toString() ); indent += " "; return true; }
org.eclipse.aether.graph.Dependency dep = node.getDependency(); if ( dep != null ) org.eclipse.aether.artifact.Artifact art = dep.getArtifact(); buffer.append( ':' ).append( dep.getScope() ); if ( ( node.getManagedBits() & DependencyNode.MANAGED_SCOPE ) == DependencyNode.MANAGED_SCOPE ) if ( ( node.getManagedBits() & DependencyNode.MANAGED_VERSION ) == DependencyNode.MANAGED_VERSION ) if ( dep.isOptional() )
private static DependencyRequest buildDependencyRequest(List<RemoteRepository> repositories, String identifier, String scope) { Artifact artifact = new DefaultArtifact(identifier); DependencyFilter classpathFlter = DependencyFilterUtils.classpathFilter(scope); CollectRequest collectRequest = new CollectRequest(); collectRequest.setRoot(new Dependency(artifact, scope)); collectRequest.setRepositories(repositories); return new DependencyRequest(collectRequest, classpathFlter); } }
continue; Dependency dependency2 = new Dependency(new DefaultArtifact(depend.getGroupId() + ":" + depend.getArtifactId() + ":jar:" + depend.getVersion()), "compile"); DelegatingClassLoader depDelLoader = new DelegatingClassLoader(previous); if (!dependency2.getArtifact().isSnapshot()) { if (dependency2.getArtifact().getFile() != null) { bimServerDependencies.add(new org.bimserver.plugins.Dependency(dependency2.getArtifact().getFile().toPath())); loadDependencies(dependency2.getArtifact().getFile().toPath(), depDelLoader); } else { ArtifactRequest request = new ArtifactRequest(); request.setArtifact(dependency2.getArtifact()); request.setRepositories(mavenPluginRepository.getRepositories()); try { ArtifactResult resolveArtifact = mavenPluginRepository.getSystem().resolveArtifact(mavenPluginRepository.getSession(), request); if ((!"test".equals(dependency2.getScope()) && !dependency2.getArtifact().isSnapshot())) { request.setArtifact(dependency2.getArtifact()); request.setRepositories(mavenPluginRepository.getLocalRepositories()); try { ArtifactResult resolveArtifact = mavenPluginRepository.getSystem().resolveArtifact(mavenPluginRepository.getSession(), request); LOGGER.info(dependency2.getArtifact().toString()); e.printStackTrace(); descriptorRequest.setArtifact(dependency2.getArtifact()); descriptorRequest.setRepositories(mavenPluginRepository.getRepositories()); ArtifactDescriptorResult descriptorResult = mavenPluginRepository.getSystem().readArtifactDescriptor(mavenPluginRepository.getSession(), descriptorRequest);
private Artifact getDependencyArtifact( Dependency dep ) { org.eclipse.aether.artifact.Artifact artifact = dep.getArtifact(); return factory.createDependencyArtifact( artifact.getGroupId(), artifact.getArtifactId(), VersionRange.createFromVersion( artifact.getVersion() ), artifact.getProperty( "type", artifact.getExtension() ), artifact.getClassifier(), dep.getScope(), dep.isOptional() ); }
private PreorderNodeListGenerator resolveInternal(String spec) throws DependencyCollectionException, DependencyResolutionException { Dependency dependency = new Dependency(new DefaultArtifact(spec), "compile"); CollectRequest collectRequest = new CollectRequest(); collectRequest.setRoot(dependency); for (RemoteRepository remote : remoteRepositories) { collectRequest.addRepository(remote); } DependencyNode node = repositorySystem.collectDependencies(session, collectRequest).getRoot(); DependencyRequest dependencyRequest = new DependencyRequest(); dependencyRequest.setRoot( node ); repositorySystem.resolveDependencies(session, dependencyRequest); PreorderNodeListGenerator nlg = new PreorderNodeListGenerator(); node.accept(nlg); return nlg; }
private MavenPluginVersion createMavenVersion(Version version) throws ArtifactDescriptorException, FileNotFoundException, IOException, ArtifactResolutionException, XmlPullParserException { ArtifactDescriptorRequest descriptorRequest = new ArtifactDescriptorRequest(); Artifact versionArtifact = new DefaultArtifact(groupId, artifactId, "pom", version.toString()); descriptorResult = mavenPluginRepository.getSystem().readArtifactDescriptor(mavenPluginRepository.getSession(), descriptorRequest); ArtifactRequest request = new ArtifactRequest(); request.setArtifact(descriptorResult.getArtifact()); request.setRepositories(mavenPluginRepository.getRepositories()); ArtifactResult resolveArtifact = mavenPluginRepository.getSystem().resolveArtifact(mavenPluginRepository.getSession(), request); File pomFile = resolveArtifact.getArtifact().getFile(); MavenXpp3Reader mavenreader = new MavenXpp3Reader(); DefaultArtifactVersion artifactVersion = new DefaultArtifactVersion(dependency.getArtifact().getVersion()); mavenPluginVersion.addDependency(new MavenDependency(dependency.getArtifact(), artifactVersion));
session.setLocalRepositoryManager(system.newLocalRepositoryManager(session, localRepo)); if (parent.getDependency().isOptional()) { return false; return !dependencyNode.getDependency().isOptional(); }, ex.addAll(parent.getDependency().getExclusions()); if (e.getArtifactId().equals(dependencyNode.getArtifact().getArtifactId()) && e.getGroupId().equals(dependencyNode.getArtifact().getGroupId())) { return false; if (e.getArtifactId().equals(parent.getArtifact().getArtifactId()) && e.getGroupId().equals(parent.getArtifact().getGroupId())) { return false; if (!parent.getDependency().getScope().toLowerCase().equals("compile")) { return false; return dependencyNode.getDependency().getScope().toLowerCase().equals("compile"); CollectRequest collectRequest = new CollectRequest(); collectRequest.setRoot(new Dependency(new DefaultArtifact(root), JavaScopes.COMPILE)); collectRequest.addDependency(new Dependency(new DefaultArtifact(artifact), JavaScopes.COMPILE));
private void installDependency(String groupId, String artifactId, String version, RepositorySystemSession session) throws DependencyResolutionException{ logger.info("Installing and Loading Dependency : {} - {} - {} ", groupId , artifactId, version); Dependency dependency = new Dependency( new DefaultArtifact(groupId, artifactId, "", "jar", version ), "compile" ); RemoteRepository central = new RemoteRepository.Builder( "central", "default", "http://central.maven.org/maven2/" ).build(); CollectRequest collectRequest = new CollectRequest(); collectRequest.setRoot( dependency ); collectRequest.addRepository( central ); DependencyRequest dependencyRequest = new DependencyRequest(); dependencyRequest.setCollectRequest( collectRequest ); system.resolveDependencies(session, dependencyRequest ).getRoot(); }
@SuppressWarnings("unchecked") public MavenDependencyAdapter(final org.eclipse.aether.graph.Dependency dep) { if (dep == null) { throw new IllegalArgumentException("Dependency must not be null."); } this.setArtifactId(dep.getArtifact().getArtifactId()); this.setGroupId(dep.getArtifact().getGroupId()); this.setClassifier("".equals(dep.getArtifact().getClassifier()) ? null : dep.getArtifact().getClassifier()); this.setExclusions(dep.getExclusions()); if (dep.isOptional()) { this.setOptional(dep.isOptional()); } this.setScope(dep.getScope()); this.setType(dep.getArtifact().getExtension()); this.setVersion(dep.getArtifact().getBaseVersion()); this.artifact = RESOURCE_FACTORY.create(FileResource.class, dep.getArtifact().getFile()); }
versionScheme.parseVersion(artifact.getVersion()); } catch (InvalidVersionSpecificationException e) { throw new IllegalArgumentException(e); versionScheme.parseVersionRange(artifact.getVersion()); throw new IllegalArgumentException(artifact.getVersion() + " is a version range. A specific version is needed"); } catch (InvalidVersionSpecificationException expected) { artifactResult = REPOSITORY_SYSTEM.resolveArtifact(session, artifactRequest); } catch (ArtifactResolutionException e) { throw new RuntimeException(e); urls.add(artifactResult.getArtifact().getFile()); CollectRequest collectRequest = new CollectRequest(); collectRequest.setRoot(new Dependency(artifact, "compile")); for (RemoteRepository remoteRepo : remoteRepositories) { collectRequest.addRepository(remoteRepo); DependencyNode node = REPOSITORY_SYSTEM.collectDependencies(session, collectRequest).getRoot(); DependencyFilter filter = new ExclusionsDependencyFilter(Arrays.asList(excludes)); DependencyRequest dependencyRequest = new DependencyRequest(node, filter); REPOSITORY_SYSTEM.resolveDependencies(session, dependencyRequest); node.accept(nlg); for (Artifact cur : nlg.getArtifacts(false)) { urls.add(cur.getFile());
public boolean accept( DependencyNode node, List<DependencyNode> parents ) { Dependency dependency = node.getDependency(); if ( dependency != null ) { org.eclipse.aether.artifact.Artifact a = dependency.getArtifact(); String key = ArtifactUtils.key( a.getGroupId(), a.getArtifactId(), a.getVersion() ); return !keys.contains( key ); } return false; }
CollectRequest collectRequest = new CollectRequest(); collectRequest.setRoot(rootDependency); collectRequest.setRepositories(repositoryList); DependencyFilterUtils.andFilter(DependencyFilterUtils.classpathFilter(DEPENDENCIES_DEFAULT_SEARCH_SCOPE), (DependencyNode dependencyNode, List<DependencyNode> arg1) -> { Artifact artifact = dependencyNode.getArtifact(); if (dependencyNode.getDependency().isOptional()) { getLog().debug("Filtering dependency "+dependencyNode.getDependency()); return false; if (currentExclusion.getGroupId().equals(artifact.getGroupId()) && (currentExclusion.getArtifactId().equals(artifact.getArtifactId())) DependencyRequest dependencyRequest = new DependencyRequest(collectRequest, dependencyFilter); getLog().debug("Root dependency name: " + rootDependency.toString()); if ((dependencyRequest.getCollectRequest() != null) && (dependencyRequest.getCollectRequest().getTrace() != null)){ getLog().debug("Root dependency exclusions: " + rootDependency.getExclusions()); getLog().debug(LINE_SEPARATOR); dependencyNode.getArtifact().getGroupId(), if ((downloadOptionalDependencies || !dependencyNode.getDependency().isOptional()) && ! containsEx(parsedExcludedArtifacts, dummyExclusion) && !((rootDependency.getExclusions() != null) && (containsEx(rootDependency.getExclusions(), dummyExclusion)) ) ) { Artifact returnedArtifact = repositorySystem.resolveArtifact(repositorySystemSession,
if (toTransform.getScope().equals(TEST) && !MULE_PLUGIN_CLASSIFIER.equals(toTransform.getArtifact().getClassifier())) { if (TESTS_CLASSIFIER.equals(toTransform.getArtifact().getClassifier())) { return toTransform.setScope(COMPILE).setExclusions(singleton(new Exclusion("*", "*", "*", "*"))); } else { return toTransform.setScope(COMPILE); || MULE_PLUGIN_CLASSIFIER.equals(toTransform.getArtifact().getClassifier()) || MULE_SERVICE_CLASSIFIER.equals(toTransform.getArtifact().getClassifier())) && toTransform.getScope().equals(COMPILE)) { return toTransform.setScope(PROVIDED); if (rootArtifactType == MODULE && toTransform.getScope().equals(COMPILE)) { return toTransform.setScope(PROVIDED); Artifact artifact = toTransform.getArtifact(); if (context.getApplicationSharedLibCoordinates().contains(artifact.getGroupId() + ":" + artifact.getArtifactId())) { return toTransform.setScope(COMPILE); newArrayList(dependencyResolver.readArtifactDescriptor(rootArtifact).getManagedDependencies()); managedDependencies.addAll(directDependencies.stream() .filter(directDependency -> !directDependency.getScope().equals(TEST)) .collect(toList())); logger.debug("Resolving dependency graph for '{}' scope direct dependencies: {} and managed dependencies {}", TEST, directDependencies, managedDependencies); final Dependency rootTestDependency = new Dependency(new DefaultArtifact(rootArtifact.getGroupId(), rootArtifact.getArtifactId(), TESTS_CLASSIFIER, JAR_EXTENSION,
public static CollectRequest getCollectRequest(MavenProject project, List<RemoteRepository> repos, String scope){ Artifact a = new DefaultArtifact( project.getArtifact().toString() ); DefaultArtifact pom = new DefaultArtifact( a.getGroupId(), a.getArtifactId(), "pom", a.getVersion() ); CollectRequest collectRequest = new CollectRequest(); collectRequest.setRoot(new Dependency(pom, scope )); collectRequest.setRepositories(repos); return collectRequest; }
private DependencyNode findPlexusUtils( DependencyNode node ) { Artifact artifact = node.getDependency().getArtifact(); if ( AID.equals( artifact.getArtifactId() ) && GID.equals( artifact.getGroupId() ) && EXT.equals( artifact.getExtension() ) && "".equals( artifact.getClassifier() ) ) { return node; } for ( DependencyNode child : node.getChildren() ) { DependencyNode result = findPlexusUtils( child ); if ( result != null ) { return result; } } return null; }
final CollectRequest collectRequest = new CollectRequest(); collectRequest.setRoot(new Dependency(versionedArtifact, JavaScopes.RUNTIME)); final DependencyRequest dependencyRequest = new DependencyRequest( collectRequest, DependencyFilterUtils.andFilter( if (!exclusions.contains(artifact.getGroupId())) { log.info("Adding file [%s] at [%s]", artifact.getFile().getName(), toLocation.getAbsolutePath()); FileUtils.copyFileToDirectory(artifact.getFile(), toLocation); } else { log.debug("Skipped Artifact[%s]", artifact);