Reputation: 8937
I'm using Maven 3.0.3. I want to write a simple task to copy a war file from my target directory to the Tomcat deploy directory. Where do I put my goal? I tried ...
<?xml version="1.0" encoding="UTF-8"?><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>socialmediaproxy</groupId>
<artifactId>socialmediaproxy</artifactId>
<packaging>war</packaging>
<version>0.1</version>
<goal name="copy-war" description="Copies the war file to the webapps directory">
<!-- This is Ant stuff -->
<copy file="${basedir}/target/${artifactId}-${version}.war" tofile="${warDestinationDir}"/>
</goal>
but when I run
mvn copy-war -P dev
I get this error ...
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR] The project socialmediaproxy:socialmediaproxy:0.1 (/Users/davea/Documents/workspace-sts-2.6.0.SR1/socialmediaproxy/pom.xml) has 1 error
[ERROR] Malformed POM /Users/davea/Documents/workspace-sts-2.6.0.SR1/socialmediaproxy/pom.xml: Unrecognised tag: 'goal' (position: START_TAG seen ...y-war" description="Copies the war file to the webapps directory">... @9:84) @ /Users/davea/Documents/workspace-sts-2.6.0.SR1/socialmediaproxy/pom.xml, line 9, column 84 -> [Help 2]
Any ideas? - Dave
Upvotes: 3
Views: 1626
Reputation: 97537
The goal part in the pom does not exist anymore, cause that's from Maven 1...but you defined a pom (model version 4.0.0) which is intended for Maven 3. Take a look into the current reference for the pom.
Upvotes: 3
Reputation: 6260
You can use ANT itself to copy the stuff from your target directory to the Tomcat Dir
Since you want to move the files from the target dir, run the ANTRUN
plugin in the package phase.
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
<phase>package</phase>
<configuration>
<target>
<copy file="${basedir}/target/${artifactId}-${version}.war" tofile="${warDestinationDir}"/>
</target>
</configuration>
<goals>
<goal>run</goal>
This will run the ANT task mentioned in <target>
after executing the plase goal.
Upvotes: 0