Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Here's full example of using the antrun plugin to move a war file to a jboss server deploy directory once it is built. You can also define the unpacked property (ie. mvn install -Dunpacked) to have the app moved exploded (or unpacked).

Code Block
   <plugin>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <executions>
                            <execution>
                                <phase>install</phase>
                                <configuration>
                                    <tasks>
                                        <taskdef                                                 resource="net/sf/antcontrib/antcontrib.properties"                                                 classpathref="maven.plugin.classpath"/>
  
                                      <delete file="${my.jboss.server}/deploy/${build.finalName}.war"/>
                                        <delete dir="${my.jboss.server}/deploy/${build.finalName}.war"/>

                                        <if>
                                            <isset property="unpacked"/>
                                            <then>
                                                <mkdir dir="${my.jboss.server}/deploy/${build.finalName}.war"/>
                                                <unzip src="${project.build.directory}/${build.finalName}.war" 
                                                       dest="${wsm.jboss.server}/deploy/${build.finalName}.war"/>
                                            </then>
                                            <else>
                                                <copy todir="${my.jboss.server}/deploy">
                                                    <fileset dir="${project.build.directory}"                                                              includes="${build.finalName}.war"/>
                                                </copy>
                                            </else>
                                        </if>
                                    </tasks>

                                </configuration>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                            </execution>
                        </executions>
                        <dependencies>
                            <dependency>
                                <groupId>ant-contrib</groupId>
                                <artifactId>ant-contrib</artifactId>
                                <version>1.0b3</version>
                                <exclusions>
                                    <exclusion>
                                        <groupId>ant</groupId>
                                        <artifactId>ant</artifactId>
                                    </exclusion>
                                </exclusions>
                            </dependency>
                            <dependency>
                                <groupId>ant</groupId>
                                <artifactId>ant-nodeps</artifactId>
                                <version>1.6.5</version>
                            </dependency>
                        </dependencies>
                    </plugin>