Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Current »

The intention of this was to have a delivery package which comprises of a maven generated WAR-File and a Tomcat (6.0.18). This was needed to simplify the delivery process in an industrial environment.

The first step has been to create a stand-alone-module whereas the resources directory contains all files which tomcat binary comprises of, except the lib/*.jar files. This done to be able to use properties to filter (change) some configuration information within the destination Tomcat (ports, passwords etc.).

You can use the property tomcat.version to define which version of Tomcat you would like to package...(currently only 6.0.18 tested, cause older versions are not available via maven repositories).

<dependencies>
  <dependency>
    <groupId>org.apache.tomcat</groupId>
    <artifactId>annotations-api</artifactId>
    <version>${tomcat.version}</version>
  </dependency>
  <dependency>
    <groupId>org.apache.tomcat</groupId>
    <artifactId>catalina</artifactId>
    <version>${tomcat.version}</version>
  </dependency>
  <dependency>
    <groupId>org.apache.tomcat</groupId>
    <artifactId>tribes</artifactId>
    <version>${tomcat.version}</version>
  </dependency>
  <dependency>
    <groupId>org.apache.tomcat</groupId>
    <artifactId>catalina-ha</artifactId>
    <version>${tomcat.version}</version>
  </dependency>
  <dependency>
    <groupId>org.apache.tomcat</groupId>
    <artifactId>el-api</artifactId>
    <version>${tomcat.version}</version>
  </dependency>
  <dependency>
    <groupId>org.apache.tomcat</groupId>
    <artifactId>jasper-jdt</artifactId>
    <version>${tomcat.version}</version>
  </dependency>
  <dependency>
    <groupId>org.apache.tomcat</groupId>
    <artifactId>jasper-el</artifactId>
    <version>${tomcat.version}</version>
  </dependency>
  <dependency>
    <groupId>org.apache.tomcat</groupId>
    <artifactId>jasper</artifactId>
    <version>${tomcat.version}</version>
  </dependency>
  <dependency>
    <groupId>org.apache.tomcat</groupId>
    <artifactId>jsp-api</artifactId>
    <version>${tomcat.version}</version>
  </dependency>
  <dependency>
    <groupId>org.apache.tomcat</groupId>
    <artifactId>servlet-api</artifactId>
    <version>${tomcat.version}</version>
  </dependency>
  <dependency>
    <groupId>org.apache.tomcat</groupId>
    <artifactId>coyote</artifactId>
    <version>${tomcat.version}</version>
  </dependency>
  <dependency>
  <groupId>org.apache.tomcat</groupId>
    <artifactId>dbcp</artifactId>
    <version>${tomcat.version}</version>
  </dependency>
  <dependency>
    <groupId>org.apache.tomcat</groupId>
    <artifactId>juli</artifactId>
    <version>${tomcat.version}</version>
  </dependency>
		
  <dependency>
    <groupId>your.project.home</groupId>
    <artifactId>yourartifact</artifactId>
    <version>YourRevision</version>
    <type>war</type>
  </dependency>
</dependencies>

The second step was to configure the Maven Assembly plugin to package all the dependencies into a single tar.gz/zip file.

<build>
  <plugins>
    <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-assembly-plugin</artifactId>
    <executions>
      <execution>
        <phase>package</phase>
        <goals>
          <goal>single</goal>
        </goals>
      </execution>
    </executions>
    <configuration>
      <descriptor>src/main/assembly/bin.xml</descriptor>
      <finalName>yourproject-tomcat-${version}</finalName>
    </configuration>
    </plugin>
 </plugins>
</build>

And the assembly descriptor will define the structure of the resulting tar.gz/zip file:

<assembly>
  <id>bin</id>
  <formats>
    <format>tar.gz</format>
    <format>zip</format>
  </formats>
  <fileSets>
    <fileSet>
      <directory>src/main/resources/</directory>
      <outputDirectory>/</outputDirectory>
      <includes>
        <include>**</include>
      </includes>
    </fileSet>
    <fileSet>
      <outputDirectory>/webapps</outputDirectory>
      <directory>${basedir}/../yourwarproject/target</directory>
      <includes>
        <include>yourwarproject.war</include>
      </includes>
    </fileSet>
  </fileSets>
  <dependencySets>
    <dependencySet>
      <outputDirectory>/lib</outputDirectory>
      <unpack>false</unpack>
      <excludes>
        <exclude>*:yourwarproject</exclude>
      </excludes>
    </dependencySet>
  </dependencySets>
</assembly>

The configuration in that way is done to prevent putting the parent war-file into the lib folder instead of the webapps folder.

The resulted tar.gz/zip file now can simply unzipped/untared and going to the bin directory and simply saying "startup.bat/startup.sh"....
That's it...

  • No labels