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

[MCOMPILER-534] Document conditional setting of the --release property #187

Closed

Conversation

aherbert
Copy link
Contributor

Tested using:

mvn site:site -DgenerateReports=false

@garydgregory
Copy link
Member

@aherbert ping, the build failed. You might have to rerun the job if the logs have already been removed.

@aherbert
Copy link
Contributor Author

The build fails due to something totally unrelated. This is a change to the site documentation. That is not what is failing the build. When I looked at this the other PRs, and also the master branch, were also failing. I will rebase and push to collect a fix that I presume is now in master.


The <<<--release>>> option is used to target an older Java release than the JDK used during the
build process. This flag is not supported using JDK 8. To enable a project that targets Java 8
to be built using JDK 8 or later requires the conditional usage of the <<<--release>>> option.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JDK 9 or later

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The whole point is you want to be able to build with JDK 8 or later. If you want to only build with JDK 9 or later then you do not have to use conditional setting of the --release option.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is not what the sentence tells me. It says: Targettting Java 8 need JDK 8 or later and it requires this flag. What am I misunderstanding? I understand what you say and you are right, but the documentation is not for me.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change "it requires this flag" to "it requires this flag when using a JDK later than 8".

If you use the flag with JDK 8 then the build breaks. This was the original source of [MCOMPILER-534]. You can only use the flag with JDK 9+:

Target   Tool chain   --release flag    Result
Java 8   JDK 8        Y                 build error
Java 8   JDK 8        N                 OK
Java 8   JDK 9        Y                 OK (compiler targets Java 8)
Java 8   JDK 9        N                 compiler targets Java 9 API methods that supersede Java 8 methods

If this is not the desired behaviour, i.e. the --release flag should be harmless if set on JDK 8, then something should be changed in the compiler plugin. If you should not use the flag when using JDK 8, then this is what I am trying to address with this documentation.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The table does not look right, line 2. No JDK 8 exhibits --release. You can never provide it on JDK 8. What am I missing again?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The table --release column should really read set <maven.compiler.release>8</maven.compiler.release> but that was too long. Forgive my shorthand with no explanation.

When you set <maven.compiler.release>8</maven.compiler.release> then the maven plugin will use the --release flag. This is not ignored by JDK 8; as you state it does not exhibit this flag as an option. Using it raises an error. So you cannot set it when building with JDK 8. You should only set it for JDK 9+.

If this is not clear from my documentation then we can revise it. It is trying to state:

  1. Do not use this flag when building with JDK 8
  2. Use it when building with a later JDK (i.e. 9+) and targeting Java 8

I think a perfectly valid example is a project with a toolchain that uses JDK 8 only (i.e. it can be built with JDK 8). This can still be compiled with JDK 11. But that may end up targeting the wrong Java API if some methods/classes have had updates. So your project then should conditionally set the <maven.compiler.release> property. If you always set it then you have problems on JDK 8.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rework the docs. I prefer rather no docs than confusing docs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revised docs to explicitly state building "using JDK 8 and also JDK 9 or later". I think this is crux of the issue. If you only use one toolchain for the build then there is no issue, just configure it for that toolchain. If you wish your build to be flexible then you require conditional setting of the property.

@aherbert aherbert force-pushed the compiler-534-doc-release-property branch from 4798b20 to 86d761d Compare April 30, 2023 18:51
Copy link
Member

@michael-o michael-o left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me, but the issue type is bug and not improvement, plus the summary does not match. Should I update to match with your PR since we aren't going to change the code and there is no bug here, but so by design. WDYT?

@aherbert
Copy link
Contributor Author

Sure, update the Jira ticket as you see fit. This is more documentation of the current intent of the plugin.

I am not familiar with the CI workflow but something does not seem correct with the current build; I believe it to be unrelated to this doc change.

@michael-o
Copy link
Member

Sure, update the Jira ticket as you see fit. This is more documentation of the current intent of the plugin.

I am not familiar with the CI workflow but something does not seem correct with the current build; I believe it to be unrelated to this doc change.

Will address this PR tomorrow.

@asfgit asfgit closed this in 6dfe7f9 May 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants