使用 tomcat-maven-plugin 部署预构建的 WAR
我有一个由 Warbler 正确生成的 WAR 文件,当我手动完成这一切时,它正在工作。
我正在尝试使用maven(通过Hudson)来
1)调用warble(成功)
<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)部署到tomcat
这是我遇到问题的第二部分。我只想告诉 maven 获取我刚刚生成的 WAR 文件(并按预期移动到 target/)并部署它。
问题是,如果我没有为整个项目指定打包,它只会跳过任何部署(“跳过非 WAR”)。如果我指定 WAR 打包,它会尝试创建一个无用的 WAR 本身,这没什么问题,但它会不断要求提供越来越多的信息(webxml 等)来创建这个无用的 WAR,无论如何我最终都会删除并忽略它。
基本上,有没有一种简单的方法可以对maven说“将我刚刚在workspace/target/中创建的战争并将其部署为您自己创建的任何战争”?
I have a WAR file properly generated by Warbler and 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有史以来第一次发帖:)
是的,这是可能的。诀窍是禁用 maven-war-plugin 的执行,这样它就不会尝试打包任何东西。然后,您只需将 tomcat 指向您已经组装的预构建战争即可。这是我的 POM,它部署了预构建 lambda Probe WAR 文件:
感谢 waffel 的博客为我提供了通用解决方案,引导我弄清楚如何禁用 maven- 的执行战争插件。 :)
*编辑:您可能还想禁用 maven-install-plugin 以防止 maven 在调用常用的“mvn clean install”时发出抱怨(消息如下所示:)
将此部分添加到您的 POM:
如果您希望您的项目实际将 war 文件安装到您的存储库中,我认为您将不得不使用 maven-install-plugin 的 install:install - 文件目标。
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:
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:)
Add this section to your POM:
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.