diff --git a/src/main/java/org/gradlex/javamodule/moduleinfo/ExtraJavaModuleInfoPluginExtension.java b/src/main/java/org/gradlex/javamodule/moduleinfo/ExtraJavaModuleInfoPluginExtension.java index 811901b..723d5a8 100644 --- a/src/main/java/org/gradlex/javamodule/moduleinfo/ExtraJavaModuleInfoPluginExtension.java +++ b/src/main/java/org/gradlex/javamodule/moduleinfo/ExtraJavaModuleInfoPluginExtension.java @@ -187,6 +187,17 @@ public void automaticModule(Provider alias, Str automaticModule(alias.get().getModule().toString(), moduleName, conf); } + /** + * Remove a Jar that is not a module and is not required at all. + * For example when it only contains metadata irrelevant for Java itself. + * + * @param identifier group:name coordinates _or_ Jar file name + * @param representedModuleName the Module Name of the Module that this Jar represents, needed for 'requireAllDefinedDependencies' + */ + public void remove(String identifier, String representedModuleName) { + getModuleSpecs().put(identifier, new Remove(identifier, representedModuleName)); + } + /** * Let the plugin know about an existing module on the module path. * This may be needed when 'requiresDirectivesFromMetadata(true)' is used. diff --git a/src/main/java/org/gradlex/javamodule/moduleinfo/ExtraJavaModuleInfoTransform.java b/src/main/java/org/gradlex/javamodule/moduleinfo/ExtraJavaModuleInfoTransform.java index b58a202..992c3dd 100644 --- a/src/main/java/org/gradlex/javamodule/moduleinfo/ExtraJavaModuleInfoTransform.java +++ b/src/main/java/org/gradlex/javamodule/moduleinfo/ExtraJavaModuleInfoTransform.java @@ -127,9 +127,13 @@ public void transform(TransformOutputs outputs) { ModuleSpec moduleSpec = findModuleSpec(originalJar); + if (moduleSpec instanceof Remove) { // No output if the Jar is removed + return; + } if (willBeMerged(originalJar, moduleSpecs.values())) { // No output if this Jar will be merged return; } + boolean realModule = isModule(originalJar); if (moduleSpec instanceof ModuleInfo) { if (realModule && !((ModuleInfo) moduleSpec).patchRealModule) { diff --git a/src/main/java/org/gradlex/javamodule/moduleinfo/Remove.java b/src/main/java/org/gradlex/javamodule/moduleinfo/Remove.java new file mode 100644 index 0000000..29e54e9 --- /dev/null +++ b/src/main/java/org/gradlex/javamodule/moduleinfo/Remove.java @@ -0,0 +1,24 @@ +/* + * Copyright the GradleX team. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.gradlex.javamodule.moduleinfo; + +public class Remove extends ModuleSpec { + + Remove(String identifier, String representedModuleName) { + super(identifier, representedModuleName); + } +}