3030import java .util .stream .Collectors ;
3131
3232import org .apache .maven .artifact .Artifact ;
33+ import org .apache .maven .artifact .resolver .filter .AndArtifactFilter ;
34+ import org .apache .maven .artifact .resolver .filter .ArtifactFilter ;
35+ import org .apache .maven .artifact .resolver .filter .ExclusionArtifactFilter ;
36+ import org .apache .maven .artifact .resolver .filter .ScopeArtifactFilter ;
37+ import org .apache .maven .model .Exclusion ;
3338import org .apache .maven .plugin .AbstractMojo ;
3439import org .apache .maven .plugin .MojoExecutionException ;
3540import org .apache .maven .plugin .MojoFailureException ;
3944import org .apache .maven .plugins .annotations .Parameter ;
4045import org .apache .maven .plugins .annotations .ResolutionScope ;
4146import org .apache .maven .project .MavenProject ;
47+
4248import org .eclipse .aether .RepositorySystem ;
4349import org .eclipse .aether .RepositorySystemSession ;
4450import org .eclipse .aether .repository .RemoteRepository ;
51+
4552import org .moditect .commands .AddModuleInfo ;
4653import org .moditect .internal .compiler .ModuleInfoCompiler ;
4754import org .moditect .mavenplugin .add .model .MainModuleConfiguration ;
@@ -101,6 +108,9 @@ public class AddModuleInfoMojo extends AbstractMojo {
101108 @ Parameter
102109 private List <ModuleConfiguration > modules ;
103110
111+ @ Parameter
112+ private List <Exclusion > exclusions ;
113+
104114 @ Parameter
105115 private List <String > jdepsExtraArgs ;
106116
@@ -117,7 +127,13 @@ public void execute() throws MojoExecutionException, MojoFailureException {
117127 getLog ().debug ("Mojo 'add-module-info' not executed on packaging type '" +project .getModel ().getPackaging ()+"'" );
118128 return ;
119129 }
120-
130+
131+ if (exclusions != null ) {
132+ ArtifactFilter scopeFilter = new ScopeArtifactFilter ("compile+runtime" );
133+ ArtifactFilter exclusionFilter = new ExclusionArtifactFilter (exclusions );
134+ project .setArtifactFilter (new AndArtifactFilter (List .of (scopeFilter , exclusionFilter )));
135+ }
136+
121137 Path outputPath = outputDirectory .toPath ();
122138
123139 createDirectories ();
0 commit comments