Jak*_*ton 9 maven-plugin maven-3 maven maven-release-plugin
我正在使用preparationGoals
Maven发布插件的配置选项来转换其他文件以反映正在发布的项目的版本.这很好用.
问题是,在执行提交时,插件显式指定只pom.xml
应包含文件,从而使我的其他文件不受控制:
[INFO] Executing: /bin/sh -c cd /Users/jw/dev/Test && git commit --verbose -F /var/folders/w0/hr1h_7h50f3_pwd_nrk9l808000195/T/maven-scm-114713951.commit pom.xml library/pom.xml sample/pom.xml
有没有办法让我覆盖这种行为并指定要包含在提交中的其他文件或整数?
(我也需要这个行为completionGoals
,我已配置为执行相同的转换)
我还需要提交一些额外的文件(由 Maven Replacer 插件更改)。我是通过以下方式做到的:
首先,我配置了Maven Release 插件来执行其他目标:
<plugin>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.3</version>
<configuration>
<preparationGoals>-Prelease -DreplacerVersion="${releaseVersion}" clean replacer:replace scm:checkin verify</preparationGoals>
<completionGoals>-Prelease -DreplacerVersion="${developmentVersion}" clean replacer:replace scm:checkin verify</completionGoals>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
release
profile 定义了 Maven SCM 插件的配置replacerVersion
Maven Replacer 插件使用参数在某些文件中设置正确的版本clean
是的Maven插件版标准的目标运行(默认:clean verify
)replacer:replace
目标负责修改文件scm:checkin
提交和推送verify
是的Maven插件版标准的目标运行(默认:clean verify
)接下来我配置了Maven Replacer 插件:
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>replacer</artifactId>
<version>1.5.3</version>
<configuration>
<includes>
<include>${basedir}/file1.txt</include>
<include>${basedir}/file2.txt</include>
</includes>
<replacements>
<replacement>
<token><![CDATA[<pattern>.*</pattern>]]></token>
<value><![CDATA[<pattern>${replacerVersion}</pattern>]]></value>
</replacement>
</replacements>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
${replacerVersion}
允许使用相同的配置从开发更改为发布,然后从发布更改为下一个开发版本。
最后我定义了我想使用哪个版本的Maven SCM 插件:
<plugin>
<artifactId>maven-scm-plugin</artifactId>
<version>1.9.5</version>
</plugin>
Run Code Online (Sandbox Code Playgroud)
并在release
配置文件中配置它(我在配置文件中定义它以防止在非发布构建期间意外提交):
<profile>
<id>release</id>
<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-scm-plugin</artifactId>
<configuration>
<message>[maven-scm-plugin] set ${replacerVersion} version in files</message>
<includes>file1.txt, file2.txt</includes>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</profile>
Run Code Online (Sandbox Code Playgroud)
感谢执行命令后:
mvn release:prepare -DdevelopmentVersion=1.2.1-SNAPSHOT -DreleaseVersion=1.2.0 -Dtag=1.2.0
Run Code Online (Sandbox Code Playgroud)
我看到 4 个提交:
您可以使用maven-scm-plugin吗?添加运行scm:checkin
目标的插件执行,以提交所需的文件。将其绑定到preparationGoals
运行时将执行的阶段(如果您将一个或多个阶段指定为该元素的值),或者将scm:checkin
目标preparationGoals
直接包含在内。
归档时间: |
|
查看次数: |
2998 次 |
最近记录: |