-
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
m2e and toolchain #1588
Comments
I found a solution, which solves my problem - yet it seems like a bug. Adding a lifecylemetadata-entry to the configuration of m2e resolves the issue:
|
@tschoellhorn thanks for providing the snippet, where exactly did you add it? I tried adding it in |
I added it at the same level as you. The weird thing is that you can build the project directyl with mvn / mvnw - but the integration is the problem. Maybe you still have another version of the maven-toolchains-plugin? And it might be worth a try that you click on the hint which Eclipse shows in your pom. There you might be able to add this snippet directly from the hint. Sorry, that I could not be of more help. |
Glad you found a solution. Btw. you could also use the processing-instrucction based approache as it is documented here: I haven't looked in detail into your problem, but to be able to do that a minimal reproducer project would be good. |
I have tried the solution and using the xml processing instructions for the lifecycle mapping do not work for me at all. The problem is not the execution of the plugin. You ca see from the stack-trace above that it is executed. The maven-toolchains-plugin is just a simple plugin to read the project desired toolchain and match it against the known toolchains (in moste cases ~/.m2/toolchains.xml) and select one. If no matching definition is found it logs the message similar to this: Cannot find matching toolchain definitions for the following toolchain types: jdk [ version='11' ] The problem is the initialization of the known toolchains. Here some Links to understand the problem:
As you can see someone reinvented the wheel of loading the configuration and missing essential parts. |
I have to admit that I was wrong. The toolchains plugin execution is in most cases not necessary in eclipse m2e build context. The m2e launcher configures the project correctly. So Ignoring the toolchains plug within eclipse is a solution and works in most cases: Example<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-toolchains-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<?m2e ignore?>
<goals>
<goal>toolchain</goal>
</goals>
</execution>
</executions>
<configuration>
<toolchains>
<jdk>
<version>${maven.compiler.target}</version>
</jdk>
</toolchains>
</configuration>
</plugin> |
I've created a PR #1638 to ignore the plugin by default within m2e. |
There is indeed some duplication, but that's not someone wanted to reinvent something, but because there are (unfortunately) differences in Maven executed in the CLI and in the IDE. If you have specific suggestions how we can reuse existing code, a PR is of course welcome. :) Anyway, I think we can consider this fixed with |
Hi,
a few days ago I have installed Eclipse 2023-09 (4.29.0) on Windows with which uses m2 2.4.100.20230827-1557.
Now I have problems with an imported multi-module maven project using the maven-tool-chains-plugin. In the sub-modules errors are shown. Compilation with my integrated maven wrapper (same version as in Eclipse) work fine.
The errors suggest, that the toolchain.xml-file could not be successfully resolved - yet in other projects the more or less same setup works.
So, is this a user error or a bug? Is there something I can do to prevent this problem in my version?
Cheers,
Tino
The stack-traces go like this:
The text was updated successfully, but these errors were encountered: