- 通过版本号自动部署RELEASE或者SNAPSHOT仓库
- 通过generatePom=true设置自动生成pom.xml
- 解决maven-deploy-plugin 3.x 版本pom.xml 默认使用项目根目录的pom.xml的问题
以下是一个部署配置:
<plugin>
<groupId>org.codehaus.gmaven</groupId>
<artifactId>groovy-maven-plugin</artifactId>
<version>2.0</version>
<executions>
<execution>
<id>parse-repository</id>
<phase>validate</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<source>
<![CDATA[
project.properties['deploy.repository.url'] = '${project.version}'.contains('SNAPSHOT') ? '${project.distributionManagement.snapshotRepository.url}' : '${project.distributionManagement.repository.url}'
project.properties['deploy.repository.id'] = '${project.version}'.contains('SNAPSHOT') ? '${project.distributionManagement.snapshotRepository.id}' : '${project.distributionManagement.repository.id}'
]]>
</source>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>default-install</id>
<phase>install</phase>
<goals>
<goal>install</goal>
</goals>
<configuration>
<skip>true</skip>
</configuration>
</execution>
<execution>
<id>install-file</id>
<phase>install</phase>
<goals>
<goal>install-file</goal>
</goals>
<configuration>
<packaging>jar</packaging>
<generatePom>true</generatePom>
<groupId>${project.groupId}</groupId>
<artifactId>${project.artifactId}</artifactId>
<version>${project.version}</version>
<file>${project.build.directory}/${project.artifactId}-${project.version}.jar</file>
<sources>${project.build.directory}/${project.artifactId}-${project.version}-sources.jar</sources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
<executions>
<execution>
<id>default-deploy</id>
<phase>deploy</phase>
<goals>
<goal>deploy</goal>
</goals>
<configuration>
<skip>true</skip>
</configuration>
</execution>
<execution>
<id>deploy-file</id>
<phase>deploy</phase>
<goals>
<goal>deploy-file</goal>
</goals>
<configuration>
<packaging>jar</packaging>
<generatePom>true</generatePom>
<groupId>${project.groupId}</groupId>
<artifactId>${project.artifactId}</artifactId>
<version>${project.version}</version>
<file>${project.build.directory}/${project.artifactId}-${project.version}.jar</file>
<sources>${project.build.directory}/${project.artifactId}-${project.version}-sources.jar</sources>
<repositoryId>${deploy.repository.id}</repositoryId>
<url>${deploy.repository.url}</url>
</configuration>
</execution>
</executions>
</plugin>