Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[m2e-users] m2e - maven 3.5.0 - maven.conf property

I'm preparing a new version of Eclipse-based tools for our organization and have encountered an issue with m2e not being able to find global toolchains configuration with either external Maven 3.5.0 or embedded Maven 3.3.9


Target Toolset:
- Eclipse Oxygen (20170620-1800) 
- m2e 1.8.1.20170728-1531 
- Maven 3.5.0 external installation 
- maven-toolchains-plugin
- Toolchains configuration is to be provided by the distribution in $MAVEN_HOME/conf/toolchains.xml (reason: 300+ developers, don't want to require them to add toolchains.xml to their user configuration)

Issue 1

New in Maven 3.5.0, MavenCli has the following code to determine the default location of the global toolchains plugin: 

link: https://git-wip-us.apache.org/repos/asf?p=maven.git;a=blob_plain;f=maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java;hb=HEAD

public static final File DEFAULT_GLOBAL_TOOLCHAINS_FILE =
    new File( System.getProperty( "maven.conf" ), "toolchains.xml" );

m2e does not appear to set the maven.conf property, and therefore the DEFAULT_GLOBAL_TOOLCHAINS_FILE is not found.


Issue 2

The fallback solution was to use the embedded maven 3.3.9. 

In this case, m2e doesn't set maven.home as I would expect 

There are at least two threads that seem to touch on this issue:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=341120 

https://bugs.eclipse.org/bugs/show_bug.cgi?id=432992 

Without maven.home, the toolchains.xml won't be found by MavenCli.  m2e works around this by setting the -gs maven CLI option to specify the global settings file location. But they don't do the same for -gt to set the global toolchains settings 

Link: https://github.com/eclipse/m2e-core/blob/master/org.eclipse.m2e.launching/src/org/eclipse/m2e/internal/launch/MavenLaunchDelegate.java (around line 233) 


The model with maven toolchains is to clearly separate (a) the JDK used to run the tool (whether it be Maven or Eclipse), from the JDK used to build projects.  In our case, we need to use JDK 8 to run most of our tools because the tools use JDK 8 language features. However, our target environment is limited to JDK 7


Summary - configuration that doesn't find global toolchains.xml

1) external Maven 3.5.0 because of Issue 1

2) embedded Maven 3.3.9 because of Issue 2

Solution that works:

use the external maven 3.3.9 installation. The maven.home gets set correctly by m2e because it's an external installation. And the MavenCli reads maven.home to find the conf folder and ultimately the toolchains.xml file in the conf folder.


For Discussion

I am willing to work on a PR to enable m2e to find global toolchains with Maven 3.5.0. I'd like some guidance on what approach would be most acceptable. 

a) Change MavenLaunchDelegate to process -gt (for toolchains) much the same way that -gs is currently being processed 

b) find the correct location in the code to set property maven.conf prior to invoking MavenCli



Back to the top