kitodo / kitodo-production

Kitodo.Production is a workflow management tool for mass digitization and is part of the Kitodo Digital Library Suite.
http://www.kitodo.org/software/kitodoproduction/
GNU General Public License v3.0
63 stars 63 forks source link

pom.xml: Replace maven.compiler.{source,target} by maven.compiler.release #6114

Closed stweil closed 2 weeks ago

stweil commented 2 months ago

This fixes a lot of build warnings with Java compilers newer than version 11.

As the change is supported since Java 9, it also works with Java 11.

stweil commented 2 months ago

The commit fixes these build warnings:

WARNING system modules path not set in conjunction with -source 11

Please merge.

henning-gerhardt commented 2 months ago

The commit fixes these build warnings:

WARNING system modules path not set in conjunction with -source 11

Please merge.

I did not see this warning in the CI runs nor on building on my local development system. Which version of Maven did you use? On CI Maven version 3.8.8 is in use (on my local system 3.8.7).

henning-gerhardt commented 2 months ago

Compiling output did change from f.e.

[INFO] Compiling 384 source files with javac [debug:lines,vars,source target 11] to target/classes

to

[INFO] Compiling 384 source files with javac [debug:lines,vars,source release 11] to target/classes

It may have the same meaning and same binary result but it could even mean something different.

stweil commented 2 months ago

I have Apache Maven 3.8.7 (Debian bookworm).

stweil commented 2 months ago

I think it is a warning from the Java compiler, so it depends on the javac version (javac 17.0.11 in my case).

henning-gerhardt commented 2 months ago

I think it is a warning from the Java compiler, so it depends on the Java version (openjdk 17.0.11 2024-04-16 in my case).

So far as I know there is currently no real support for Java versions greater then 11 in usage and even for compiling / building the application. Your fix should be applied at least on switching to Java 17 (or newer) as I don't know what are the consequences on using this right now with Java 11.

stweil commented 2 months ago

Related documentation: https://maven.apache.org/plugins/maven-compiler-plugin/examples/set-compiler-release.html.

stweil commented 2 months ago

It may have the same meaning and same binary result but it could even mean something different.

It means the same , but "unlike the -source and -target options, the compiler will detect and generate an error when using APIs that don't exist in previous releases of Java SE". This is a desired additional meaning.

stweil commented 2 months ago

Your fix should be applied at least on switching to Java 17 (or newer) as I don't know what are the consequences on using this right now with Java 11.

It works since Java 9, so a Java 11 compiler fully supports it: "Starting JDK 9, the javac executable can accept the --release option to specify against which Java SE release you want to build the project".

stweil commented 2 months ago

@solth, please merge.

stweil commented 1 month ago

mvn clean dependency:analyze und andere Aufrufe mit OpenJDK 22 Compiler erzeugt diese Warnungen:

[WARNING] Systemmodulpfad ist nicht zusammen mit -source 11 festgelegt
  Wenn Sie den Speicherort der Systemmodule nicht festlegen, kann dies zu Klassendateien führen, die auf JDK 11 nicht ausgeführt werden können
    --release 11 wird anstelle von -source 11 -target 11 empfohlen, weil dadurch der Speicherort der Systemmodule automatisch festgelegt wird

Die hier verwendete Konfiguration entspricht dem Hinweis in den Warnungen und wird seit JDK 9 unterstützt.

JDK 9 und JDK 11 erzeugen offenbar keine Warnungen, aber JDK 17 und JDK 22 geben den Warnungstext für jedes Modul von Kitodo.Production aus. Dieser Pull Request korrigiert das, funktioniert aber auch ohne Einschränkung mit JDK 11.