13

I want to download everything except my own dependencies, which I haven't compiled yet. I think what I need is excludeGroupIds, but how to I set it, or anything else in https://maven.apache.org/plugins/maven-dependency-plugin/go-offline-mojo.html on the command line?

I have tried this

mvn dependency:go-offline -DexcludeGroupIds=com.example

I have also tried to set them in pom.xml and settings.xml, and not been able to make them have any effect.

Alex028502
  • 3,486
  • 2
  • 23
  • 50

1 Answers1

4

From checking the code of the maven-dependency-plugin, I'm pretty sure this is a bug, in the sense that the filters are not applied for go-offline. Here's the code that resolves dependencies in the go-offline mojo implementation (version 3.1.3-SNAPSHOT):

protected Set<Artifact> resolveDependencyArtifacts()
        throws DependencyResolverException
{
    final Collection<Dependency> dependencies = getProject().getDependencies();
    final Set<DependableCoordinate> dependableCoordinates = new HashSet<>();

    final ProjectBuildingRequest buildingRequest = newResolveArtifactProjectBuildingRequest();

    for ( Dependency dependency : dependencies )
    {
        dependableCoordinates.add( createDependendableCoordinateFromDependency( dependency ) );
    }

    return resolveDependableCoordinate( buildingRequest, dependableCoordinates, "dependencies" );
}

In contract, here is the code that resolves dependencies for the resolve mojo:

@Override
protected void doExecute()
    throws MojoExecutionException
{
    // get sets of dependencies
    results = this.getDependencySets( false, includeParents );

    ...
}

AbstractDependencyFilterMojo:

protected DependencyStatusSets getDependencySets( boolean stopOnFailure, boolean includeParents )
    throws MojoExecutionException
{
    // add filters in well known order, least specific to most specific
    FilterArtifacts filter = new FilterArtifacts();

    filter.addFilter( new ProjectTransitivityFilter( getProject().getDependencyArtifacts(),
                                                     this.excludeTransitive ) );

    filter.addFilter( new ScopeFilter( DependencyUtil.cleanToBeTokenizedString( this.includeScope ),
                                       DependencyUtil.cleanToBeTokenizedString( this.excludeScope ) ) );

    filter.addFilter( new TypeFilter( DependencyUtil.cleanToBeTokenizedString( this.includeTypes ),
                                      DependencyUtil.cleanToBeTokenizedString( this.excludeTypes ) ) );

    filter.addFilter( new ClassifierFilter( DependencyUtil.cleanToBeTokenizedString( this.includeClassifiers ),
                                            DependencyUtil.cleanToBeTokenizedString( this.excludeClassifiers ) ) );

    filter.addFilter( new GroupIdFilter( DependencyUtil.cleanToBeTokenizedString( this.includeGroupIds ),
                                         DependencyUtil.cleanToBeTokenizedString( this.excludeGroupIds ) ) );

    filter.addFilter( new ArtifactIdFilter( DependencyUtil.cleanToBeTokenizedString( this.includeArtifactIds ),
                                            DependencyUtil.cleanToBeTokenizedString( this.excludeArtifactIds ) ) );

    ...

It's pretty clear that the code of go-offline is not applying those filters when resolving dependencies. So I've inserted a ticket for the project to confirm: https://issues.apache.org/jira/browse/MDEP-725

M A
  • 71,713
  • 13
  • 134
  • 174