bndtools / bnd

Bnd/Bndtools. Tooling to build OSGi bundles including Eclipse, Maven, and Gradle plugins.
https://bndtools.org
Other
527 stars 305 forks source link

How to skip --release flag with bnd gradle plugin ? #6248

Open bmv126 opened 2 weeks ago

bmv126 commented 2 weeks ago

I am using 7.0.0 bnd gradle plugin.

In my cnf/build.bnd, javac source and javac target are not set.

#javac.source: 1.21
#javac.target: 1.21

I am using jdk21 to compile the src code with JAVA_HOME set to jdk 21 binary path.

JAVA_HOME=/usr/lib/jvm/java-21-openjdk

However when I run the gradlew command I see below getting printed in compiler arguments and debug logs:

2024-08-29T15:33:33.614+0530 [INFO] [org.gradle.api.Task] Compile to /home/test/java21/module/com.abc.plugin.core/bin
2024-08-29T15:33:33.614+0530 [INFO] [org.gradle.api.Task] --release 21 --add-exports java.base/sun.net.www=ALL-UNNAMED
2024-08-29T15:33:33.632+0530 [DEBUG] [org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler] Compiler arguments: --release 21 

From this code, I was thinking if we do not have javac.source and javac.target set in build.bnd, --release will not be added to the compiler arguments, but it is still getting added.

As I am trying to use --add-exports option,it is causing conflict with --release and build is failing.

2024-08-29T15:33:33.970+0530 [ERROR] [system.err] error: exporting a package from system module java.base is not allowed with --release

How to avoid adding the --release option in the compiler arguments ?

 

pkriens commented 2 weeks ago

It looks like a gradle issue?

bmv126 commented 1 week ago

Does not look like gradle issue.

Instead of commenting out the javac.source and javac.target variables, if I just set it to empty value like below

javac.source:
javac.target:

It works as expected. The --release does not get added and -source -target gets added and with this --add-exports can be added.

pkriens commented 1 week ago

so we can close this?