-
Notifications
You must be signed in to change notification settings - Fork 116
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
Toolchain for JDK version does not work in Eclipse 2022-09 anymore #988
Comments
May relate with #1120 |
I have a similar problem with the jaxws-maven-plugin:2.6: the toolchain is not honored and the plugin is run using Java 17. It is as if m2e was not reading the Note that I tried the snapshot release of m2e (2.3.0.20230329-2139) without any result. |
I'm not aware of a way to define the JDK/Java-version through a tool-chain as it is described in the Guide to Using Toolchains. From your description I assume you have configured In the Eclipse preferences you could do the same by associating a JDK11 for the JavaSE-1.8 execution environment: |
This should now be fixed with #1643. But we still would need a test-case for this issue. If @G-Ork cannot provide a one, @glhez would you be interested to provide a PR with a test-case in |
As per the previous comments, I think this issue is not an Eclipse bug respectively the described problems are fixed. |
Indeed i've fixed the configuration part in m2e to set the toolchain locations. But there are more layers in maven. Actually i can not guaranty that #1643 will solve your problems. @philipp-lenz In eclipse things work quite different. The toolchain is in most cases for plain maven execution e.g. on your build server. M2e parses your maven config and configures your eclipse project to use a suitable execution environment. Toolchains end eclipse execution environments are to independent concepts for the same problem. You find an example pom in #1120 as @blacelle mentioned. Also works without a profile. The major part is to configure the compiler for m2e and be sure you have suitable / matching environments configured in your workspace. @glhez: Can you provide a example project for your use case? |
This pom.xml should do the trick: https://github.com/glhez/m2e-core-toolchains-988/blob/master/pom.xml (you can clone the project if you need).
And I do have a toolchains for Java 8: In Maven, this is defined as: <?xml version="1.0" encoding="UTF8"?>
<!-- Generated by Zeta Bash /e/git/zb/zeta-bash/bin/maven-generate-toolchains on 2024-01-31T00:29:33+01:00 -->
<toolchains xmlns='http://maven.apache.org/TOOLCHAINS/1.1.0'
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xsi:schemaLocation='http://maven.apache.org/TOOLCHAINS/1.1.0 https://maven.apache.org/xsd/toolchains-1.1.0.xsd'
>
<toolchain> <type>jdk</type> <provides> <version>1.8.0_402</version> <id>JavaSE-1.8</id> <vendor>Temurin</vendor> </provides> <configuration> <jdkHome>E:\apps\portable\java\latest\openjdk-8-hotspot</jdkHome> </configuration> </toolchain>
<toolchain> <type>jdk</type> <provides> <version>17.0.10</version> <id>JavaSE-17</id> <vendor>Eclipse Adoptium</vendor> </provides> <configuration> <jdkHome>E:\apps\portable\java\latest\openjdk-17-hotspot</jdkHome> </configuration> </toolchain>
<toolchain> <type>jdk</type> <provides> <version>21.0.2</version> <id>JavaSE-21</id> <vendor>Eclipse Adoptium</vendor> </provides> <configuration> <jdkHome>E:\apps\portable\java\latest\openjdk-21-hotspot</jdkHome> </configuration> </toolchain>
</toolchains> I also tried with Do note that this is a blocker for any project still using JAXB/WS stuff and Java 8 : the maven plugin can't run with Java 17 without some tricks. |
@glhez Is there real error in your build or is it just the annoying log entry? The misguiding log entry should be fixed in the next m2e release with #1637. The toolchain plugin will not be executed in m2e as it is not necessary in eclipse. In the current version of m2e you have to disable the toolchain plugin execution in eclipse builds via lifecycle mapping to get rid of the log entry. Either by XML processing instruction like <?m2e ignore?> (see: New syntax for specifying lifecycle mapping metadata) or by a lifecycle mapping file. |
There is a real error in the build: it won't build. The cause changed from NPE (the toolchains was not provided) to No toolchain found for type jdk: this block the build because jawxs (and compiler) plugin both requires a toolchains that Eclipse won't provide. And I don't know what toolchains Eclipse provide to maven plugin in this context: I did try JavaSE-1.8 ... and it failed too. I did not dig into it too much: I did not check what was the content of generated toolchains (I did not run Eclipse in debug mode) but if you have a way easier than debugging, I can try it. |
Please don't confuse maven toolchains with what you see in eclipse, this is completely independent and m2e does not supply any toolchains to maven at all base on this. As a first step you should enable debugging ( |
That's explain a lot. @G-Ork if you wanted a use case for #1643 , then the one I provided should works. Especially since updating Maven project from Eclipse delete resources (#1511) generated by mwnv: having Eclipse capable of executing jaxws project correctly (with JDK8 and no error :)) will alleviate that. |
By the way I think it was made recently by @mickaelistria the other way round that meven defined toolchains are visible in eclipse but the other way round would be rather confusing as this would mean it works if you run it from eclipse probably but not on commandline/your CI ... So depending on your configuration |
@glhez I've testet your project and it works for me after changing the pom as suggested. Here is what i've changed:
|
That's normal: these are two different use case. There are some plugins incompatible with Java 8 like git-commit-id-maven-plugin: if you use Java 8 with this plugin, you will get:
With enforcer set to Java 17, you won't get this problem because it should execute first.
What the intended purpose of m2e core with toolchains in #1643? If the purpose is to support it, there should not be any I do not really have other working use case of toolchains + other plugin. |
@glhez This issue is closed and was owned by someone else may not like to participate. This discussion hijacked the dead issue. Eclipse is more like a simple texteditor that forks some processes. You do not need toolchain execution in eclipse......... In the next release the execution will be ignored by default. There should be better documentation anyway. I extend the m2e configuration before I debug so deep I understand better. Although the settings are not used in every execution the setting is not useless. Use the PI. It won't hurt your POM. Only necessary till next release. Read the links provided for lifecycle mapping and learn more. For sure helpfull for larger multimodule buids especially when codegen is involved. |
@glhez I think again there is some confusion between different things:
And again you should enable debugging (-X) and version infos (-V) and stack traces (-e) to see whats going on here e.g used maven/java versions and what parameter are used. So far from the side of "running the build from eclipse", now about the suppression and m2e running some mojos as part of the build inside Eclipse, there for technical reasons build is always run with the JVM you start your eclipse with, so if you project does not run on Java 17 it will only work with a limited feature set in the IDE. |
I know how the toolchains works: you use the toolchains plugin to restrict the set of toolchains so that other plugin may use these toolchains. But we are thinking only in terms of Java: the intent for toolchains, although it might be an obscure part of Maven is to provide tools, not JDK tools, but any tools: the frontend-maven-plugin for example supports m2e but does not supports toolchains while it could have requested
This assertion is false: some plugin allow overriding the global toolchains selection, eg: compiler The sole use case I could think about is that you wish to build with older version of Java (< 8) and run test with newer version (8) all by remaining binary compatible with older version;
As long as you use a toolchain, the maven-compiler-plugin will use it: the release option (eg:
You don't have to use debug here, as you can see it right in the logs:
And that is where I could be fairly confused: you are giving me debug options for Maven (-X, -V, -e) but the problem is only inside Eclipse and m2e-core, with the toolchains not being supported. The only way I know to print the existing toolchains is by going into debug mode with the m2e-core Oomph installer and since you said in your previous comment that m2e does not supply any toolchains to maven at all base on this I did not even try.
That's fine by me. |
Then I'm a bit confused about the questions / complains here...
No one here does it, this was brought up by you as you are made a connection between Eclipse configured JREs and maven toolchains (where there is no such connection).
It is not, you are selecting the javac that the compiler plugin is using to compile, but you can't select a jre that is used to execute the compiler plugin itself.
I can see what? That everything worls and a toolchain was found so what is now the exact problem to solve?
I never claimed that, I only said that m2e does not inject / support additional toolchains, for the sole reason that m2e only calls maven and maven do whatever it does if you execute it as a maven build. So what you show here as a screenshot shows the jdk that is used to run maven, it has nothing to do with any tool-chain configuration. |
I never said that. I only mentioned the fact that maven-compiler-plugin use, in order:
And I did a test:
And all "works" (the compilation fails because, well, JAX WS is not really Java 8 compatible without some changes). I don't expect m2e to handle the edgy case: without any I don't think I would want that supported because it would be quite the headache to maintain.
If we speak about the problem I had in Apr 11, 2023, the problem is gone because there are no longer issues with jaxws plugin. If we speak about toolchains, these problems were introduced in 2.2.0 (Mojos without a mapping are now executed by default in incremental builds): toolchains is executed, m2e "provides" an empty toolchains and the plugin execution fails because its lacks expected toolchains and you get an error in the pom.xml Snapshot build seems to ignore this execution by default (probably because of #1637) and that's fine by me: I don't have other use of toolchains. Or they would mean complicated stuff in Maven - which I try to avoid. |
Hello all,
we are using the following Eclipse and m2e-Plugin Version:
Eclipse Version:
Version: 2022-09 (4.25.0)
Build id: 20220908-1902
m2e Plugin:
M2E - Maven Integration for Eclipse 2.0.6.20221012-0544 org.eclipse.m2e.feature.feature.group Eclipse.org - m2e
We are using the Maven toolchain to control the JDK used for the projects. It is working fine with Eclipse 2022-06 but it does not work anymore with the new version.
We think it might be linked to this new tab in the Eclipse preferences:
The JDK version is not controlled via the maven-comiler-plugin configuration, it is controlled via the Maven toolchain on our side.
We have projects configured by the toolchain to be built with JDK11 but when we import such projects in Eclipse then JDK8 is taken.
Do you have the same issue or any recommendation how we can fix this issue?
Thank you!
The text was updated successfully, but these errors were encountered: