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

Ability to set a min language version for a toolchain (maybe also max and preferred) #16256

Open
Vampire opened this issue Feb 22, 2021 · 3 comments
Labels
a:feature A new functionality in:toolchains Java Toolchains

Comments

@Vampire
Copy link
Contributor

Vampire commented Feb 22, 2021

I have a library where I still maintain Java 8 compatibility.
But I want JavaDoc to always be created with at least Java 9 to get the nice search box.
So I could configure a Java 9 toolchain for the JavaDoc task of course.
But if someone builds with Java 11, there is not really a need to discover or auto-provision a Java 9 toolchain.
Because of that it would be nice if you could specify a toolchain with min language version (maybe there are also use-cases for max language version), so that the current toolchain is used if it is recent enough and just another one is searched if it is too old.

Currently you would probably have to do something like

tasks.javadoc {
    if (!JavaVersion.current().isJava9Compatible) {
        javadocTool.set(javaToolchains.javadocToolFor {
            languageVersion.set(JavaLanguageVersion.of(9))
        })
    }
}
@Vampire Vampire added a:feature A new functionality from:contributor labels Feb 22, 2021
@ljacomet ljacomet added the in:toolchains Java Toolchains label Feb 22, 2021
@Vampire
Copy link
Contributor Author

Vampire commented Mar 17, 2021

While the work-around of course only works if the current version is compatible, a min version and max version would be better as then also another discovered version can be used, like you specify "min java 9", run with java 8, and there is a discovered java 10, then for the JavaDoc task the discovered version can be used without provisioning a new java 9 version.

Maybe even a "preferred version" would make sense then, so if min version is 9 and 9 and 10 is discovered that the preferred one is used, but that might be overkill.

@stale
Copy link

stale bot commented Apr 17, 2022

This issue has been automatically marked as stale because it has not had recent activity. Given the limited bandwidth of the team, it will be automatically closed if no further activity occurs. If you're interested in how we try to keep the backlog in a healthy state, please read our blog post on how we refine our backlog. If you feel this is something you could contribute, please have a look at our Contributor Guide. Thank you for your contribution.

@stale stale bot added stale and removed stale labels Apr 17, 2022
@Vampire Vampire changed the title Ability to set a min language version for a toolchain (maybe also max) Ability to set a min language version for a toolchain (maybe also max and preferred) Mar 13, 2024
@JojOatXGME
Copy link

When you specify Java 17 as the minimum version, I guess Gradle should implicitly specify -release 17 when it uses a more recent JDK for compiling.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:feature A new functionality in:toolchains Java Toolchains
Projects
None yet
Development

No branches or pull requests

5 participants
@ljacomet @Vampire @JojOatXGME @jjohannes and others