You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Da...@stchome.com on 2005/11/01 22:23:28 UTC

[M2] merging war files




I just thought I would share with everyone our solution to merging war
files (special thanks goes out to Roland Bali for the
dependency-copier-plugin).  Note that there is no auto-merging of the
web.xml as we didn't have a necessity for that.

Basically I setup the war I need as a dependency, then during the packaging
phase I explode the project war into a new directory, then explode the
dependency war into that directory as well (noting that overwrite=false so
that web.xml isn't modified).

Then just war up that directory and you now have a merged war.

Things to keep in mind:

1.  Thought must be placed in file naming conventions, as files of the same
name will not get copied from the dependent war file
2.  The web.xml of the base project has no need to be overwritten.  Since
you already know ahead of time which wars this project will be dependent
on, you can setup the web.xml to include all configurations for each
dependant war.

Hope this helps some folks out there..

<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>com.stchome.maven.parent</groupId>
    <artifactId>war</artifactId>
    <version>1.0-SNAPSHOT</version>
  </parent>
  <groupId>com.stchome.shared</groupId>
  <artifactId>test-webapp</artifactId>
  <packaging>war</packaging>
  <version>1.0-SNAPSHOT</version>
  <name>Maven Webapp Archetype</name>
  <url>http://maven.apache.org</url>
  <dependencies>
    <dependency>
      <groupId>com.stchome.shared</groupId>
      <artifactId>supplementaldata-ui</artifactId>
      <version>1.0-SNAPSHOT</version>
      <scope>compile</scope>
      <type>war</type>
    </dependency>
  </dependencies>
  <build>
    <finalName>test-webapp</finalName>
    <plugins>
      <plugin>
        <artifactId>maven-antrun-plugin</artifactId>
        <executions>
          <execution>
            <phase>package</phase>
            <configuration>
              <tasks>
                <mkdir dir="./target/test-webapp-exploded"/>
                <unwar src="./target/test-webapp.war"
dest="./target/test-webapp-exploded" overwrite="true"/>
                <unwar src="./target/supplementaldata-ui-1.0-SNAPSHOT.war"
dest="./target/test-webapp-exploded" overwrite="false"/>
                <jar destfile="./target/test-webapp.war"
basedir="./target/test-webapp-exploded"/>
                <delete dir="./target/test-webapp-exploded"/>
                <delete
file="./target/supplementaldata-ui-1.0-SNAPSHOT.war"/>
              </tasks>
            </configuration>
            <goals>
              <goal>run</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>com.buckazoid.maven.mojos</groupId>
        <artifactId>dependency-copier-plugin</artifactId>
        <version>1.1</version>
        <configuration>
          <outputDirectory>./target/</outputDirectory>
        </configuration>
        <executions>
          <execution>
          <phase>package</phase>
            <goals>
              <goal>copy</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
  <pluginRepositories>
    <pluginRepository>
      <id>buckazoid-repo</id>
      <name>Maven repository at buckazoid.com</name>
      <url>http://www.buckazoid.com/maven/repository</url>
    </pluginRepository>
  </pluginRepositories>
</project>
___________________________________
Damian Bradicich
Software Developer
Scientific Technologies Corporation
Tel: (603) 471-4712
Email: Damian_Bradicich@stchome.com
Web Site: www.stchome.com
"Advancing Public Health Outcomes Through Information Technology"
___________________________________


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