java - Maven release not calling resources:resources plugin
问题描述
I'm trying to deploy a maven project and upgrade the versions by executing the maven release plugin on TeamCity. I am able to successfully do this - however, the resources:resources plugin is no longer executed. Or more accurately, it is executed but not doing the expected changes. When I run a maven package or install however, it works. Not sure what it is I'm missing. Any help would be appreciated.
Below is my code Parent pom
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<configuration>
<delimiters>
<delimiter>@</delimiter>
</delimiters>
<useDefaultDelimiters>false</useDefaultDelimiters>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.3</version>
<configuration>
<tagNameFormat>v@{project.version}</tagNameFormat>
<autoVersionSubmodules>true</autoVersionSubmodules>
<releaseProfiles>releases</releaseProfiles>
<localCheckout>true</localCheckout>
<arguments>-Dmaven.javadoc.skip=true -Dmaven.test.skipTests=true -Dmaven.test.skip=true -DCONTINUOUS_BUILD_ID=%build.counter% -DGIT_COMMIT=%build.vcs.number% -DGIT_BRANCH=%vcsroot.branch%</arguments>
</configuration>
<executions>
<execution>
<id>prepare</id>
<goals>
<goal>prepare</goal>
</goals>
<configuration>
<pushChanges>false</pushChanges>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
Child pom
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<configuration>
<delimiters>
<delimiter>@</delimiter>
</delimiters>
<useDefaultDelimiters>false</useDefaultDelimiters>
</configuration>
</plugin>
</plugins>
<resources>
<resource>
<!-- Adds ${buildNumber} to buildNumber.properties -->
<directory>src/main/resources</directory>
<filtering>true</filtering>
<excludes>
<exclude>application_local.properties</exclude>
</excludes>
</resource>
</resources>
</build>
I run the following command:
mvn -B -e initialize release:branch release:clean release:prepare release:stage -DCONTINUOUS_BUILD_ID=%build.counter% -DGIT_COMMIT=%build.vcs.number% -DGIT_BRANCH=%vcsroot.branch%...
And I have in my child project in the src/main/resources folder a file called application-deployed.properties with the following lines which is what I want to change.
# build information by team city
child.propject.buildNumber=@CONTINUOUS_BUILD_ID@
child.propject.buildVersion=@GIT_COMMIT@
child.propject.buildBranch=@GIT_BRANCH@
Any help is much appreciated
解决方案
maven-resources-plugin
无权访问您在命令行中传递的参数。这样做的原因是在单独的 Maven 执行中调用了deploy
目标(其中包括resources:resources
等) 。maven-release-plugin
为了克服这个限制,maven-release-plugin
接受arguments
参数的目标可用于将参数传递给上述单独的 Maven 执行。尝试通过以下方式修改命令行:
mvn -B -e initialize release:branch release:clean release:prepare release:stage -Darguments="-DCONTINUOUS_BUILD_ID=%build.counter% -DGIT_COMMIT=%build.vcs.number% -DGIT_BRANCH=%vcsroot.branch%"
推荐阅读
- python-3.x - 控制哪些元素在 Bokeh 中接收悬停工具提示
- python - 如何将 json.loads 对象从烧瓶传递到 jinja 而不会被截断?
- reactjs - 类型'Readonly<{}> 上不存在属性'location' - React Router 和 Typescript
- arduino - 如何在蓝牙和指纹上合并两个 arduino 程序?
- javascript - 如何通过拆分字符串将数组转换为对象?
- c++ - 如何使用模板函数进行隐式转换
- ruby-on-rails - 如何在 do 循环中发布请求 API
- python - 为什么比较两个数据帧时会得到不同的结果?
- r - dplyr 中的管道 (|) 如何在 Shiny 和数据表的上下文中工作?
- javascript - 当我尝试将多个点击侦听器添加到标记 django 时,initMap 不是一个函数