Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Extra Java Module Info Gradle Plugin - Changelog

## Version 1.10.1
* [Fix] [#164](https://github.com/gradlex-org/extra-java-module-info/pull/164) - fix: 'preserveExisting' does not duplicate 'provides' entries

## Version 1.10
* [New] [#160](https://github.com/gradlex-org/extra-java-module-info/pull/160) - Add 'preserveExisting' option to patch real modules
* [New] [#140](https://github.com/gradlex-org/extra-java-module-info/pull/140) - Add 'removePackage' option to deal with duplicated packages
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ public ModuleVisitor visitModule(String name, int access, String version) {
return new ModuleVisitor(Opcodes.ASM9, moduleVisitor) {
@Override
public void visitEnd() {
addModuleInfoEntires(moduleInfo, providers, autoExportedPackages, this);
addModuleInfoEntires(moduleInfo, Collections.emptyMap(), autoExportedPackages, this);
super.visitEnd();
}
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.gradlex.javamodule.moduleinfo.test

import org.gradlex.javamodule.moduleinfo.test.fixture.GradleBuild
import spock.lang.IgnoreIf
import spock.lang.Specification

class RealModuleJarPatchingFunctionalTest extends Specification {
Expand Down Expand Up @@ -200,57 +199,4 @@ class RealModuleJarPatchingFunctionalTest extends Specification {
out.output.contains("Patching of real modules must be explicitly enabled with 'patchRealModule()' and can only be done with 'module()'")
}

@IgnoreIf({ GradleBuild.gradleVersionUnderTest?.matches("[67]\\..*") }) // requires Gradle to support Java 17
def "a real module cannot be extended"() {
given:
buildFile << '''
tasks.withType<JavaCompile>().configureEach {
options.compilerArgs.add("-Xlint:all")
options.compilerArgs.add("-Werror")
}
dependencies {
implementation("org.apache.logging.log4j:log4j-api:2.24.3")

// required because not declared in LOG4J metadata
compileOnly("com.google.errorprone:error_prone_annotations:2.36.0")
compileOnly("com.github.spotbugs:spotbugs-annotations:4.9.0")
compileOnly("biz.aQute.bnd:biz.aQute.bnd.annotation:7.1.0")
compileOnly("org.osgi:osgi.annotation:8.1.0") // this includes 'org.osgi.annotation.bundle'
}
extraJavaModuleInfo {
failOnMissingModuleInfo.set(false) // transitive dependencies of annotation libs

module("org.apache.logging.log4j:log4j-api", "org.apache.logging.log4j") {
preserveExisting()
requiresStatic("com.google.errorprone.annotations")
requiresStatic("com.github.spotbugs.annotations")
requiresStatic("biz.aQute.bnd.annotation")
requiresStatic("org.osgi.annotation")
}
module("biz.aQute.bnd:biz.aQute.bnd.annotation", "biz.aQute.bnd.annotation") {
requiresStatic("org.osgi.annotation")
exportAllPackages()
}
module("org.osgi:osgi.annotation", "org.osgi.annotation")
}
'''
file("src/main/java/module-info.java") << """
module org.example {
requires org.apache.logging.log4j;
}
"""
file("src/main/java/org/example/Main.java") << """
package org.example;
public class Main {
org.apache.logging.log4j.message.ParameterizedMessage m; // needs errorprone
org.apache.logging.log4j.status.StatusData d; // needs spotbugs
org.apache.logging.log4j.util.SystemPropertiesPropertySource s; // needs aQute.bnd
org.apache.logging.log4j.util.Activator a; // needs osgi
}
"""

expect:
build()
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
package org.gradlex.javamodule.moduleinfo.test

import org.gradlex.javamodule.moduleinfo.test.fixture.GradleBuild
import spock.lang.IgnoreIf
import spock.lang.Specification

class RealModuleJarPreservePatchingFunctionalTest extends Specification {

@Delegate
GradleBuild build = new GradleBuild()

def setup() {
settingsFile << 'rootProject.name = "test-project"'
buildFile << '''
plugins {
id("application")
id("org.gradlex.extra-java-module-info")
}
application {
mainModule.set("org.example")
mainClass.set("org.example.Main")
}
'''
}

@IgnoreIf({ GradleBuild.gradleVersionUnderTest?.matches("[67]\\..*") }) // requires Gradle to support Java 17
def "a real module cannot be extended via preserveExisting"() {
given:
buildFile << '''
tasks.withType<JavaCompile>().configureEach {
options.compilerArgs.add("-Xlint:all")
options.compilerArgs.add("-Werror")
}
dependencies {
implementation("org.apache.logging.log4j:log4j-api:2.24.3")

// required because not declared in LOG4J metadata
compileOnly("com.google.errorprone:error_prone_annotations:2.36.0")
compileOnly("com.github.spotbugs:spotbugs-annotations:4.9.0")
compileOnly("biz.aQute.bnd:biz.aQute.bnd.annotation:7.1.0")
compileOnly("org.osgi:osgi.annotation:8.1.0") // this includes 'org.osgi.annotation.bundle'
}
extraJavaModuleInfo {
failOnMissingModuleInfo.set(false) // transitive dependencies of annotation libs

module("org.apache.logging.log4j:log4j-api", "org.apache.logging.log4j") {
preserveExisting()
requiresStatic("com.google.errorprone.annotations")
requiresStatic("com.github.spotbugs.annotations")
requiresStatic("biz.aQute.bnd.annotation")
requiresStatic("org.osgi.annotation")
}
module("biz.aQute.bnd:biz.aQute.bnd.annotation", "biz.aQute.bnd.annotation") {
requiresStatic("org.osgi.annotation")
exportAllPackages()
}
module("org.osgi:osgi.annotation", "org.osgi.annotation")
}
'''
file("src/main/java/module-info.java") << """
module org.example {
requires org.apache.logging.log4j;
}
"""
file("src/main/java/org/example/Main.java") << """
package org.example;
public class Main {
org.apache.logging.log4j.message.ParameterizedMessage m; // needs errorprone
org.apache.logging.log4j.status.StatusData d; // needs spotbugs
org.apache.logging.log4j.util.SystemPropertiesPropertySource s; // needs aQute.bnd
org.apache.logging.log4j.util.Activator a; // needs osgi

public static void main(String[] args) {}
}
"""

expect:
run()
}

}