[
https://issues.apache.org/jira/browse/MWAR-355?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14732372#comment-14732372
]
Karl Heinz Marbaise commented on MWAR-355:
------------------------------------------
The first thing is you should move the plain configuration into a
{{pluginManagement}} [block like
this|https://github.com/khmarbaise/so-questions/tree/master/so-5]:
{code:xml}
<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<archiveClasses>true</archiveClasses>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
{code}
If you do the above the classes will be created within the war archive by
using: {{mvn clean compile war:war}}
{code}
~/ws-git/so-questions/so-5 (master)$ unzip -t target/web-1.0.0-SNAPSHOT.war
Archive: target/web-1.0.0-SNAPSHOT.war
testing: META-INF/ OK
testing: META-INF/MANIFEST.MF OK
testing: WEB-INF/ OK
testing: WEB-INF/classes/ OK
testing: WEB-INF/lib/ OK
testing: WEB-INF/lib/commons-fileupload-1.1.1.jar OK
testing: WEB-INF/lib/commons-io-1.1.jar OK
testing: WEB-INF/lib/web-1.0.0-SNAPSHOT.jar OK
testing: WEB-INF/web.xml OK
testing: META-INF/maven/com.soebes.examples.so/web/pom.xml OK
testing: META-INF/maven/com.soebes.examples.so/web/pom.properties OK
testing: META-INF/INDEX.LIST OK
No errors detected in compressed data of target/web-1.0.0-SNAPSHOT.war.
{code}
This will also working for your call {{mvn clean compile war:exploded}}.
{noformat}
└── web-1.0.0-SNAPSHOT
├── META-INF
└── WEB-INF
├── classes
├── lib
│ ├── commons-fileupload-1.1.1.jar
│ ├── commons-io-1.1.jar
│ └── web-1.0.0-SNAPSHOT.jar
└── web.xml
{noformat}
The reason for this behaviour is simply cause by using a goal like {{war:war}},
or {{war:exploded}} instead of the life cycle which means the configuration in
the pom is not taken into account. If you like having a configuration for your
command line calls you can do this by using a special configuration for calls
on command line:
{code:xml}
<build>
<plugins>
<plugin>
<groupId...>
<artifactId...>
<executions>
<execution>
<id>default-cli</id>
<configuration>
.....
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
which means having a special configuration for command line calls. Starting
with Maven 3.3.1 it is possible having many configuration for command line
calls by using it like:
{code:xml}
<project...>
<build>
<plugins>
<plugin>
<groupId>...</groupId>
<artifactId>...</artifactId>
<executions>
<execution>
<id>first-cli</id>
<configuration>
....
</configuration>
</execution>
<execution>
<id>second-cli</id>
<configuration>
....
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
{code}
This can be used by maven via the following:
{noformat}
mvn plugin:goal@second-cli
mvn plugin:goal@first-cli
{noformat}
See also the [release notes for Maven
3.3.1|http://blog.soebes.de/blog/2015/03/17/apache-maven-3-dot-3-1-features/]....
> <archiveClasses> ignored
> ------------------------
>
> Key: MWAR-355
> URL: https://issues.apache.org/jira/browse/MWAR-355
> Project: Maven WAR Plugin
> Issue Type: Bug
> Affects Versions: 2.6
> Environment: Maven 3.3.3, Debian Jetty
> Reporter: Dominykas Mostauskis
> Priority: Blocker
>
> Given this plugin configuration:
> ...
> <plugin>
> <artifactId>maven-war-plugin</artifactId>
> <version>2.6</version>
> <configuration>
> <archiveClasses>true</archiveClasses>
> </configuration>
> </plugin>
> ...
> The <archiveClasses> option has no effect.
> Running `mvn clean compile war:exploded` produces a war directory with .class
> files in the `classes` directory, and they are not archived into a jar in the
> `lib` directory neither. `war:war` produces same result.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)