Maven WAR Plugin
  1. Maven WAR Plugin
  2. MWAR-82

setting archiveClasses to true create the jar in WEB-INF/lib but does not remove WEB-INF/classes

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Cannot Reproduce
    • Affects Version/s: 2.0
    • Fix Version/s: 2.0.1
    • Component/s: None
    • Labels:
      None
    • Number of attachments :
      0

      Description

      This bug has been explained on the maven users mailing list:

      Hi Sebastien
      It seems to be a bug.
      In the code [1] we have :
      if ( archiveClasses )

      { createJarArchive( libDirectory ); }

      else

      { copyDirectoryStructureIfModified( classesDirectory, webappClassesDirectory ); }

      The content of the classes directory is never removed (neither in createJarArchive nor somewhere else).

      Can you create an issue please ?

      Thx

      Arnaud

      [1]
      http://svn.apache.org/viewvc/maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/AbstractWarMojo.java?revision=471624

      Sebastien Brunot wrote:
      >
      > Hi all,
      >
      > i've got a war project which pom build section contains the following
      > statements:
      >
      > <!-- Package webapp classes into a jar instead of under
      > WEB-INF/classes -->
      > <plugin>
      > <groupId>org.apache.maven.plugins</groupId>
      > <artifactId>maven-war-plugin</artifactId>
      > <executions>
      > <execution>
      > <goals>
      > <goal>war</goal>
      > </goals>
      > <configuration>
      > <archiveClasses>true</archiveClasses>
      > </configuration>
      > </execution>
      > </executions>
      > </plugin>
      >
      > As a result, all the classes and resources from my war project are
      > packaged in a jar that is copied in the WEB-INF/lib directory of the
      > war artifact.
      >
      > But i don't understand why the war artifact still contains copy of the
      > classes and resources under WEB-INF/classes... Does anybody think that
      > i've misconfigured the war plugin ?
      >
      > Thanks for your help,
      >
      > Sebastien
      >
      >


      View this message in context: http://www.nabble.com/Configuring-war-plugin-for-using-a-jar-instead-of-WEB-INF-classes-tf2589199s177.html#a7219855
      Sent from the Maven - Users mailing list archive at Nabble.com.

      ---------------------------------------------------------------------
      To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
      For additional commands, e-mail: users-help@maven.apache.org

        Activity

        Hide
        Piotr Tabor added a comment -

        What commands have you been using to generate your war ?

        I have an idea that the scenario was:

        " <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
        <configuration>
        <archiveClasses>false</archiveClasses><!-or missing->
        </configuration>
        </execution>
        </executions>
        </plugin>"

        then:
        mvn package

        after that user changed in pom.xml to: <archiveClasses>true</archiveClasses>

        then:
        mvn package

        In effect the final zzz.war constains both: classes and zzz.jar.

        It is reason of the target/zzz directory, which constains zzz classes ofter first "mvn package",
        and zzz.jar after the second "mvn package".

        Instead the second "mvn package" the user should use "mvn clean package", to run the
        war plugin on an empty target/zzz dir.

        If the scenario is true - I think that this issue is not a bug.

        Show
        Piotr Tabor added a comment - What commands have you been using to generate your war ? I have an idea that the scenario was: " <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <configuration> <archiveClasses>false</archiveClasses><!- or missing -> </configuration> </execution> </executions> </plugin>" then: mvn package after that user changed in pom.xml to: <archiveClasses>true</archiveClasses> then: mvn package In effect the final zzz.war constains both: classes and zzz.jar. It is reason of the target/zzz directory, which constains zzz classes ofter first "mvn package", and zzz.jar after the second "mvn package". Instead the second "mvn package" the user should use "mvn clean package", to run the war plugin on an empty target/zzz dir. If the scenario is true - I think that this issue is not a bug.
        Hide
        Stéphane Nicoll added a comment -

        Piotr is right, it's not a bug. Behavior runs as expected if you're starting from a clean build.

        Show
        Stéphane Nicoll added a comment - Piotr is right, it's not a bug. Behavior runs as expected if you're starting from a clean build.
        Hide
        Zecas added a comment - - edited

        Hi,

        I came across this issue, and I'm having the same problem.

        My pom.xml settings:
        <build>
        <outputDirectory>WebContent/WEB-INF/classes</outputDirectory>
        <plugins>
        <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
        <version>2.0.1</version>
        <executions>
        <goal>explode</goal>
        </executions>
        <configuration>
        <archiveClasses>true</archiveClasses>
        <dependentWarIncludes>
        */resources/.*
        </dependentWarIncludes>
        <webResources>
        <resource>
        <!-- this is relative to the pom.xml directory -->
        <directory>$

        {basedir}

        /WebContent</directory>
        </resource>
        </webResources>
        </configuration>
        </plugin>
        </plugins>
        </build>

        It creates a jar file inside the WEB-INF\lib folder, but doesn't remove classes from WEB-INF\classes folder.

        I've tried a clean build:
        mvn clean
        and then to be sure:
        mvn clean package

        Any workaround?

        Show
        Zecas added a comment - - edited Hi, I came across this issue, and I'm having the same problem. My pom.xml settings: <build> <outputDirectory>WebContent/WEB-INF/classes</outputDirectory> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <version>2.0.1</version> <executions> <goal>explode</goal> </executions> <configuration> <archiveClasses>true</archiveClasses> <dependentWarIncludes> * /resources/ .* </dependentWarIncludes> <webResources> <resource> <!-- this is relative to the pom.xml directory --> <directory>$ {basedir} /WebContent</directory> </resource> </webResources> </configuration> </plugin> </plugins> </build> It creates a jar file inside the WEB-INF\lib folder, but doesn't remove classes from WEB-INF\classes folder. I've tried a clean build: mvn clean and then to be sure: mvn clean package Any workaround?
        Hide
        Taras Lipatov added a comment -

        Still getting this....
        mvn 2.0.9
        war 2.0

        Any one out there on the same boat?

        Show
        Taras Lipatov added a comment - Still getting this.... mvn 2.0.9 war 2.0 Any one out there on the same boat?
        Hide
        Wendy Smoak added a comment - - edited

        Comment edited: 2.0 does not have the <archiveClasses> feature, and I can't reproduce the problem of getting both WEB-INF/classes and WEB-INF/lib in any version.

        With 2.0 - files in WEB-INF/classes, nothing in WEB-INF/lib

             0 Thu Oct 16 08:11:56 MST 2008 META-INF/
           221 Thu Oct 16 08:11:54 MST 2008 META-INF/MANIFEST.MF
             0 Thu Oct 16 08:11:56 MST 2008 WEB-INF/
             0 Thu Oct 16 08:11:56 MST 2008 WEB-INF/classes/
             0 Thu Oct 16 08:11:56 MST 2008 WEB-INF/classes/net/
             0 Thu Oct 16 08:11:56 MST 2008 WEB-INF/classes/net/wsmoak/
            52 Thu Oct 16 08:11:56 MST 2008 index.jsp
           535 Thu Oct 16 08:11:56 MST 2008 WEB-INF/classes/net/wsmoak/App.class
           215 Thu Oct 16 08:11:56 MST 2008 WEB-INF/web.xml
             0 Thu Oct 16 08:11:56 MST 2008 META-INF/maven/
             0 Thu Oct 16 08:11:56 MST 2008 META-INF/maven/com.example/
             0 Thu Oct 16 08:11:56 MST 2008 META-INF/maven/com.example/mywebapp/
           946 Thu Oct 16 08:11:50 MST 2008 META-INF/maven/com.example/mywebapp/pom.xml
           111 Thu Oct 16 08:11:56 MST 2008 META-INF/maven/com.example/mywebapp/pom.properties
        

        With 2.0.1, 2.1-alpha-2 - jar in WEB-INF/lib, nothing in WEB-INF/classes

             0 Thu Oct 16 08:12:48 MST 2008 META-INF/
           125 Thu Oct 16 08:12:46 MST 2008 META-INF/MANIFEST.MF
             0 Thu Oct 16 08:12:46 MST 2008 WEB-INF/
             0 Thu Oct 16 08:12:46 MST 2008 WEB-INF/lib/
            52 Thu Oct 16 08:02:02 MST 2008 index.jsp
          2208 Thu Oct 16 08:12:46 MST 2008 WEB-INF/lib/mywebapp.jar
           215 Thu Oct 16 08:02:02 MST 2008 WEB-INF/web.xml
             0 Thu Oct 16 08:12:48 MST 2008 META-INF/maven/
             0 Thu Oct 16 08:12:48 MST 2008 META-INF/maven/com.example/
             0 Thu Oct 16 08:12:48 MST 2008 META-INF/maven/com.example/mywebapp/
           948 Thu Oct 16 08:12:40 MST 2008 META-INF/maven/com.example/mywebapp/pom.xml
           111 Thu Oct 16 08:12:46 MST 2008 META-INF/maven/com.example/mywebapp/pom.properties
        
        Show
        Wendy Smoak added a comment - - edited Comment edited: 2.0 does not have the <archiveClasses> feature, and I can't reproduce the problem of getting both WEB-INF/classes and WEB-INF/lib in any version. With 2.0 - files in WEB-INF/classes, nothing in WEB-INF/lib 0 Thu Oct 16 08:11:56 MST 2008 META-INF/ 221 Thu Oct 16 08:11:54 MST 2008 META-INF/MANIFEST.MF 0 Thu Oct 16 08:11:56 MST 2008 WEB-INF/ 0 Thu Oct 16 08:11:56 MST 2008 WEB-INF/classes/ 0 Thu Oct 16 08:11:56 MST 2008 WEB-INF/classes/net/ 0 Thu Oct 16 08:11:56 MST 2008 WEB-INF/classes/net/wsmoak/ 52 Thu Oct 16 08:11:56 MST 2008 index.jsp 535 Thu Oct 16 08:11:56 MST 2008 WEB-INF/classes/net/wsmoak/App.class 215 Thu Oct 16 08:11:56 MST 2008 WEB-INF/web.xml 0 Thu Oct 16 08:11:56 MST 2008 META-INF/maven/ 0 Thu Oct 16 08:11:56 MST 2008 META-INF/maven/com.example/ 0 Thu Oct 16 08:11:56 MST 2008 META-INF/maven/com.example/mywebapp/ 946 Thu Oct 16 08:11:50 MST 2008 META-INF/maven/com.example/mywebapp/pom.xml 111 Thu Oct 16 08:11:56 MST 2008 META-INF/maven/com.example/mywebapp/pom.properties With 2.0.1, 2.1-alpha-2 - jar in WEB-INF/lib, nothing in WEB-INF/classes 0 Thu Oct 16 08:12:48 MST 2008 META-INF/ 125 Thu Oct 16 08:12:46 MST 2008 META-INF/MANIFEST.MF 0 Thu Oct 16 08:12:46 MST 2008 WEB-INF/ 0 Thu Oct 16 08:12:46 MST 2008 WEB-INF/lib/ 52 Thu Oct 16 08:02:02 MST 2008 index.jsp 2208 Thu Oct 16 08:12:46 MST 2008 WEB-INF/lib/mywebapp.jar 215 Thu Oct 16 08:02:02 MST 2008 WEB-INF/web.xml 0 Thu Oct 16 08:12:48 MST 2008 META-INF/maven/ 0 Thu Oct 16 08:12:48 MST 2008 META-INF/maven/com.example/ 0 Thu Oct 16 08:12:48 MST 2008 META-INF/maven/com.example/mywebapp/ 948 Thu Oct 16 08:12:40 MST 2008 META-INF/maven/com.example/mywebapp/pom.xml 111 Thu Oct 16 08:12:46 MST 2008 META-INF/maven/com.example/mywebapp/pom.properties
        Hide
        John Baker added a comment -

        Hello,

        This bug still seems to exist in this version of the war task:

        [DEBUG] Retrieving parent-POM: org.apache.maven.plugins:maven-plugins:pom:13 for project: null:maven-war-plugin:maven-plugin:2.1-beta-1 from the repository.

        I have defined:

        <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
        <executions><execution>
        <goals>
        <goal>war</goal>
        </goals>
        <configuration>
        <archiveClasses>true</archiveClasses>
        </configuration>
        </execution></executions>
        </plugin>

        In my pom and run mvn clean package. I see the classes and the jar file in WEB-INF/lib.

        Would be great so solve this issue so if someone wants to get in touch then I'm happy to help where I can.

        Show
        John Baker added a comment - Hello, This bug still seems to exist in this version of the war task: [DEBUG] Retrieving parent-POM: org.apache.maven.plugins:maven-plugins:pom:13 for project: null:maven-war-plugin:maven-plugin:2.1-beta-1 from the repository. I have defined: <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <executions><execution> <goals> <goal>war</goal> </goals> <configuration> <archiveClasses>true</archiveClasses> </configuration> </execution></executions> </plugin> In my pom and run mvn clean package. I see the classes and the jar file in WEB-INF/lib. Would be great so solve this issue so if someone wants to get in touch then I'm happy to help where I can.
        Hide
        John Baker added a comment -

        Hello,

        Also, I would expect this to work when the exploded goal is included, but in this instance, the task does not even create the jar file.

        I've looked at the source:

        http://svn.apache.org/viewvc/maven/plugins/tags/maven-war-plugin-2.1-beta-1/src/main/java/org/apache/maven/plugin/war/packaging/ClassesPackagingTask.java?revision=754916&view=markup

        (I know nothing about task development for maven) and I can't see any obvious code that would remove/mask the classes.

        John

        Show
        John Baker added a comment - Hello, Also, I would expect this to work when the exploded goal is included, but in this instance, the task does not even create the jar file. I've looked at the source: http://svn.apache.org/viewvc/maven/plugins/tags/maven-war-plugin-2.1-beta-1/src/main/java/org/apache/maven/plugin/war/packaging/ClassesPackagingTask.java?revision=754916&view=markup (I know nothing about task development for maven) and I can't see any obvious code that would remove/mask the classes. John

          People

          • Assignee:
            Stéphane Nicoll
            Reporter:
            Sebastien Brunot
          • Votes:
            2 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: