Uploaded image for project: 'Maven'
  1. Maven
  2. MNG-7204

Maven might pick up the wrong configuration when the plugin happens to include relocation information

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Duplicate
    • 3.6.1, 3.8.1
    • None
    • None
    • None

    Description

      Issue Description

      The relocation process is outlined in here and IMHO boils down to adding the relocation information into the distributionManagement.

      For the sake of experimenting assume we want to relocate a plugin from

          <groupId>com.example.plugins</groupId>
          <artifactId>test-plugin</artifactId>
      

      to

          <groupId>com.test.plugins</groupId>
          <artifactId>test-plugin-enhanced</artifactId>
      

      To visualize the issue the plugin needs one configuration parameter (let's call it helloString). Based on the relocation guide my understanding is that we need two publications. One under the old coordinates and one under the new coordinates.

      When invoking the plugin with the old coordinates it will *not* pickup our configuration supplied. Consider:

      <groupId>com.example.plugins</groupId>
      <artifactId>test-plugin</artifactId>
      <version>0.0.1</version>
      <configuration>
      	<helloString>from Maven!</helloString>
      </configuration>
      

      Issue Reproducer

      Attached I have an example that consists of essentially two parts. On a high level my understanding is that the the publication under the "old" coordinates can have a jar ("01_project_old_coordinates_with_jar"), but doesn't need to have one which would then essentially be a relocation pom ("01_project_old_coordinates_without_jar").

      The project publication with jar allows to see the expected by running

      cd 01_project_old_coordinates_with_jar
      mvn clean install
      mvn clean package -Pdemo
      

      which outputs Hello from Maven! (since this is the setting configured in the pom).

      When the relocation is done ("02_project_new_coordinates") and a new version under the new coordinates is published (but one still points to the old configuration) the configuration will not be picked up.

      cd 02_project_new_coordinates
      # install the SAME version under new coordinates
      mvn clean install
      # run the demo again which still points to the OLD config
      mvn clean package -Pdemo
      

      which output Hello World!. World is the default encoded in the Mojo, but *not* what was provided to the plugin config!

      This issue can also be observed when the publication under the old coordinates is just a relocation pom.

      Reproducible under

      $ mvn --version
      Apache Maven 3.6.1 (d66c9c0b3152b2e69ee9bac180bb8fcc8e6af555; 2019-04-04T21:00:29+02:00)
      Maven home: /usr/share/maven-3.6.1
      Java version: 11.0.11, vendor: Oracle Corporation, runtime: /usr/lib/jvm/java-11-oracle
      Default locale: en_US, platform encoding: UTF-8
      OS name: "linux", version: "5.4.0-77-generic", arch: "amd64", family: "unix"
      
      $ mvn --version
      Apache Maven 3.8.1 (05c21c65bdfed0f71a2f2ada8b84da59348c4c5d)
      Maven home: /usr/share/maven-3.8.1
      Java version: 11.0.11, vendor: Oracle Corporation, runtime: /usr/lib/jvm/java-11-oracle
      Default locale: en_US, platform encoding: UTF-8
      OS name: "linux", version: "5.4.0-77-generic", arch: "amd64", family: "unix"
      

      Potentially many other versions.

      Attachments

        1. screenshot-1.png
          48 kB
          Michael Osipov
        2. MNG-7204.zip
          9 kB
          S L

        Issue Links

          Activity

            People

              michael-o Michael Osipov
              TheSnoozer S L
              Votes:
              2 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: