Maven
  1. Maven
  2. MNG-3891

Modify maven-toolchain to look in ${maven.home}/conf/toolchains.xml and in ${user.home}/.m2/toolchains.xml

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0.9
    • Fix Version/s: 3.3.1
    • Component/s: Toolchains
    • Labels:
      None

      Description

      Actually, we can only specify the toolchains.xml in ${user.home}/.m2/toolchains.xml.

      However, like for the settings.xml, it would be very convenient to specify a default toolchains.xml in ${maven.home}/conf/toolchains.xml

      The idea is : If there is NO ${user.home}/.m2/toolchains.xml,
      then uses ${maven.home}/conf/toolchains.xml,
      otherwise NONE defined.

      Merging both would also be good but not necessary.

      The change is very simple. Edit the file
      maven-toolchain\src\main\java\org\apache\maven\toolchain\DefaultToolchainManager.java

      and replace

      private PersistedToolchains readToolchainSettings() throws MisconfiguredToolchainException {
          File tch = new File(System.getProperty("user.home"), ".m2/toolchains.xml");
          if (tch.exists()) {
             MavenToolchainsXpp3Reader reader = new MavenToolchainsXpp3Reader();
             ...
      

      by

      private PersistedToolchains readToolchainSettings() throws MisconfiguredToolchainException {
          File tch = null;
          tch = new File(System.getProperty("user.home"), ".m2/toolchains.xml");
          if (tch == null || !tch.exists()) {
              tch = new File(System.getProperty("maven.home"), "conf/toolchains.xml");
          }
      
          if (tch.exists()) {
              MavenToolchainsXpp3Reader reader = new MavenToolchainsXpp3Reader();
              ...
      

      I did that on my local environment by compiling this 2.0.11-SNAPSHOT class and integrating it in my maven-2.0.9-uber.jar and it works perfectly.

        Issue Links

          Activity

          Hide
          John Casey added a comment -

          Consolidating to 2.1.0-M1 so we can then rename to 2.1.0. We can weed out any issues we want to push to a later release from this set once we've done the consolidation.

          Show
          John Casey added a comment - Consolidating to 2.1.0-M1 so we can then rename to 2.1.0. We can weed out any issues we want to push to a later release from this set once we've done the consolidation.
          Hide
          John Casey added a comment -

          This approach would make the toolchains.xml file exceptional when compared to the settings.xml and other files we used to use. In the case of settings.xml, $(maven.home)/conf/settings.xml and $(user.home)/.m2/settings.xml are merged, then used. This is a significantly more involved process.

          Show
          John Casey added a comment - This approach would make the toolchains.xml file exceptional when compared to the settings.xml and other files we used to use. In the case of settings.xml, $(maven.home)/conf/settings.xml and $(user.home)/.m2/settings.xml are merged, then used. This is a significantly more involved process.
          Hide
          Brett Porter added a comment -

          consistency is important on these

          Show
          Brett Porter added a comment - consistency is important on these
          Show
          Jason van Zyl added a comment - Please refer to https://cwiki.apache.org/confluence/display/MAVEN/The+Great+JIRA+Cleanup+of+2014
          Hide
          Jason van Zyl added a comment -

          Please refer to https://cwiki.apache.org/confluence/display/MAVEN/The+Great+JIRA+Cleanup+of+2014 if you're wondering why this issue was closed out.

          Show
          Jason van Zyl added a comment - Please refer to https://cwiki.apache.org/confluence/display/MAVEN/The+Great+JIRA+Cleanup+of+2014 if you're wondering why this issue was closed out.
          Hide
          Robert Scholte added a comment -

          We're slowly pushing forward the runtime JDK requirement for Maven.
          However, we want to keep the users in control if they want to use another (older?) JDK to compile there code with.
          Toolchain is the preferred way, so it will get a more prominent role in future releases of Maven.
          To make it easier to understand how to use it, we want to make it part of the Maven distribution. So it will be better if toolchains will be treated the same as the settings.xml, so for that reason this issue will be reopened.

          Show
          Robert Scholte added a comment - We're slowly pushing forward the runtime JDK requirement for Maven. However, we want to keep the users in control if they want to use another (older?) JDK to compile there code with. Toolchain is the preferred way, so it will get a more prominent role in future releases of Maven. To make it easier to understand how to use it, we want to make it part of the Maven distribution. So it will be better if toolchains will be treated the same as the settings.xml , so for that reason this issue will be reopened.
          Hide
          Robert Scholte added a comment -
          Show
          Robert Scholte added a comment - Fixed in ceae922653e7bf4bd1013e01d0f8deae7443744c

            People

            • Assignee:
              Robert Scholte
              Reporter:
              Marco Lessard
            • Votes:
              5 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development