是否可以避免在'deploy:deploy'处理期间部署根据项目包装构建的工件?
我的意思是:
IE。我希望能够运行“mvn deploy”并得到以下结果:
我检查了'war:war documentation'并发现了“primaryArtifact”参数。但是,它仅提及本地存储库。
我尝试了以下POM,但它仍将'* .war'或'* .zip'部署到远程存储库:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mygroup</groupId>
<artifactId>myapp</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>myapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<!-- dependencies go here -->
</dependencies>
<build>
<plugins>
<! -- plugins like 'compiler' etc -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<primaryArtifact>false</primaryArtifact>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>myapp-standalone</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptors>
<descriptor>src/main/assembly/standalone.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<distributionManagement>
<repository>
<-- target repository information -->
</repository>
<snapshotRepository>
<-- target repository information -->
</snapshotRepository>
</distributionManagement>
</project>
似乎我可以通过将项目包装声明为“pom”并手动配置“war”包装所隐含的所有mojo(“resources:resources”,“compiler:compile”,“resources:testResources”,“compiler:testCompile”)来获得所需的行为。 ','surefire:test','war:war','install:install','deploy:deploy')。但是,这会使POM变得很冗长,我想避免这种情况。
据我了解,Maven方法是始终将项目包装类型所隐含的工件作为项目工件之一。但是,尚不清楚如果Maven用户想要获得与任何默认打包类型(例如单个“* .zip”归档文件)都不匹配的工件,则该做什么。
有什么想法吗?
问候,丹尼斯
最佳答案
根据Maven Deploy Plugin文档:
因此,我认为不可能阻止您的 war “按原样”部署。
但是,为了获得理想的效果,您可以在构建中添加一个特定的模块,该模块将负责生成程序集(该程序集取决于war模块),并将war模块中的deploy插件配置为skip deployment,如下所示:
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>X.Y</version>
<configuration>
<skip>true</skip>
</configuration>
</plugin>