我有一个项目,可以用两种不同的方式打包和部署,它要么是Tomcat的WAR,要么是AWS Lambda的阴影JAR。目前这工作得不是很好,我必须在发布时不断更改pom.xml来回更改。有没有办法使用 Maven 配置文件来实现这一点?
例如,我想做
mvn install -Pwar
生成战争,以及
mvn install -Plambda
以生成带阴影的 JAR。
这可能吗?
您可以尝试在您的pom中包含以下内容.xml
<packaging>${packaging.type}</packaging>
<profiles>
<profile>
<id>lambda</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<packaging.type>jar</packaging.type>
</properties>
</profile>
<profile>
<id>war</id>
<properties>
<packaging.type>war</packaging.type>
</properties>
</profile>
</profiles>