我想使用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硬编码吗?
发布于 2013-03-22 07:31:11
我最终得到的解决方案是使用build-helper-maven-plugin和maven-resources-plugin。这个设置意味着,与jar和pom一起,project将部署一个xml文件,该文件可以在maven存储库中作为project/xml/feature引用。
相关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>发布于 2013-03-19 17:37:20
默认情况下已经给出了这个行为。但您应该使用repository manager。您可以通过mvn deploy简单地部署工件,通常具有快照版本的工件将进入快照存储库中,如果是发布版本,则将进入发布存储库。
https://stackoverflow.com/questions/15494191
复制相似问题