Skip to content

Commit

Permalink
#169 Add support for dependency exclusion
Browse files Browse the repository at this point in the history
  • Loading branch information
aseovic authored Mar 2, 2023
1 parent ef49a1c commit 8e41afb
Showing 1 changed file with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@
import java.util.stream.Collectors;

import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.resolver.filter.AndArtifactFilter;
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
import org.apache.maven.artifact.resolver.filter.ExclusionArtifactFilter;
import org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter;
import org.apache.maven.model.Exclusion;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
Expand All @@ -39,9 +44,11 @@
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.annotations.ResolutionScope;
import org.apache.maven.project.MavenProject;

import org.eclipse.aether.RepositorySystem;
import org.eclipse.aether.RepositorySystemSession;
import org.eclipse.aether.repository.RemoteRepository;

import org.moditect.commands.AddModuleInfo;
import org.moditect.internal.compiler.ModuleInfoCompiler;
import org.moditect.mavenplugin.add.model.MainModuleConfiguration;
Expand Down Expand Up @@ -101,6 +108,9 @@ public class AddModuleInfoMojo extends AbstractMojo {
@Parameter
private List<ModuleConfiguration> modules;

@Parameter
private List<Exclusion> exclusions;

@Parameter
private List<String> jdepsExtraArgs;

Expand All @@ -117,7 +127,13 @@ public void execute() throws MojoExecutionException, MojoFailureException {
getLog().debug("Mojo 'add-module-info' not executed on packaging type '"+project.getModel().getPackaging()+"'");
return;
}


if (exclusions != null) {
ArtifactFilter scopeFilter = new ScopeArtifactFilter("compile+runtime");
ArtifactFilter exclusionFilter = new ExclusionArtifactFilter(exclusions);
project.setArtifactFilter(new AndArtifactFilter(List.of(scopeFilter, exclusionFilter)));
}

Path outputPath = outputDirectory.toPath();

createDirectories();
Expand Down

0 comments on commit 8e41afb

Please sign in to comment.