本文整理汇总了Java中org.apache.maven.artifact.resolver.filter.OrArtifactFilter类的典型用法代码示例。如果您正苦于以下问题:Java OrArtifactFilter类的具体用法?Java OrArtifactFilter怎么用?Java OrArtifactFilter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
OrArtifactFilter类属于org.apache.maven.artifact.resolver.filter包,在下文中一共展示了OrArtifactFilter类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createTransitiveDependencyFilter
import org.apache.maven.artifact.resolver.filter.OrArtifactFilter; //导入依赖的package包/类
private ArtifactFilter createTransitiveDependencyFilter(MavenProject project) {
List<String> dependencyKeys = new ArrayList<>(project.getDependencies().size());
for (Dependency dependency : project.getDependencies()) {
dependencyKeys.add(dependency.getManagementKey());
}
// Matches direct dependencies or the configured transitive dependencies or the project itself
OrArtifactFilter artifactFilter = new OrArtifactFilter();
artifactFilter.add(this.transitiveIncludeExcludeFilter);
artifactFilter.add(new StrictPatternIncludesArtifactFilter(dependencyKeys));
artifactFilter.add(new StrictPatternIncludesArtifactFilter(singletonList(project.getArtifact().toString())));
return artifactFilter;
}
示例2: processTransitiveDependencies
import org.apache.maven.artifact.resolver.filter.OrArtifactFilter; //导入依赖的package包/类
private Set<Artifact> processTransitiveDependencies( Dependency dependency, boolean sharedLibraries )
throws MojoExecutionException
{
log.debug( "Processing transitive dependencies for : " + dependency );
try
{
final Set<Artifact> artifacts = new LinkedHashSet<Artifact>();
final List<String> exclusionPatterns = new ArrayList<String>();
if ( dependency.getExclusions() != null && !dependency.getExclusions().isEmpty() )
{
for ( final Exclusion exclusion : dependency.getExclusions() )
{
exclusionPatterns.add( exclusion.getGroupId() + ":" + exclusion.getArtifactId() );
}
}
final ArtifactFilter optionalFilter = new ArtifactFilter()
{
@Override
public boolean include( Artifact artifact )
{
return !artifact.isOptional();
}
};
final AndArtifactFilter filter = new AndArtifactFilter();
filter.add( new ExcludesArtifactFilter( exclusionPatterns ) );
filter.add( new OrArtifactFilter( Arrays.<ArtifactFilter>asList( new ScopeArtifactFilter( "compile" ),
new ScopeArtifactFilter( "runtime" ),
new ScopeArtifactFilter( "test" ) ) ) );
filter.add( optionalFilter );
final DependencyNode node = dependencyGraphBuilder.buildDependencyGraph( project, filter );
final CollectingDependencyNodeVisitor collectingVisitor = new CollectingDependencyNodeVisitor();
node.accept( collectingVisitor );
final List<DependencyNode> dependencies = collectingVisitor.getNodes();
for ( final DependencyNode dep : dependencies )
{
final boolean isNativeLibrary = isNativeLibrary( sharedLibraries, dep.getArtifact().getType() );
log.debug( "Processing library : " + dep.getArtifact() + " isNative=" + isNativeLibrary );
if ( isNativeLibrary )
{
artifacts.add( dep.getArtifact() );
}
}
return artifacts;
}
catch ( Exception e )
{
throw new MojoExecutionException( "Error while processing transitive dependencies", e );
}
}