Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-42302

maven-shade-plugin uses a temporary project file "dependency-reduced-pom.xml" that is deleted when "withMaven()" collects the artifacts

      maven-shade-plugin uses a temporary project file "dependency-reduced-pom.xml" instead of "pom.xml" and deletes this temporary file "dependency-reduced-pom.xml" at the end of the build.

      When withMaven() processes the build report, the file basedir/dependency-reduced-pom.xml no longer exist.

      https://github.com/apache/maven-plugins/blob/3964d2a2c3b5d2c3b73b8685755e772cfabeea40/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java

      public class ShadeMojo extends AbstractMojo implements Contextualizable {
          /**
           * Flag whether to generate a simplified POM for the shaded artifact. If set to <code>true</code>, dependencies that
           * have been included into the uber JAR will be removed from the <code>&lt;dependencies&gt;</code> section of the
           * generated POM. The reduced POM will be named <code>dependency-reduced-pom.xml</code> and is stored into the same
           * directory as the shaded artifact. Unless you also specify dependencyReducedPomLocation, the plugin will create a
           * temporary file named <code>dependency-reduced-pom.xml</code> in the project basedir.
           */
          @Parameter( defaultValue = "true" )
          private boolean createDependencyReducedPom;
      
          /**
           * Where to put the dependency reduced pom. Note: setting a value for this parameter with a directory other than
           * ${basedir} will change the value of ${basedir} for all executions that come after the shade execution. This is
           * often not what you want. This is considered an open issue with this plugin.
           *
           * @since 1.7
           */
          @Parameter( defaultValue = "${basedir}/dependency-reduced-pom.xml" )
          private File dependencyReducedPomLocation;
      
      

          [JENKINS-42302] maven-shade-plugin uses a temporary project file "dependency-reduced-pom.xml" that is deleted when "withMaven()" collects the artifacts

          Code changed in jenkins
          User: Cyrille Le Clerc
          Path:
          maven-spy/src/main/java/org/jenkinsci/plugins/pipeline/maven/eventspy/handler/AbstractMavenEventHandler.java
          http://jenkins-ci.org/commit/pipeline-maven-plugin/510a7d0e43349b8e930194636742f8a225c08bad
          Log:
          JENKINS-42302 tweak Maven project file handling in case of maven-shade-plugin usage.

          Ignore temporary project file "dependency-reduced-pom.xml" and use "pom.xml”.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Cyrille Le Clerc Path: maven-spy/src/main/java/org/jenkinsci/plugins/pipeline/maven/eventspy/handler/AbstractMavenEventHandler.java http://jenkins-ci.org/commit/pipeline-maven-plugin/510a7d0e43349b8e930194636742f8a225c08bad Log: JENKINS-42302 tweak Maven project file handling in case of maven-shade-plugin usage. Ignore temporary project file "dependency-reduced-pom.xml" and use "pom.xml”.

          Code changed in jenkins
          User: Cyrille Le Clerc
          Path:
          maven-spy/src/main/java/org/jenkinsci/plugins/pipeline/maven/eventspy/handler/AbstractMavenEventHandler.java
          http://jenkins-ci.org/commit/pipeline-maven-plugin/31794f864e364dda20e09ffb9c286309ca772eb2
          Log:
          Merge pull request #23 from cyrille-leclerc/JENKINS-42302

          JENKINS-42302 Tweak Maven project file handling in case of maven-shade-plugin usage.

          Compare: https://github.com/jenkinsci/pipeline-maven-plugin/compare/d224f6bdc9f0...31794f864e36

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Cyrille Le Clerc Path: maven-spy/src/main/java/org/jenkinsci/plugins/pipeline/maven/eventspy/handler/AbstractMavenEventHandler.java http://jenkins-ci.org/commit/pipeline-maven-plugin/31794f864e364dda20e09ffb9c286309ca772eb2 Log: Merge pull request #23 from cyrille-leclerc/ JENKINS-42302 JENKINS-42302 Tweak Maven project file handling in case of maven-shade-plugin usage. Compare: https://github.com/jenkinsci/pipeline-maven-plugin/compare/d224f6bdc9f0...31794f864e36

          "hack" introduced in the code:

          https://github.com/jenkinsci/pipeline-maven-plugin/commit/510a7d0e43349b8e930194636742f8a225c08bad

          File projectFile = project.getFile();
          String absolutePath = projectFile.getAbsolutePath();
          if (absolutePath.endsWith("/pom.xml")) {
              // no tweak
          } else if (absolutePath.endsWith("/dependency-reduced-pom.xml")) {
              // JENKINS-42302: maven-shade-plugin creates a temporary project file dependency-reduced-pom.xml
              // TODO see if there is a better way to implement this "workaround"
              absolutePath = absolutePath.replace("/dependency-reduced-pom.xml", "/pom.xml");
          } else {
              System.out.println("[jenkins-maven-event-spy] WARNING: unexpected Maven project file name '"
                      + projectFile.getName() + "', problems may occur");
          }
          projectElt.setAttribute("file", absolutePath);
          

          Cyrille Le Clerc added a comment - "hack" introduced in the code: https://github.com/jenkinsci/pipeline-maven-plugin/commit/510a7d0e43349b8e930194636742f8a225c08bad File projectFile = project.getFile(); String absolutePath = projectFile.getAbsolutePath(); if (absolutePath.endsWith( "/pom.xml" )) { // no tweak } else if (absolutePath.endsWith( "/dependency-reduced-pom.xml" )) { // JENKINS-42302: maven-shade-plugin creates a temporary project file dependency-reduced-pom.xml // TODO see if there is a better way to implement this "workaround" absolutePath = absolutePath.replace( "/dependency-reduced-pom.xml" , "/pom.xml" ); } else { System .out.println( "[jenkins-maven-event-spy] WARNING: unexpected Maven project file name '" + projectFile.getName() + "', problems may occur" ); } projectElt.setAttribute( "file" , absolutePath);

            cleclerc Cyrille Le Clerc
            cleclerc Cyrille Le Clerc
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: