Stephan
Stephan

Reputation: 43023

Auto-deploy a war file on local JBoss instance after package phase with Maven

When I build my project, I run this command :

mvn clean package

I'd like the resulting jar file built in the default target directory, during the package phase, be copied in another directory.

How can I do this with Maven?

Upvotes: 4

Views: 4041

Answers (2)

Oleksandr
Oleksandr

Reputation: 2416

By default the folder declared in Super POM, that have been inherited by your pom.

 <build>

 <directory>${project.basedir}/target</directory> 

</build>

You can change it in your pom.xml the next way:

 <build>
 <directory>${project.basedir}/yourFolder</directory>

</build>

Upvotes: 1

Heiko Rupp
Heiko Rupp

Reputation: 30934

You can use the ant run plugin to copy the stuff over.

The following is taken from a pom from rhq-project.org

 <build>
    <plugins>

       <plugin>
          <artifactId>maven-antrun-plugin</artifactId>
          <version>1.1</version>
          <executions>

             <execution>
                <id>deploy-jar-meta-inf</id>
                <phase>package</phase>
                <configuration>
                   <tasks>
                      <unjar src="${project.build.directory}/${project.build.finalName}.jar" dest="${rhq.deploymentDir}" overwrite="false">
                         <patternset>
                            <include name="META-INF/**" />
                         </patternset>
                      </unjar>
                   </tasks>
                </configuration>
                <goals>
                   <goal>run</goal>
                </goals>
             </execution>

             <execution>
                <id>undeploy</id>
                <phase>clean</phase>
                <configuration>
                   <tasks>
                      <property name="deployment.dir" location="${rhq.deploymentDir}" />
                      <echo>*** Deleting ${deployment.dir}${file.separator}...</echo>
                      <delete dir="${deployment.dir}" />
                   </tasks>
                </configuration>
                <goals>
                   <goal>run</goal>
                </goals>
             </execution>

          </executions>
       </plugin>

Upvotes: 1

Related Questions