Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Java Builds with Conditional Compiler Options for JDK-8 Compatibility #16

Merged
merged 1 commit into from
Jan 6, 2024

Conversation

kilo52
Copy link
Member

@kilo52 kilo52 commented Jan 5, 2024

Adds conditional handling for --source and --target and --release compiler arguments in Maven-based builds.

The POM for Java-based project source templates is adjusted conditionally such that when Java 8 support is specified by the user as a requirement, then the POM will have two additional profiles which are activated based on the JDK version which is used to build the project. This effectively instructs Maven to add the --source and --target arguments as compiler options when using JDK-8. However, when using JDK-9 or higher, only the --release argument must be specified as a compiler option. This ensures complete compatibility of the produced class files with the minimum specified Java version.
When support for Java 8 is not required by the project, then the Maven profiles are not added and the --release compiler option is simply specified in the POMs project properties.

The Maven compiler plugin is added to the affected POMs as an explicit declaration with version 3.12.1 of the plugin.

The Maven JAR plugin is updated to version 3.3.0 of the plugin in all affected POMs.

Introduces conditional handling for when a Java project needs
compatibility with Java 8. The POM for Java project source templates is
adjusted conditionally such that when Java 8 support is specified by the
user as a requirement, then the POM will have two additional profiles
which activate based on the JDK version which is used to build the
project. This effectively instructs Maven to add the --source and --target
arguments as compiler options when using JDK-8. However, when using JDK-9
or higher, only the --release argument must be specified as a compiler
option. This ensures complete compatibility of the produced class files
with the minimum specified Java version.

The Maven compiler plugin is added to the affected POMs as an explicit
declaration with version 3.12.1 of the plugin.

The Maven JAR plugin is updated to version 3.3.0 of the plugin in all
affected POMs.
@kilo52 kilo52 linked an issue Jan 5, 2024 that may be closed by this pull request
@kilo52 kilo52 added Improvement Improvement of an existing feature Templates Changes in project source templates Java Affects project source templates or init code for Java labels Jan 5, 2024
@kilo52 kilo52 merged commit 9be0441 into master Jan 6, 2024
@kilo52 kilo52 deleted the templates/java-jdk8-pom-compat branch January 6, 2024 21:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Improvement Improvement of an existing feature Java Affects project source templates or init code for Java Templates Changes in project source templates
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Explicit Java Compiler Release Option
1 participant