Deploying prebuilt WAR with tomcat-maven-plugin
I have a WAR file properly generated by Warbler a开发者_StackOverflow中文版nd it's working when I do this all by hand.
I'm trying to use maven (via Hudson) to
1) Invoke the warble (successful)
<phase>package</phase>
<configuration>
<executable>/bin/bash</executable>
<workingDirectory>.</workingDirectory>
<arguments>
<argument>-c</argument>
<argument>
echo "Sourcing bashrc"
source ~/.bashrc
rvm use jruby
echo "Path is $PATH"
echo "Gem path is $GEM_PATH"
warble --trace
rm -R target/*
mv workspace.war target/yams.war
</argument>
</arguments>
</configuration>
2) deploy to tomcat
It's part two that I'm having trouble with. I want to just tell maven to take the WAR file I just generated (and helpfully moved to target/, as it expects) and deploy it.
The problem is, if I don't specify a packaging for the whole project, it just skips any deploy ("skipping non-WAR"). If I specify WAR packaging, it tries to make a useless WAR itself, which would be okay but it keeps asking for more and more information (webxml, etc) to make this useless WAR which I'd just end up deleting and ignoring anyways.
Basically, is there a simple way to say "take the war I just created in workspace/target/ and deploy it as you would any WAR you made yourself" to maven?
First ever post :)
Yes, it is possible. The trick is to disable the execution of the maven-war-plugin so that it doesn't try to package anything. Then you can simply point the tomcat at the pre-build war you've already assembled. Here's my POM which deploys the prebuild lambda Probe WAR file:
<project>
<modelVersion>4.0.0</modelVersion>
<artifactId>Probe</artifactId>
<packaging>war</packaging>
<name>Probe</name>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<executions>
<execution>
<id>default-war</id>
<phase>none</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<configuration>
<warFile>Probe.war</warFile>
</configuration>
</plugin>
</plugins>
</build>
</project>
Thanks to waffel's Weblog for providing me with the generic solution that led me to figuring out how to disable execution of the maven-war-plugin. :)
*edit: you may also want to disable the maven-install-plugin to keep maven from complaining when you invoke the oft-used 'mvn clean install' (message looks like this:)
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-install-plugin:2.3.1:install (default-install) on project : The packaging for this project did not assign a file to the build artifact
Add this section to your POM:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>2.3.1</version>
<executions>
<execution>
<id>default-install</id>
<phase>none</phase>
</execution>
</executions>
</plugin>
If you want your project to actually install the war file into your repository, I think you'll be stuck with using the maven-install-plugin's install:install-file goal.
精彩评论