我在我的 POM 中定义了以下插件,试图在我们的测试或生产 tomcat 服务器上部署 maven 生成的 .war 文件:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<configuration>
<target name="test-deploy">
<taskdef name="deploy" classname="org.apache.catalina.ant.DeployTask"/>
<deploy
path="/${project.name}"
url="http://test-server:8080/manager/text"
username="user"
password="pass"
war="file:${project.build.directory}/${project.build.finalName}.${project.packaging}"
update="true"/>
</target>
<target name="prod-deploy">
<taskdef name="deploy" classname="org.apache.catalina.ant.DeployTask"/>
<deploy
path="/${project.name}"
url="http://prod-server:8080/manager/text"
username="user"
password="pass"
war="file:${project.build.directory}/${project.build.finalName}.${project.packaging}"
update="true"/>
</target>
</configuration>
<dependencies>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-catalina-ant</artifactId>
<version>8.0.14</version>
</dependency>
</dependencies>
</plugin>
从阅读Maven AntRun 插件用法看来,我应该能够添加目标名称(正如我所做的那样),但我不确定如何调用特定目标。web-deploy
即使我尝试仅使用以下方法调用目标,目标也是唯一运行的目标test-deploy
:
mvn antrun:run -Dtarget=test-deploy
如何指定要运行的 ant 目标?