30
30
import java .util .stream .Collectors ;
31
31
32
32
import 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 ;
33
38
import org .apache .maven .plugin .AbstractMojo ;
34
39
import org .apache .maven .plugin .MojoExecutionException ;
35
40
import org .apache .maven .plugin .MojoFailureException ;
39
44
import org .apache .maven .plugins .annotations .Parameter ;
40
45
import org .apache .maven .plugins .annotations .ResolutionScope ;
41
46
import org .apache .maven .project .MavenProject ;
47
+
42
48
import org .eclipse .aether .RepositorySystem ;
43
49
import org .eclipse .aether .RepositorySystemSession ;
44
50
import org .eclipse .aether .repository .RemoteRepository ;
51
+
45
52
import org .moditect .commands .AddModuleInfo ;
46
53
import org .moditect .internal .compiler .ModuleInfoCompiler ;
47
54
import org .moditect .mavenplugin .add .model .MainModuleConfiguration ;
@@ -101,6 +108,9 @@ public class AddModuleInfoMojo extends AbstractMojo {
101
108
@ Parameter
102
109
private List <ModuleConfiguration > modules ;
103
110
111
+ @ Parameter
112
+ private List <Exclusion > exclusions ;
113
+
104
114
@ Parameter
105
115
private List <String > jdepsExtraArgs ;
106
116
@@ -117,7 +127,13 @@ public void execute() throws MojoExecutionException, MojoFailureException {
117
127
getLog ().debug ("Mojo 'add-module-info' not executed on packaging type '" +project .getModel ().getPackaging ()+"'" );
118
128
return ;
119
129
}
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
+
121
137
Path outputPath = outputDirectory .toPath ();
122
138
123
139
createDirectories ();
0 commit comments