Marouane Gazanayi
Marouane Gazanayi

Reputation: 5193

Maven : How to generate project's war file in two folders

I want that when I run the mvn install, a war can be generated in the /target and an other war in the c:....tomcat 6\deploy directory. I'm using maven2, Eclipse and m2eclipse. How to do this ?? Thnx :)

Upvotes: 1

Views: 415

Answers (3)

FrVaBe
FrVaBe

Reputation: 49361

You could try to use the maven-antrun-plugin to copy your war to the tomcat deploy directory like this:

<build>
    <plugins>
        <plugin>
            <artifactId>maven-antrun-plugin</artifactId>
            <version>1.6</version>
            <executions>
                <execution>
                    <phase>install</phase>
                    <configuration>
                        <target>
                            <copy file="{project.build.directory}/${project.actifactId}-${project.version}.war" tofile="<your tomcat path>/${project.actifactId}-${project.version}.war" />
                        </target>
                    </configuration>
                    <goals>
                        <goal>run</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

Upvotes: 1

Zac Thompson
Zac Thompson

Reputation: 12685

Try the cargo-maven2-plugin. Probably something like this would work:

<plugin>
  <groupId>org.codehaus.cargo</groupId>
  <artifactId>cargo-maven2-plugin</artifactId>
  <executions>
    <execution>
      <id>deploy-local</id>
      <phase>install</phase>
      <goals>
        <goal>deployer-deploy</goal>
      <goals>
    </execution>
  </executions>
  <configuration>
    <container>
      <containerId>tomcat6x</containerId>
    </container>
    <configuration>
      <type>existing</type>
      <home>/your/tomcat/dir</home> <!-- replace as needed -->
    </configuration>
  </configuration>
</plugin>

... slap that into a profile or the top-level <build><plugins> section and see if it works for you ...

Upvotes: 1

splash
splash

Reputation: 13327

Maybe you don't need to copy the war file if you try the Maven Jetty Plugin. This plugin is for running a web application directly from Maven.

Upvotes: 1

Related Questions