exasol / project-keeper

This maven plugin checks and unifies a project's structure according to the Exasol integration team's repository standards.
MIT License
3 stars 1 forks source link

Enable compiler warnings #497

Closed kaklakariada closed 10 months ago

kaklakariada commented 11 months ago

By default Maven generates only a non-helpful warning for deprecated Java code:

[INFO] --- maven-compiler-plugin:3.11.0:testCompile (default-testCompile) @ exasol-testcontainers ---
[INFO] Changes detected - recompiling the module! :dependency
[INFO] Compiling 72 source files with javac [debug target 11] to target/test-classes
[INFO] /home/runner/work/exasol-testcontainers/exasol-testcontainers/src/test/java/com/exasol/clusterlogs/MappedClusterLogsIT.java: /home/runner/work/exasol-testcontainers/exasol-testcontainers/src/test/java/com/exasol/clusterlogs/MappedClusterLogsIT.java uses or overrides a deprecated API.
[INFO] /home/runner/work/exasol-testcontainers/exasol-testcontainers/src/test/java/com/exasol/clusterlogs/MappedClusterLogsIT.java: Recompile with -Xlint:deprecation for details.
[INFO] 

To fix this, we need to add option to the compiler plugin:

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.11.0</version>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                    <showWarnings>true</showWarnings>
                    <compilerArgs>
                        <arg>-Xlint:all</arg>
                    </compilerArgs>
                </configuration>
            </plugin>

Note: <arg>-Werror</arg> would let the build fail with the following error:

[INFO] --- maven-compiler-plugin:3.11.0:compile (default-compile) @ exasol-testcontainers ---
[INFO] Changes detected - recompiling the module! :source
[INFO] Compiling 71 source files with javac [debug target 11] to target/classes
[INFO] -------------------------------------------------------------
[WARNING] COMPILATION WARNING : 
[INFO] -------------------------------------------------------------
[WARNING] system modules path not set in conjunction with -source 11
[INFO] 1 warning
[INFO] -------------------------------------------------------------
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] warnings found and -Werror specified
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------