Maven Shade Plugin
  1. Maven Shade Plugin
  2. MSHADE-75

Package maven multimodule project with shade plugin : error in opening zip on directory

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.3.1
    • Fix Version/s: 1.7
    • Labels:
    • Environment:
      Ubuntu 9.04 - Jaunty Jackalope -, Eclispse (Galileo), java 1.6.0_16
    • Patch Submitted:
      Yes
    • Number of attachments :
      2

      Description

      Hello,

      I make a maven aggregator project with two modules.
      The first module is a dependency of the second.
      The first module is build with the install goal.
      The second with the shade plugin during the package phase.
      The first module build runs successfully and install resulting jar file in the maven local repository.
      The second module build fails with this error :

      [INFO] ------------------------------------------------------------------------
      [ERROR] BUILD ERROR
      [INFO] ------------------------------------------------------------------------
      [INFO] Error creating shaded jar: error in opening zip file /home/yoann/workspace/maven.1265640716107/trunk/tcx-ws-client/module1/target/classes
      
      [INFO] ------------------------------------------------------------------------
      [INFO] For more information, run Maven with the -e switch
      [INFO] ------------------------------------------------------------------------
      [INFO] Total time: 10 seconds
      [INFO] Finished at: Fri Feb 12 10:39:29 CET 2010
      [INFO] Final Memory: 59M/583M
      [INFO] ------------------------------------------------------------------------

      It's due to the shade plugin whose tries to reference first module classes from target/classes repository instead of the jar file previously build.
      Therefore, it seems that the shade plugin doesn't work with a maven multimodules project.

      I manage to build my maven aggregator project by applying the attached patch (patch-maven-shade-plugin.txt) on the class ShadeMojo.java

      1. patch-maven-shade-plugin.txt
        1 kB
        Yoann Yonnet
      2. pom.xml
        0.9 kB
        Stephanos Piperoglou

        Issue Links

          Activity

          Hide
          Stephanos Piperoglou added a comment -

          Specifically, the error arises when the maevn-jar-plugin has a classifier in its configuration.

          Show
          Stephanos Piperoglou added a comment - Specifically, the error arises when the maevn-jar-plugin has a classifier in its configuration.
          Hide
          Benson Margulies added a comment - - edited

          This is not a fix for the problem at hand. The patch doesn't change the behavior at all, it would apply to a case where a declared dependency had a classifier, and the fix would never work, either.

          Show
          Benson Margulies added a comment - - edited This is not a fix for the problem at hand. The patch doesn't change the behavior at all, it would apply to a case where a declared dependency had a classifier, and the fix would never work, either.
          Hide
          Benson Margulies added a comment -

          I claim that this case should not work, but it could 'not work' more politely.

          What you've done is disrupt the production of the project's main artifact. By adding a classifier to the default execution of the jar plugin, you've made the jar plugin create an attached artifact instead of the main 'jar' artifact. This leaves the project 'naked' and no longer producing a jar, and so shade is flummoxed. Arguably, this case should produce a diagnostic like the diagnostic for non-jar projects, and that's what I'm going to make it do. Then, I believe that you could exclude the project's main artifact from shade and ask for the classified one instead.

          Show
          Benson Margulies added a comment - I claim that this case should not work, but it could 'not work' more politely. What you've done is disrupt the production of the project's main artifact. By adding a classifier to the default execution of the jar plugin, you've made the jar plugin create an attached artifact instead of the main 'jar' artifact. This leaves the project 'naked' and no longer producing a jar, and so shade is flummoxed. Arguably, this case should produce a diagnostic like the diagnostic for non-jar projects, and that's what I'm going to make it do. Then, I believe that you could exclude the project's main artifact from shade and ask for the classified one instead.
          Hide
          Benson Margulies added a comment -

          Proper diagnosis added.

          Show
          Benson Margulies added a comment - Proper diagnosis added.
          Hide
          Benson Margulies added a comment -

          r1343119 | bimargulies | 2012-05-27 20:52:20 -0400 (Sun, 27 May 2012) | 3 lines

          MSHADE-75: Package maven multimodule project with shade plugin : error in opening zip on directory
          o detect and diagnose missing jar main artifact.

          ------------------------------------------------------------------------

          ------------------------------------------------------------------------
          r1343121 | bimargulies | 2012-05-27 21:01:53 -0400 (Sun, 27 May 2012) | 3 lines

          MSHADE-75: Package maven multimodule project with shade plugin : error in opening zip on directory
          o this was a dumb error in the work on -75 that I misattributed briefly.

          ------------------------------------------------------------------------

          Show
          Benson Margulies added a comment - r1343119 | bimargulies | 2012-05-27 20:52:20 -0400 (Sun, 27 May 2012) | 3 lines MSHADE-75 : Package maven multimodule project with shade plugin : error in opening zip on directory o detect and diagnose missing jar main artifact. ------------------------------------------------------------------------ ------------------------------------------------------------------------ r1343121 | bimargulies | 2012-05-27 21:01:53 -0400 (Sun, 27 May 2012) | 3 lines MSHADE-75 : Package maven multimodule project with shade plugin : error in opening zip on directory o this was a dumb error in the work on -75 that I misattributed briefly. ------------------------------------------------------------------------

            People

            • Assignee:
              Benson Margulies
              Reporter:
              Yoann Yonnet
            • Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: