我正在尝试构建一个pom.xml
来处理远程 TomEE (PluME 7.0.3) 服务器的部署和取消部署。但是,我无法确定要在path
配置标签中使用的正确值。这是用于将我的应用程序(成熟的 EAR,用于教育目的)部署到远程 TomEE 的有效插件配置:
<build>
<plugins>
<plugin>
<groupId>org.apache.tomee.maven</groupId>
<artifactId>tomee-maven-plugin</artifactId>
<version>7.0.3</version>
<configuration>
<context>someear</context>
<tomeeClassifier>plus</tomeeClassifier>
<tomeeHost>192.168.100.100</tomeeHost>
<debugPort>8000</debugPort>
<tomeeAjpPort>8009</tomeeAjpPort>
<tomeeHttpPort>8080</tomeeHttpPort>
<tomeeShutdownPort>8005</tomeeShutdownPort>
<path>target/someear-1.0-SNAPSHOT.ear</path>
<useBinaries>true</useBinaries>
</configuration>
</plugin>
</plugins>
</build>
而要取消部署,我必须像这样配置插件:
<build>
<plugins>
<plugin>
<groupId>org.apache.tomee.maven</groupId>
<artifactId>tomee-maven-plugin</artifactId>
<version>7.0.3</version>
<configuration>
<context>someear</context>
<tomeeClassifier>plus</tomeeClassifier>
<tomeeHost>192.168.100.100</tomeeHost>
<debugPort>8000</debugPort>
<tomeeAjpPort>8009</tomeeAjpPort>
<tomeeHttpPort>8080</tomeeHttpPort>
<tomeeShutdownPort>8005</tomeeShutdownPort>
<path>someear-1.0-SNAPSHOT</path>
<useBinaries>true</useBinaries>
</configuration>
</plugin>
</plugins>
</build>
注意path
配置的不同。在命令行中,它的行为类似;当path
pom.xml 中的标签被省略时,我可以像这样部署和取消部署:
mvn tomee:deploy -Dtomee-plugin.archive=target/someear-1.0-SNAPSHOT.ear
mvn tomee:undeploy -Dtomee-plugin.archive=someear-1.0-SNAPSHOT
有没有人经历过同样的行为,并找到了缓解这种情况的方法?我希望在 pom.xml 中完全配置部署和取消部署,而无需在调用mvn
. 但是,截至目前,我不能这样做,因为tomee:deploy
似乎期望path
与tomee:undeploy
.
编辑
好的,根据@Old School 编辑的答案,我可以这样做:
<profiles>
<profile>
<id>deploy</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<my-tomee-maven-plugin-path>target/someear-1.0-SNAPSHOT.ear</tomee-maven-plugin-path>
</properties>
</profile>
<profile>
<id>undeploy</id>
<properties>
<my-tomee-maven-plugin-path>someear-1.0-SNAPSHOT</tomee-maven-plugin-path>
</properties>
</profile>
</profiles>
然后,path
在tomee-maven-plugin
的配置部分中指定如下:
...
<path>${my-tomee-maven-plugin-path}</path>
...
然后,像这样执行maven:
mvn tomee:deploy
mvn tomee:undeploy -Pundeploy
-D
我认为这比在执行时(YMMV)指定一些参数更方便。
但是,我认为完美的解决方案是,如果您可以path
在tomee-maven-plugin
's 配置中进行配置,以便两者都可以tomee:deploy
轻松tomee:undeploy
工作。
编辑2
我发现了另一种没有配置文件的可能性,我以前似乎无法找到(基于:http ://tomee-openejb.979440.n4.nabble.com/Deployment-to-TomEE-7-0-0-using-tomee- maven-plugin-error-Cannot-open-input-stream-to-server-tp4679142p4679282.html):
<plugin>
<groupId>org.apache.tomee.maven</groupId>
<artifactId>tomee-maven-plugin</artifactId>
<version>7.0.3</version>
<configuration>
<context>${project.artifactId}</context>
<tomeeClassifier>plus</tomeeClassifier>
<context>someear</context>
<tomeeClassifier>plus</tomeeClassifier>
<tomeeHost>192.168.100.100</tomeeHost>
<debugPort>8000</debugPort>
<tomeeAjpPort>8009</tomeeAjpPort>
<tomeeHttpPort>8080</tomeeHttpPort>
<tomeeShutdownPort>8005</tomeeShutdownPort>
<!-- no <path> tag -->
<useBinaries>true</useBinaries>
</configuration>
<executions>
<execution>
<id>deploy-it</id>
<phase>none</phase>
<goals>
<goal>deploy</goal>
</goals>
<configuration>
<path>target/someear-1.0-SNAPSHOT.ear</path>
</configuration>
</execution>
<execution>
<id>undeploy-it</id>
<phase>none</phase>
<goals>
<goal>undeploy</goal>
</goals>
<configuration>
<path>someear-1.0-SNAPSHOT</path>
</configuration>
</execution>
</executions>
</plugin>
用法:
mvn tomee:deploy@deploy-it
mvn tomee:undeploy@undeploy-it