/** * Parses dependency parameter and build {@link Dependency} object. * * @param dependency string representation of dependency parameter * @return Dependency object */ public static Dependency parseDependency(String dependency) { List<String> dependencyAndExclusions = Arrays.asList(dependency.split("\\^")); Collection<Exclusion> exclusions = new ArrayList<>(); for (int idx = 1 ; idx < dependencyAndExclusions.size() ; idx++) { exclusions.add(AetherUtils.createExclusion(dependencyAndExclusions.get(idx))); } Artifact artifact = new DefaultArtifact(dependencyAndExclusions.get(0)); return new Dependency(artifact, JavaScopes.COMPILE, false, exclusions); }
public static Dependency toDependency( org.apache.maven.artifact.Artifact artifact, Collection<org.apache.maven.model.Exclusion> exclusions ) { if ( artifact == null ) { return null; } Artifact result = toArtifact( artifact ); List<Exclusion> excl = null; if ( exclusions != null ) { excl = new ArrayList<>( exclusions.size() ); for ( org.apache.maven.model.Exclusion exclusion : exclusions ) { excl.add( toExclusion( exclusion ) ); } } return new Dependency( result, artifact.getScope(), artifact.isOptional(), excl ); }
public DependencyNode transformGraph( DependencyNode node, DependencyGraphTransformationContext context ) throws RepositoryException { if ( findPlexusUtils( node ) == null ) { Artifact pu = new DefaultArtifact( GID, AID, null, EXT, VER ); DefaultDependencyNode child = new DefaultDependencyNode( new Dependency( pu, JavaScopes.RUNTIME ) ); child.setRepositories( node.getRepositories() ); child.setRequestContext( node.getRequestContext() ); node.getChildren().add( child ); } return node; }
private Dependency convert( org.apache.maven.model.Dependency dependency, ArtifactTypeRegistry stereotypes ) { ArtifactType stereotype = stereotypes.get( dependency.getType() ); if ( stereotype == null ) { stereotype = new DefaultArtifactType( dependency.getType() ); } boolean system = dependency.getSystemPath() != null && dependency.getSystemPath().length() > 0; Map<String, String> props = null; if ( system ) { props = Collections.singletonMap( ArtifactProperties.LOCAL_PATH, dependency.getSystemPath() ); } Artifact artifact = new DefaultArtifact( dependency.getGroupId(), dependency.getArtifactId(), dependency.getClassifier(), null, dependency.getVersion(), props, stereotype ); List<Exclusion> exclusions = new ArrayList<>( dependency.getExclusions().size() ); for ( org.apache.maven.model.Exclusion exclusion : dependency.getExclusions() ) { exclusions.add( convert( exclusion ) ); } Dependency result = new Dependency( artifact, dependency.getScope(), dependency.getOptional() != null ? dependency.isOptional() : null, exclusions ); return result; }
public static Dependency toDependency( org.apache.maven.model.Dependency dependency, ArtifactTypeRegistry stereotypes ) { ArtifactType stereotype = stereotypes.get( dependency.getType() ); if ( stereotype == null ) { stereotype = new DefaultArtifactType( dependency.getType() ); } boolean system = dependency.getSystemPath() != null && dependency.getSystemPath().length() > 0; Map<String, String> props = null; if ( system ) { props = Collections.singletonMap( ArtifactProperties.LOCAL_PATH, dependency.getSystemPath() ); } Artifact artifact = new DefaultArtifact( dependency.getGroupId(), dependency.getArtifactId(), dependency.getClassifier(), null, dependency.getVersion(), props, stereotype ); List<Exclusion> exclusions = new ArrayList<>( dependency.getExclusions().size() ); for ( org.apache.maven.model.Exclusion exclusion : dependency.getExclusions() ) { exclusions.add( toExclusion( exclusion ) ); } Dependency result = new Dependency( artifact, dependency.getScope(), dependency.getOptional() != null ? dependency.isOptional() : null, exclusions ); return result; }
collectRequest.setRoot(new Dependency(versionedArtifact, JavaScopes.RUNTIME)); final DependencyRequest dependencyRequest = new DependencyRequest( collectRequest,
/** * Given a set of maven coordinates, returns a set of jars which include all * of the specified coordinates and optionally their transitive dependencies. */ public Set<File> resolve(boolean withTransitives, Collection<String> mavenCoordinates) { Collection<Exclusion> excludeTransitive = new ArrayList<Exclusion>(1); if (!withTransitives) { excludeTransitive.add(EXCLUDE_ALL_TRANSITIVES); } List<Dependency> dependencies = mavenCoordinates.stream() .map(coordinateString -> new DefaultArtifact(coordinateString)) .map(artifact -> new Dependency(artifact, null, null, excludeTransitive)) .collect(toList()); CollectRequest collectRequest = new CollectRequest(dependencies, null, repositories); DependencyRequest dependencyRequest = new DependencyRequest(collectRequest, null); DependencyResult dependencyResult = resolveDependencies(dependencyRequest); return dependencyResult.getArtifactResults() .stream() .peek(this::logResolved) .map(ArtifactResult::getArtifact) .map(Artifact::getFile) .collect(toSet()); }
request.setRequestContext( REPOSITORY_CONTEXT ); request.setRepositories( repositories ); request.setRoot( new org.eclipse.aether.graph.Dependency( pluginArtifact, null ) ); for ( Dependency dependency : plugin.getDependencies() )
final DefaultArtifact artifact = new DefaultArtifact(groupId, artifactId, JAR_EXTENSION, rootArtifact.getVersion()); logger.debug("'{}' artifact coordinates resolved to: '{}'", artifactCoords, artifact); return of(new Dependency(artifact, COMPILE));
.add(new Dependency(new DefaultArtifact(RUNTIME_GROUP_ID, LOGGING_ARTIFACT_ID, JAR_EXTENSION, muleVersion), COMPILE));
+ MULE_PLUGIN_CLASSIFIER + ":*"), new PatternInclusionsDependencyFilter(toId(artifactToClassify)))); urls = toUrl(dependencyResolver.resolveDependencies(new Dependency(artifactToClassify, COMPILE), emptyList(), emptyList(), dependencyFilter, rootArtifactRemoteRepositories));
TEST, directDependencies, managedDependencies); final Dependency rootTestDependency = new Dependency(new DefaultArtifact(rootArtifact.getGroupId(), rootArtifact.getArtifactId(), TESTS_CLASSIFIER, JAR_EXTENSION,
collectRequest.setRoot(new Dependency(artifact, "compile")); for (RemoteRepository remoteRepo : remoteRepositories) { collectRequest.addRepository(remoteRepo);
continue; Dependency dependency2 = new Dependency(new DefaultArtifact(depend.getGroupId() + ":" + depend.getArtifactId() + ":jar:" + depend.getVersion()), "compile"); DelegatingClassLoader depDelLoader = new DelegatingClassLoader(previous);
private List<Dependency> getDependencies(DependencyResult dependencyResult) { List<Dependency> dependencies = new ArrayList<>(); for (ArtifactResult artifactResult : dependencyResult.getArtifactResults()) { dependencies.add( new Dependency(artifactResult.getArtifact(), JavaScopes.COMPILE)); } return dependencies; }
public TestVersionFilterContext( RepositorySystemSession session, VersionRangeResult result ) { this.session = session; this.result = result; dependency = new Dependency( result.getRequest().getArtifact(), "" ); versions = new ArrayList<Version>( result.getVersions() ); }
private Dependency toAetherDependency(org.apache.maven.model.Dependency dependency) { Artifact artifact = new DefaultArtifact(dependency.getGroupId(), dependency.getArtifactId(), dependency.getClassifier(), dependency.getType(), dependency.getVersion()); ImmutableList.Builder<Exclusion> exclusions = ImmutableList.builder(); for (org.apache.maven.model.Exclusion exclusion : dependency.getExclusions()) { exclusions.add(new Exclusion(exclusion.getGroupId(), exclusion.getArtifactId(), null, "*")); } return new Dependency(artifact, dependency.getScope(), dependency.isOptional(), exclusions.build()); }
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); } }
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(); }
@Override public CollectorResult collectDependencies( ProjectBuildingRequest buildingRequest, DependableCoordinate root ) throws DependencyCollectorException { ArtifactHandler artifactHandler = artifactHandlerManager.getArtifactHandler( root.getType() ); String extension = artifactHandler != null ? artifactHandler.getExtension() : null; Artifact aetherArtifact = new DefaultArtifact( root.getGroupId(), root.getArtifactId(), root.getClassifier(), extension, root.getVersion() ); CollectRequest request = new CollectRequest(); request.setRoot( new Dependency( aetherArtifact, null ) ); return collectDependencies( buildingRequest, request ); }