我正在尝试通过在TeamCity上执行Maven发行插件来部署Maven项目并升级版本。我能够成功执行此操作-但是,resources:resources插件不再执行。或更准确地说,它已执行但未进行预期的更改。但是,当我运行maven软件包或进行安装时,它可以工作。不知道这是我所缺少的。任何帮助将不胜感激。
下面是我的代码 父母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>
儿童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>
我运行以下命令:
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%...
在子项目中,我的src / main / resources文件夹中有一个名为application-deployed.properties的文件,下面是我要更改的行。
# build information by team city
child.propject.buildNumber=@CONTINUOUS_BUILD_ID@
child.propject.buildVersion=@GIT_COMMIT@
child.propject.buildBranch=@GIT_BRANCH@
非常感谢您的帮助
答案 0 :(得分:1)
maven-resources-plugin
无权访问您在命令行中传递的参数。原因是deploy
在单独的Maven执行中调用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%"
答案 1 :(得分:0)
我能够通过将以下内容添加到父pom中的maven版本插件中来解决该问题
<arguments>-Dmaven.javadoc.skip=true -Dmaven.test.skipTests=true -Dmaven.test.skip=true -DCONTINUOUS_BUILD_ID=${CONTINUOUS_BUILD_ID} -DGIT_COMMIT=${GIT_COMMIT} -DGIT_BRANCH=${GIT_BRANCH}</arguments>
然后调用我的初始命令
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%...