【发布时间】:2016-03-28 21:18:10
【问题描述】:
使用 Maven,我需要将 Web 应用程序自动部署到 Tomcat 服务器,然后运行 MainClass 以执行一些部署后操作。
通过 cargo-maven2-plugin 和 exec-maven-plugin 单独这两件事已经开始工作了。但是我不知道如何将它们绑定在一起。
我看到两个选项:
将“官方”maven deploy 目标设为简单地执行 cargo-plugin,然后执行 exec-maven,仅此而已
将exec-maven的执行绑定到cargo:deploy
的完成
第一个是我的最爱。不幸的是,我不知道如何实现它们。
当前的 pom.xml:
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.4.15</version>
<configuration>
<container>
<containerId>tomcat8x</containerId>
<type>remote</type>
<systemProperties>
<cargo.jvmargs>-XX:MaxPermSize=256M -Xmx1024m</cargo.jvmargs>
</systemProperties>
</container>
<configuration>
<type>runtime</type>
<properties>
<cargo.hostname>${my.hostname}</cargo.hostname>
<cargo.servlet.port>${my.port}</cargo.servlet.port>
<cargo.tomcat.manager.url>${my.hostname}/manager</cargo.tomcat.manager.url>
<cargo.remote.username>tomcat</cargo.remote.username>
<cargo.remote.password>tomcat</cargo.remote.password>
</properties>
</configuration>
<deployables>
<deployable>
<location>${project.build.directory}/${project.build.finalName}.war</location>
<type>war</type>
<properties>
<context>/${project.build.finalName}</context>
</properties>
</deployable>
</deployables>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.4.0</version>
<executions>
<execution>
<!-- NEED TO BE AFTER DEPLOY -->
<phase>package</phase>
<goals>
<goal>java</goal>
</goals>
<configuration>
<mainClass>ch.MainClass</mainClass>
<arguments>
<argument>Will be forwarded to main()</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
【问题讨论】:
标签: maven tomcat deployment maven-cargo exec-maven-plugin