我想使用maven-deploy-plugin部署文件。目前我在我的pom中有以下内容:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.7</version>
<executions>
<execution>
<id>deploy-features-xml</id>
<phase>deploy</phase>
<goals>
<goal>deploy-file</goal>
</goals>
<configuration>
<repositoryId>${project.distributionManagement.snapshotRepository.id}</repositoryId>
<url>${project.distributionManagement.snapshotRepository.url}</url>
<groupId>${project.groupId}</groupId>
<artifactId>${project.artifactId}</artifactId>
<version>${project.version}</version>
<file>features.xml</file>
</configuration>
</execution>
</executions>
</plugin>
我想根据版本在快照和发布存储库之间进行更改。如果项目版本为1-SNAPSHOT,则应将文件部署到快照存储库,如果项目是1.0版,则应将文件部署到发布存储库。但是maven-deploy-plugin硬代码呢?
答案 0 :(得分:4)
默认情况下已提供此行为。但是你应该使用repository manager。您可以通过mvn部署简单地部署工件部署通常具有SNAPSHOT版本将进入SNAPSHOT存储库,以便在发布时它将进入发布存储库。
答案 1 :(得分:2)
我最终得到的解决方案是使用build-helper-maven-plugin和maven-resources-plugin。这个设置意味着与jar和pom以及项目一起将部署一个xml文件,该文件可以作为project / xml / features在maven repo中引用。
相关的pom插件:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>attach-artifacts</id>
<phase>package</phase>
<goals>
<goal>attach-artifact</goal>
</goals>
<configuration>
<artifacts>
<artifact>
<file>target/features/features.xml</file>
<type>xml</type>
<classifier>features</classifier>
</artifact>
</artifacts>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-features</id>
<phase>generate-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>target/features</outputDirectory>
<resources>
<resource>
<directory>src/main/features</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>