org.apache.maven.artifact.resolver.filter.CumulativeScopeArtifactFilter Java Examples

The following examples show how to use org.apache.maven.artifact.resolver.filter.CumulativeScopeArtifactFilter. 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: MojoUtil.java    From kogito-runtimes with Apache License 2.0 6 votes vote down vote up
public static Set<URL> getProjectFiles(final MavenProject mavenProject, final List<InternalKieModule> kmoduleDeps)
        throws DependencyResolutionRequiredException, IOException {
    final Set<URL> urls = new HashSet<>();
    for (final String element : mavenProject.getCompileClasspathElements()) {
        urls.add(new File(element).toURI().toURL());
    }

    mavenProject.setArtifactFilter(new CumulativeScopeArtifactFilter(Arrays.asList("compile", "runtime")));
    for (final Artifact artifact : mavenProject.getArtifacts()) {
        final File file = artifact.getFile();
        if (file != null && file.isFile()) {
            urls.add(file.toURI().toURL());
            final KieModuleModel depModel = getDependencyKieModel(file);
            if (kmoduleDeps != null && depModel != null) {
                final ReleaseId releaseId = new ReleaseIdImpl(artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion());
                kmoduleDeps.add(new ZipKieModule(releaseId, depModel, file));
            }
        }
    }
    return urls;
}
 
Example #2
Source File: MojoExecutor.java    From dew with Apache License 2.0 6 votes vote down vote up
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 #3
Source File: MojoExecutor.java    From dew with Apache License 2.0 6 votes vote down vote up
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 #4
Source File: MojoExecutor.java    From dew with Apache License 2.0 6 votes vote down vote up
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 #5
Source File: MojoExecutor.java    From dew with Apache License 2.0 6 votes vote down vote up
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 #6
Source File: MojoExecutor.java    From dew with Apache License 2.0 6 votes vote down vote up
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 #7
Source File: MojoExecutor.java    From dew with Apache License 2.0 6 votes vote down vote up
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 #8
Source File: MojoExecutor.java    From dew with Apache License 2.0 6 votes vote down vote up
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 #9
Source File: BaseCycloneDxMojo.java    From cyclonedx-maven-plugin with Apache License 2.0 6 votes vote down vote up
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 #10
Source File: ScopeSkipper.java    From pgpverify-maven-plugin with Apache License 2.0 2 votes vote down vote up
/**
 * Construction of cumulative scope filter.
 *
 * @param scope the maximum scope, meaning that if, e.g. 'test' scope is specified, then every scope
 *              chronologically prior to 'test' will also be included.
 */
public ScopeSkipper(String scope) {
    filter = new CumulativeScopeArtifactFilter(singleton(requireNonNull(scope)));
}