本文整理匯總了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 );
}
}