I have two wars which I deploy in two maven projects using tomcat plugin. I want to do this in one step and be able to deploy more than one war in a single maven project. Ho
I'm not in a position to test this, but there are two approaches I can think of. Either may work for you.
Option 1:
In one of the projects you can define the configuration for the tomcat plugin. In the snippet below there are two executions defined, both bound to the pre-integration-test phase (this might not be the best phase to do this, but it seems a good starting point as the war will have been packaged). Each execution will deploy the war defined in its configuration's warFile property.
...
...
...
org.codehaus.mojo
tomcat-maven-plugin
1.0-beta-1
deploy1
pre-integration-test
path/to/my/warFile1.war
deploy
deploy2
pre-integration-test
path/to/my/warFile2.war
deploy
...
...
...
Option 2: This is probably the better approach. Define one execution in each war (you can omit the warFile element as the default can be used). You can then define a third project with a modules declaration referencing each war project. When the parent is built both wars will be be built and the wars deployed.
The modules declaration for the third project:
relative/path/to/war1
relative/path/to/war2
And the config for each war project:
...
...
...
org.codehaus.mojo
tomcat-maven-plugin
1.0-beta-1
deploy
pre-integration-test
deploy
...
...
...
Maven has some properties you can use to avoid absolute paths.
${maven.repo.local} will resolve to the local repository
${project.basedir} is the project directory (the root of the project)
${project.build.directory} is the build directory (default is "target")
${project.build.outputDirectory} is the directory where compilation output goes (default is "target/classes")