我想使用Maven发行插件来发行我的Eclipse插件,但是在release:prepare步骤中,我必须跳过更新某些插件的版本号。这是因为它们是其他第三方插件所依赖的插件的修改版本。
我尝试过的是明确地查看现有版本:
mvn release:prepare -DreleaseVersion=1.1.99 -Dproject.rel.org.eclipse.linuxtools.docker.core:org.eclipse.linuxtools.docker.core=4.1.0 -Dproject.dev.org.eclipse.linuxtools.docker.core:org.eclipse.linuxtools.docker.core=4.1.0-SNAPSHOT
这对我不起作用,发行插件仍试图更改版本。
接下来,我尝试将插件分成配置文件,仅调用release:为要更改的插件做准备:
pom.xml
<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>
<artifactId>com.conti.daisy.bundles</artifactId>
<packaging>pom</packaging>
<parent>
<groupId>com.conti.daisy</groupId>
<artifactId>com.conti.daisy.build.parent</artifactId>
<version>1.0.0-SNAPSHOT</version>
<relativePath>./com.conti.daisy.build.parent</relativePath>
</parent>
<profiles>
<profile>
<id>daisy</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<modules>
...
</modules>
</profile>
<profile>
<id>linuxtools</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<modules>
<module>org.eclipse.linuxtools.docker.core</module>
</modules>
</profile>
命令
mvn install -P !daisy # make sure I have the linuxtools plugins in the local repo
mvn release:prepare -P !linuxtools -DreleaseVersion=1.1.99
这有一个缺点,即在跳过的插件中未更新对父pom的引用,这再次使构建中断。
如何正确处理?
我到底做了什么,什么起作用:
在运行mvn release:prepare
之前,我运行mvn install
以确保所有插件都在本地存储库中。
然后我通过在linuxtools
期间停用linuxtools配置文件来排除release:prepare
模块,但是我在preparationGoals
和completionGoals
中添加了以下目标:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<executions>
<execution>
<id>update-parent-version</id>
<goals>
<goal>exec</goal>
</goals>
<phase>none</phase>
<configuration>
<executable>mvn</executable>
<workingDirectory>${rootlocation}</workingDirectory>
<arguments>
<argument>versions:update-child-modules</argument>
<argument>-N</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>install</id>
<goals>
<goal>exec</goal>
</goals>
<phase>none</phase>
<configuration>
<executable>mvn</executable>
<arguments>
<argument>install</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
这可确保linuxtools父pom已更新为新版本,并将新版本安装到本地存储库。