Online Info: appassembler-maven-plugin
Steps to get a fully packaged test app are as follows:
1. run maven archetype to create a basic CLI app
$ mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app
2. Add maven plugin configuration for the appassembler-maven-plugin
<build>
<plugins>
<!-- package the app into a jar -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>appassembler-maven-plugin</artifactId>
<version>${appassembler-maven-plugin-version}</version> <!-- 1.0 -->
<configuration>
<extraJvmArguments>-Xms128m -Xmx512m</extraJvmArguments>
<programs>
<program>
<mainClass>com.mycompany.app.App</mainClass>
<name>testApp</name>
</program>
</programs>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>assemble</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- use the archive.xml to package up a deployable .zip file -->
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>${maven-assembly-plugin-version}</version>
<executions>
<execution>
<phase>integration-test</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptors>
<descriptor>src/main/assembly/archive.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
3. Add in proper archiving configuration
in assembly\archive.xml
example:
<assembly>
<id>appassembly</id>
<formats>
<format>zip</format>
</formats>
<fileSets>
<fileSet>
<directory>target/appassembler</directory>
<outputDirectory>/</outputDirectory>
</fileSet>
<!--fileSet>
<directory>bin</directory>
<outputDirectory>/bin</outputDirectory>
</fileSet-->
<!-- add any other filesets to include docs, readmes, licences etc here -->
</fileSets>
</assembly>
When completed, run maven clean install. The generated .ZIP file can then can be unpackaged
and deployed where desired. In the deployed bin directory, a .bat file will properly run the CLI app.
No comments:
Post a Comment