You can try this:
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.1</version>
<configuration>
<url>${server-url}</url>
<path>${deploy-path}</path>
<username>${deploy-un}</username>
<password>${deploy-pw}</password>
</configuration>
</plugin>
When you have many modules in your project, use <profile>
in each module to deploy each module to different URLs
. Ex:
In module A:
<profile>
<id>server1</id>
<properties>
<!-- Replace with URL and authentication if needed -->
<server-url>http://localhost:8080/manager/text</server-url>
<deploy-path>/moduleA</deploy-path>
<deploy-un>tomcatscript</deploy-un>
<deploy-pw>p@ssw0rd</deploy-pw>
</properties>
</profile>
In module B:
<profile>
<id>server1</id>
<properties>
<!-- Replace with URL and authentication if needed -->
<server-url>http://localhost:8080/manager/text</server-url>
<deploy-path>/moduleB</deploy-path>
<deploy-un>tomcatscript</deploy-un>
<deploy-pw>p@ssw0rd</deploy-pw>
</properties>
</profile>
DO NOT FORGET to add this into your tomcat/conf/tomcat-users.xml
:
<role rolename="manager-script"/>
<role rolename="manager-jmx"/>
<user username="tomcatscript" password="p@ssw0rd" roles="manager-script, manager-jmx"/>
Then at terminal, use this: mvn tomcat7:[re]deploy -Pserver1
moduleA
will be deployed to http://localhost:8080/moduleA
,
moduleB
will be deployed to http://localhost:8080/moduleB
Hope this helps!