org.apache.maven.artifact.resolver.filter.ArtifactFilter Java Examples
The following examples show how to use
org.apache.maven.artifact.resolver.filter.ArtifactFilter.
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: ShrinkWrapFatJarPackageService.java From vertx-maven-plugin with Apache License 2.0 | 6 votes |
private void addDependencies(PackageConfig config, Collection<DependencySet> dependencies, JavaArchive jar) { Log logger = config.getMojo().getLog(); for (DependencySet ds : dependencies) { ScopeFilter scopeFilter = ServiceUtils.newScopeFilter(ds.getScope()); ArtifactFilter filter = new ArtifactIncludeFilterTransformer().transform(scopeFilter); Set<Artifact> artifacts = ServiceUtils.filterArtifacts(config.getArtifacts(), ds.getIncludes(), ds.getExcludes(), ds.isUseTransitiveDependencies(), logger, filter); for (Artifact artifact : artifacts) { File file = artifact.getFile(); if (file.isFile()) { logger.debug("Adding Dependency :" + artifact); embedDependency(logger, ds, jar, file); } else { logger.warn("Cannot embed artifact " + artifact + " - the file does not exist"); } } } }
Example #2
Source File: AbstractGraphMojo.java From depgraph-maven-plugin with Apache License 2.0 | 6 votes |
private ArtifactFilter createScopesArtifactFilter(List<String> scopes) { ScopeArtifactFilter filter = new ScopeArtifactFilter(); for (String scope : scopes) { if (SCOPE_COMPILE.equals(scope)) { filter.setIncludeCompileScope(true); } else if (SCOPE_RUNTIME.equals(scope)) { filter.setIncludeRuntimeScope(true); } else if (SCOPE_TEST.equals(scope)) { filter.setIncludeTestScope(true); } else if (SCOPE_PROVIDED.equals(scope)) { filter.setIncludeProvidedScope(true); } else if (SCOPE_SYSTEM.equals(scope)) { filter.setIncludeSystemScope(true); } else { getLog().warn("Unknown scope: " + scope); } } return filter; }
Example #3
Source File: DependencyGraphByGroupIdMojo.java From depgraph-maven-plugin with Apache License 2.0 | 6 votes |
@Override protected GraphFactory createGraphFactory(ArtifactFilter globalFilter, ArtifactFilter transitiveIncludeExcludeFilter, ArtifactFilter targetFilter, GraphStyleConfigurer graphStyleConfigurer) { GraphBuilder<DependencyNode> graphBuilder = graphStyleConfigurer .showGroupIds(true) .showArtifactIds(false) .showTypes(false) .showClassifiers(false) .showVersionsOnNodes(false) .showVersionsOnEdges(false) .showOptional(false) .configure(GraphBuilder.create(DependencyNodeIdRenderer.groupId().withScope(true))) .omitSelfReferences(); MavenGraphAdapter adapter = new MavenGraphAdapter(this.dependenciesResolver, transitiveIncludeExcludeFilter, targetFilter, EnumSet.of(INCLUDED)); return new SimpleGraphFactory(adapter, globalFilter, graphBuilder); }
Example #4
Source File: AggregatingDependencyGraphByGroupIdMojo.java From depgraph-maven-plugin with Apache License 2.0 | 6 votes |
@Override protected GraphFactory createGraphFactory(ArtifactFilter globalFilter, ArtifactFilter transitiveIncludeExcludeFilter, ArtifactFilter targetFilter, GraphStyleConfigurer graphStyleConfigurer) { DependencyNodeIdRenderer nodeIdRenderer = DependencyNodeIdRenderer .groupId() .withScope(!this.mergeScopes); GraphBuilder<DependencyNode> graphBuilder = graphStyleConfigurer .showGroupIds(true) .showArtifactIds(false) .showTypes(false) .showClassifiers(false) .showVersionsOnNodes(false) .showVersionsOnEdges(false) .showOptional(false) .repeatTransitiveDependencies(this.repeatTransitiveDependenciesInTextGraph) .configure(GraphBuilder.create(nodeIdRenderer)) .omitSelfReferences(); MavenGraphAdapter adapter = new MavenGraphAdapter(this.dependenciesResolver, transitiveIncludeExcludeFilter, targetFilter, EnumSet.of(INCLUDED)); return new AggregatingGraphFactory(adapter, subProjectsInReactorOrder(), globalFilter, graphBuilder, true, this.reduceEdges); }
Example #5
Source File: GraphBuildingVisitorTest.java From depgraph-maven-plugin with Apache License 2.0 | 6 votes |
@BeforeEach void before() { this.graphBuilder = GraphBuilder.create(ToStringNodeIdRenderer.INSTANCE); this.globalFilter = mock(ArtifactFilter.class); when(this.globalFilter.include(any())).thenReturn(true); this.transitiveFilter = mock(ArtifactFilter.class); when(this.transitiveFilter.include(any())).thenReturn(true); // this is the same as an empty list of target dependencies this.targetFilter = mock(ArtifactFilter.class); when(this.targetFilter.include(any())).thenReturn(true); this.includedResolutions = allOf(NodeResolution.class); }
Example #6
Source File: AbstractJnlpMojo.java From webstart with MIT License | 6 votes |
/** * Iterate through all the extensions dependencies declared in the project and * collect all the runtime scope dependencies for inclusion in the .zip and just * copy them to the lib directory. * <p> * TODO, should check that all dependencies are well signed with the same * extension with the same signer. * * @throws MojoExecutionException TODO */ private void processExtensionsDependencies() throws MojoExecutionException { Collection<Artifact> artifacts = isExcludeTransitive() ? getProject().getDependencyArtifacts() : getProject().getArtifacts(); for ( JnlpExtension extension : jnlpExtensions ) { ArtifactFilter filter = new IncludesArtifactFilter( extension.getIncludes() ); for ( Artifact artifact : artifacts ) { if ( filter.include( artifact ) ) { processExtensionDependency( extension, artifact ); } } } }
Example #7
Source File: AbstractJnlpMojo.java From webstart with MIT License | 6 votes |
/** * @param pattern pattern to test over artifacts * @param artifacts collection of artifacts to check * @return true if filter matches no artifact, false otherwise * */ private boolean ensurePatternMatchesAtLeastOneArtifact( String pattern, Collection<Artifact> artifacts ) { List<String> onePatternList = new ArrayList<>(); onePatternList.add( pattern ); ArtifactFilter filter = new IncludesArtifactFilter( onePatternList ); boolean noMatch = true; for ( Artifact artifact : artifacts ) { getLog().debug( "checking pattern: " + pattern + " against " + artifact ); if ( filter.include( artifact ) ) { noMatch = false; break; } } if ( noMatch ) { getLog().error( "pattern: " + pattern + " doesn't match any artifact." ); } return noMatch; }
Example #8
Source File: AggregatingGraphFactoryTest.java From depgraph-maven-plugin with Apache License 2.0 | 6 votes |
@BeforeEach void before() throws Exception { this.globalFilter = mock(ArtifactFilter.class); ArtifactFilter transitiveIncludeExcludeFilter = mock(ArtifactFilter.class); ArtifactFilter targetFilter = mock(ArtifactFilter.class); when(this.globalFilter.include(any())).thenReturn(true); when(transitiveIncludeExcludeFilter.include(any())).thenReturn(true); when(targetFilter.include(any())).thenReturn(true); DependencyResolutionResult dependencyResolutionResult = mock(DependencyResolutionResult.class); org.eclipse.aether.graph.DependencyNode dependencyNode = mock(org.eclipse.aether.graph.DependencyNode.class); when(dependencyResolutionResult.getDependencyGraph()).thenReturn(dependencyNode); this.dependenciesResolver = mock(ProjectDependenciesResolver.class); when(this.dependenciesResolver.resolve(any(DependencyResolutionRequest.class))).thenReturn(dependencyResolutionResult); this.adapter = new MavenGraphAdapter(this.dependenciesResolver, transitiveIncludeExcludeFilter, targetFilter, EnumSet.of(INCLUDED)); this.graphBuilder = GraphBuilder.create(ToStringNodeIdRenderer.INSTANCE); }
Example #9
Source File: MavenGraphAdapterTest.java From depgraph-maven-plugin with Apache License 2.0 | 6 votes |
@BeforeEach void before() throws Exception { Artifact projectArtifact = mock(Artifact.class); this.mavenProject = new MavenProject(); this.mavenProject.setArtifact(projectArtifact); ProjectBuildingRequest projectBuildingRequest = mock(ProjectBuildingRequest.class); when(projectBuildingRequest.getRepositorySession()).thenReturn(mock(RepositorySystemSession.class)); //noinspection deprecation this.mavenProject.setProjectBuildingRequest(projectBuildingRequest); this.globalFilter = mock(ArtifactFilter.class); ArtifactFilter transitiveIncludeExcludeFilter = mock(ArtifactFilter.class); ArtifactFilter targetFilter = mock(ArtifactFilter.class); this.graphBuilder = GraphBuilder.create(ToStringNodeIdRenderer.INSTANCE); this.dependenciesResolver = mock(ProjectDependenciesResolver.class); DependencyResolutionResult dependencyResolutionResult = mock(DependencyResolutionResult.class); when(dependencyResolutionResult.getDependencyGraph()).thenReturn(mock(org.eclipse.aether.graph.DependencyNode.class)); when(this.dependenciesResolver.resolve(any(DependencyResolutionRequest.class))).thenReturn(dependencyResolutionResult); this.graphAdapter = new MavenGraphAdapter(this.dependenciesResolver, transitiveIncludeExcludeFilter, targetFilter, EnumSet.of(INCLUDED)); }
Example #10
Source File: AbstractVersionsDependencyUpdaterMojo.java From versions-maven-plugin with Apache License 2.0 | 6 votes |
/** * Determine if the artifact is included in the list of artifacts to be processed. * * @param artifact The artifact we want to check. * @return true if the artifact should be processed, false otherwise. */ protected boolean isIncluded( Artifact artifact ) { boolean result = true; ArtifactFilter includesFilter = this.getIncludesArtifactFilter(); if ( includesFilter != null ) { result = includesFilter.include( artifact ); } ArtifactFilter excludesFilter = this.getExcludesArtifactFilter(); if ( excludesFilter != null ) { result = result && excludesFilter.include( artifact ); } return result; }
Example #11
Source File: AggregatingDependencyGraphMojo.java From depgraph-maven-plugin with Apache License 2.0 | 6 votes |
@Override protected GraphFactory createGraphFactory(ArtifactFilter globalFilter, ArtifactFilter transitiveIncludeExcludeFilter, ArtifactFilter targetFilter, GraphStyleConfigurer graphStyleConfigurer) { handleOptionsForFullGraph(); DependencyNodeIdRenderer nodeIdRenderer = DependencyNodeIdRenderer.versionlessId() .withClassifier(!this.mergeClassifiers) .withType(!this.mergeTypes) .withScope(!this.mergeScopes); GraphBuilder<DependencyNode> graphBuilder = graphStyleConfigurer .showGroupIds(this.showGroupIds) .showArtifactIds(true) .showTypes(this.showTypes) .showClassifiers(this.showClassifiers) .showOptional(this.showOptional) .showVersionsOnNodes(this.showVersions) // This graph won't show any conflicting dependencies. So don't show versions on edges .showVersionsOnEdges(false) .repeatTransitiveDependencies(this.repeatTransitiveDependenciesInTextGraph) .configure(GraphBuilder.create(nodeIdRenderer)); MavenGraphAdapter adapter = new MavenGraphAdapter(this.dependenciesResolver, transitiveIncludeExcludeFilter, targetFilter, EnumSet.of(INCLUDED)); return new AggregatingGraphFactory(adapter, subProjectsInReactorOrder(), globalFilter, graphBuilder, this.includeParentProjects, this.reduceEdges); }
Example #12
Source File: DependencyCopy.java From wisdom with Apache License 2.0 | 6 votes |
/** * Gets the list of artifact to consider during the analysis. * * @param mojo the mojo * @param graph the dependency graph builder * @param transitive do we have to include transitive dependencies * @return the set of artifacts */ public static Set<Artifact> getArtifactsToConsider(AbstractWisdomMojo mojo, DependencyGraphBuilder graph, boolean transitive, ArtifactFilter filter) { // No transitive. Set<Artifact> artifacts; if (!transitive) { // Direct dependencies that the current project has (no transitives) artifacts = mojo.project.getDependencyArtifacts(); } else { // All dependencies that the current project has, including transitive ones. Contents are lazily // populated, so depending on what phases have run dependencies in some scopes won't be // included. artifacts = getTransitiveDependencies(mojo, graph, filter); } return artifacts; }
Example #13
Source File: BaseCycloneDxMojo.java From cyclonedx-maven-plugin with Apache License 2.0 | 6 votes |
protected Set<Dependency> buildDependencyGraph(final Set<String> componentRefs) throws MojoExecutionException { final Set<Dependency> dependencies = new LinkedHashSet<>(); final Collection<String> scope = new HashSet<>(); if (includeCompileScope) scope.add("compile"); if (includeProvidedScope) scope.add("provided"); if (includeRuntimeScope) scope.add("runtime"); if (includeSystemScope) scope.add("system"); if (includeTestScope) scope.add("test"); final ArtifactFilter artifactFilter = new CumulativeScopeArtifactFilter(scope); final ProjectBuildingRequest buildingRequest = new DefaultProjectBuildingRequest(session.getProjectBuildingRequest()); buildingRequest.setProject(this.project); try { final DependencyNode rootNode = dependencyGraphBuilder.buildDependencyGraph(buildingRequest, artifactFilter); buildDependencyGraphNode(componentRefs, dependencies, rootNode, null); final CollectingDependencyNodeVisitor visitor = new CollectingDependencyNodeVisitor(); rootNode.accept(visitor); for (final DependencyNode dependencyNode : visitor.getNodes()) { buildDependencyGraphNode(componentRefs, dependencies, dependencyNode, null); } } catch (DependencyGraphBuilderException e) { throw new MojoExecutionException("An error occurred building dependency graph", e); } return dependencies; }
Example #14
Source File: MavenGraphAdapter.java From depgraph-maven-plugin with Apache License 2.0 | 6 votes |
public void buildDependencyGraph(MavenProject project, ArtifactFilter globalFilter, GraphBuilder<DependencyNode> graphBuilder) { DefaultDependencyResolutionRequest request = new DefaultDependencyResolutionRequest(); request.setMavenProject(project); request.setRepositorySession(getVerboseRepositorySession(project)); DependencyResolutionResult result; try { result = this.dependenciesResolver.resolve(request); } catch (DependencyResolutionException e) { throw new DependencyGraphException(e); } org.eclipse.aether.graph.DependencyNode root = result.getDependencyGraph(); ArtifactFilter transitiveDependencyFilter = createTransitiveDependencyFilter(project); GraphBuildingVisitor visitor = new GraphBuildingVisitor(graphBuilder, globalFilter, transitiveDependencyFilter, this.targetFilter, this.includedResolutions); root.accept(visitor); }
Example #15
Source File: ArtifactTransformer.java From component-runtime with Apache License 2.0 | 6 votes |
private ArtifactFilter getFilter() { final List<ArtifactFilter> filters = new ArrayList<>(2); if (include != null) { filters.add(new IncludesArtifactFilter(Stream.of(include.split(",")).collect(toList()))); } if (exclude != null) { filters.add(new ExcludesArtifactFilter(Stream.of(exclude.split(",")).collect(toList()))); } if (scope != null) { filters .addAll(Stream .of(scope.split(",")) .map(singleScope -> singleScope.startsWith("-") ? new ArtifactFilter() { private final ArtifactFilter delegate = newScopeFilter(singleScope.substring(1)); @Override public boolean include(final Artifact artifact) { return !delegate.include(artifact); } } : newScopeFilter(singleScope)) .collect(toList())); } return new AndArtifactFilter(filters); }
Example #16
Source File: MojoExecutor.java From dew with Apache License 2.0 | 6 votes |
private ArtifactFilter getArtifactFilter( MojoDescriptor mojoDescriptor ) { String scopeToResolve = mojoDescriptor.getDependencyResolutionRequired(); String scopeToCollect = mojoDescriptor.getDependencyCollectionRequired(); List<String> scopes = new ArrayList<>( 2 ); if ( StringUtils.isNotEmpty( scopeToCollect ) ) { scopes.add( scopeToCollect ); } if ( StringUtils.isNotEmpty( scopeToResolve ) ) { scopes.add( scopeToResolve ); } if ( scopes.isEmpty() ) { return null; } else { return new CumulativeScopeArtifactFilter( scopes ); } }
Example #17
Source File: MojoExecutor.java From dew with Apache License 2.0 | 6 votes |
private ArtifactFilter getArtifactFilter( MojoDescriptor mojoDescriptor ) { String scopeToResolve = mojoDescriptor.getDependencyResolutionRequired(); String scopeToCollect = mojoDescriptor.getDependencyCollectionRequired(); List<String> scopes = new ArrayList<String>( 2 ); if ( StringUtils.isNotEmpty( scopeToCollect ) ) { scopes.add( scopeToCollect ); } if ( StringUtils.isNotEmpty( scopeToResolve ) ) { scopes.add( scopeToResolve ); } if ( scopes.isEmpty() ) { return null; } else { return new CumulativeScopeArtifactFilter( scopes ); } }
Example #18
Source File: MojoExecutor.java From dew with Apache License 2.0 | 6 votes |
private ArtifactFilter getArtifactFilter(MojoDescriptor mojoDescriptor) { String scopeToResolve = mojoDescriptor.getDependencyResolutionRequired(); String scopeToCollect = mojoDescriptor.getDependencyCollectionRequired(); List<String> scopes = new ArrayList<String>(2); if (StringUtils.isNotEmpty(scopeToCollect)) { scopes.add(scopeToCollect); } if (StringUtils.isNotEmpty(scopeToResolve)) { scopes.add(scopeToResolve); } if (scopes.isEmpty()) { return null; } else { return new CumulativeScopeArtifactFilter(scopes); } }
Example #19
Source File: MojoExecutor.java From dew with Apache License 2.0 | 6 votes |
private ArtifactFilter getArtifactFilter( MojoDescriptor mojoDescriptor ) { String scopeToResolve = mojoDescriptor.getDependencyResolutionRequired(); String scopeToCollect = mojoDescriptor.getDependencyCollectionRequired(); List<String> scopes = new ArrayList<>( 2 ); if ( StringUtils.isNotEmpty( scopeToCollect ) ) { scopes.add( scopeToCollect ); } if ( StringUtils.isNotEmpty( scopeToResolve ) ) { scopes.add( scopeToResolve ); } if ( scopes.isEmpty() ) { return null; } else { return new CumulativeScopeArtifactFilter( scopes ); } }
Example #20
Source File: MojoExecutor.java From dew with Apache License 2.0 | 6 votes |
private ArtifactFilter getArtifactFilter( MojoDescriptor mojoDescriptor ) { String scopeToResolve = mojoDescriptor.getDependencyResolutionRequired(); String scopeToCollect = mojoDescriptor.getDependencyCollectionRequired(); List<String> scopes = new ArrayList<>( 2 ); if ( StringUtils.isNotEmpty( scopeToCollect ) ) { scopes.add( scopeToCollect ); } if ( StringUtils.isNotEmpty( scopeToResolve ) ) { scopes.add( scopeToResolve ); } if ( scopes.isEmpty() ) { return null; } else { return new CumulativeScopeArtifactFilter( scopes ); } }
Example #21
Source File: MojoExecutor.java From dew with Apache License 2.0 | 6 votes |
private ArtifactFilter getArtifactFilter( MojoDescriptor mojoDescriptor ) { String scopeToResolve = mojoDescriptor.getDependencyResolutionRequired(); String scopeToCollect = mojoDescriptor.getDependencyCollectionRequired(); List<String> scopes = new ArrayList<>( 2 ); if ( StringUtils.isNotEmpty( scopeToCollect ) ) { scopes.add( scopeToCollect ); } if ( StringUtils.isNotEmpty( scopeToResolve ) ) { scopes.add( scopeToResolve ); } if ( scopes.isEmpty() ) { return null; } else { return new CumulativeScopeArtifactFilter( scopes ); } }
Example #22
Source File: MojoExecutor.java From dew with Apache License 2.0 | 6 votes |
private ArtifactFilter getArtifactFilter( MojoDescriptor mojoDescriptor ) { String scopeToResolve = mojoDescriptor.getDependencyResolutionRequired(); String scopeToCollect = mojoDescriptor.getDependencyCollectionRequired(); List<String> scopes = new ArrayList<String>( 2 ); if ( StringUtils.isNotEmpty( scopeToCollect ) ) { scopes.add( scopeToCollect ); } if ( StringUtils.isNotEmpty( scopeToResolve ) ) { scopes.add( scopeToResolve ); } if ( scopes.isEmpty() ) { return null; } else { return new CumulativeScopeArtifactFilter( scopes ); } }
Example #23
Source File: DependencyTreeFactory.java From netbeans with Apache License 2.0 | 6 votes |
private static DependencyNode createDependencyTree(MavenProject project, DependencyTreeBuilder dependencyTreeBuilder, ArtifactRepository localRepository, ArtifactFactory artifactFactory, ArtifactMetadataSource artifactMetadataSource, ArtifactCollector artifactCollector, String scope) { ArtifactFilter artifactFilter = createResolvingArtifactFilter(scope); try { // TODO: note that filter does not get applied due to MNG-3236 return dependencyTreeBuilder.buildDependencyTree(project, localRepository, artifactFactory, artifactMetadataSource, artifactFilter, artifactCollector); } catch (DependencyTreeBuilderException exception) { } return null; }
Example #24
Source File: GraphBuildingVisitor.java From depgraph-maven-plugin with Apache License 2.0 | 5 votes |
GraphBuildingVisitor(GraphBuilder<DependencyNode> graphBuilder, ArtifactFilter globalFilter, ArtifactFilter transitiveFilter, ArtifactFilter targetFilter, Set<NodeResolution> includedResolutions) { this.graphBuilder = graphBuilder; this.nodeStack = new ArrayDeque<>(); this.globalFilter = globalFilter; this.transitiveFilter = transitiveFilter; this.targetFilter = targetFilter; this.includedResolutions = includedResolutions; }
Example #25
Source File: Libraries.java From wisdom with Apache License 2.0 | 5 votes |
/** * @return a selection filter that reverse the {@link #getFilter()} selection. This filter is used to determine * whether a dependency must be ignored during the bundle copy because of the {@link #excludeFromApplication} * parameter. */ public ArtifactFilter getReverseFilter() { if (!hasLibraries()) { return null; } AndArtifactFilter filter = new AndArtifactFilter(); PatternExcludesArtifactFilter excl = new PatternExcludesArtifactFilter(getIncludes(), isResolveTransitive()); filter.add(excl); if (!getExcludes().isEmpty()) { PatternIncludesArtifactFilter incl = new PatternIncludesArtifactFilter(getExcludes(), isResolveTransitive()); filter.add(incl); } return filter; }
Example #26
Source File: AggregatingGraphFactory.java From depgraph-maven-plugin with Apache License 2.0 | 5 votes |
public AggregatingGraphFactory( MavenGraphAdapter mavenGraphAdapter, Supplier<Collection<MavenProject>> subProjectSupplier, ArtifactFilter globalFilter, GraphBuilder<DependencyNode> graphBuilder, boolean includeParentProjects, boolean reduceEdges) { this.mavenGraphAdapter = mavenGraphAdapter; this.subProjectSupplier = subProjectSupplier; this.globalFilter = globalFilter; this.graphBuilder = graphBuilder; this.includeParentProjects = includeParentProjects; this.reduceEdges = reduceEdges; }
Example #27
Source File: AbstractGraphMojo.java From depgraph-maven-plugin with Apache License 2.0 | 5 votes |
private ArtifactFilter createGlobalArtifactFilter() { AndArtifactFilter filter = new AndArtifactFilter(); if (this.scope != null) { getLog().warn("The 'scope' parameter is deprecated and will be removed in future versions. Use 'classpathScope' instead."); // Prefer the new parameter if it is set if (this.classpathScope == null) { this.classpathScope = this.scope; } } if (this.classpathScope != null) { if (this.scopes.isEmpty()) { filter.add(new ScopeArtifactFilter(this.classpathScope)); } else { getLog().warn("Both 'classpathScope' (formerly 'scope') and 'scopes' parameters are set. The 'classpathScope' parameter will be ignored."); } } if (!this.scopes.isEmpty()) { filter.add(createScopesArtifactFilter(this.scopes)); } if (!this.includes.isEmpty()) { filter.add(new StrictPatternIncludesArtifactFilter(this.includes)); } if (!this.excludes.isEmpty()) { filter.add(new StrictPatternExcludesArtifactFilter(this.excludes)); } if (this.excludeOptionalDependencies) { filter.add(new OptionalArtifactFilter()); } return filter; }
Example #28
Source File: AbstractGraphMojo.java From depgraph-maven-plugin with Apache License 2.0 | 5 votes |
private ArtifactFilter createTransitiveIncludeExcludeFilter() { AndArtifactFilter filter = new AndArtifactFilter(); if (!this.transitiveIncludes.isEmpty()) { filter.add(new StrictPatternIncludesArtifactFilter(this.transitiveIncludes)); } if (!this.transitiveExcludes.isEmpty()) { filter.add(new StrictPatternExcludesArtifactFilter(this.transitiveExcludes)); } return filter; }
Example #29
Source File: AbstractGraphMojo.java From depgraph-maven-plugin with Apache License 2.0 | 5 votes |
private ArtifactFilter createTargetArtifactFilter() { AndArtifactFilter filter = new AndArtifactFilter(); if (!this.targetIncludes.isEmpty()) { filter.add(new StrictPatternIncludesArtifactFilter(this.targetIncludes)); } return filter; }
Example #30
Source File: DependencyMediatorMojo.java From dependency-mediator with Apache License 2.0 | 5 votes |
private void processPackage() throws MojoExecutionException { try { //Limit the transitivity of a dependency, and also to affect the classpath used for various build tasks. ArtifactFilter artifactFilter = createResolvingArtifactFilter(); DependencyResolver dependencyResolver = new DefaultDependencyResolver(); DependencyNode rootNode = dependencyTreeBuilder.buildDependencyTree(project, localRepository, artifactFilter); DependencyResolutionResult drr = dependencyResolver.resolve(rootNode); Map<String, List<Artifact>> conflictDependencyArtifact = drr .getConflictDependencyArtifact(); Map<String, Artifact> results = drr.getResolvedDependenciesByName(); if (!conflictDependencyArtifact.isEmpty()) { Iterator<Entry<String, List<Artifact>>> iter = conflictDependencyArtifact .entrySet().iterator(); while (iter.hasNext()) { Entry<String, List<Artifact>> conflictEntries = iter.next(); StringBuilder sb = new StringBuilder("Founded conflicting dependency component:"); List<Artifact> conflictArtifacts = conflictEntries.getValue(); sb.append(conflictEntries.getKey()) .append("\n Resolved version is " + results.get(conflictEntries.getKey())) .append("\n But found conflicting artifact "); for (Artifact at : conflictArtifacts) { sb.append(String.format("%s:%s:%s,", at.getGroupId(), at.getArtifactId(), at.getVersion())); } getLog().warn(sb.subSequence(0, sb.length() - 1)); } } } catch (DependencyTreeBuilderException e) { throw new MojoExecutionException("Cannot build project dependency ", e); } }