我正在尝试使用build-helper-maven-plugin regex来转换默认属性,然后再将其用于依赖项部分。
我的pom.xml文件属性部分看起来像这样...
<properties>
<some.version>114.6.9</some.version>
</properties>我的pom.xml文件构建插件部分看起来像...
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.9</version>
<executions>
<execution>
<id>regex-property</id>
<goals>
<goal>regex-property</goal>
</goals>
<configuration>
<name>some.version</name>
<value>${P_SOME_VERSION_AS_PASSED_BY_JENKINS}</value>
<regex>^dirtyPrefix-(\S*)</regex>
<replacement>$1</replacement>
<failIfNoMatch>false</failIfNoMatch>
</configuration>
</execution>
</executions>
</plugin>我的pom.xml依赖项版本看起来像...
<dependencies>
<dependency>
<groupId>someArtifactGroup</groupId>
<artifactId>someArtifact</artifactId>
<version>${some.version}</version>
</dependency>
</dependencies>这个想法是,如果使用Jenkins并传递依赖覆盖,它将被剥离它的前缀,并使用它代替默认值。
然而,在验证依赖关系之前,这个插件似乎没有运行--有没有可能让它工作,或者有没有更好的方法?
发布于 2020-02-04 20:07:03
我也遇到过类似的情况,但是使用-D覆盖没有解决方案(只是不要问),因为我有一些变量,所以配置文件也是没有的。
在我的例子中是这样的: fabric8 docker maven插件使用了一个变量。该变量由"build-helper-maven-plugin“regex属性生成。
如果调用"mvn docker: build“,则不使用验证阶段,并且变量不存在(因此我得到一个"${blabla}”字面量),构建失败。如果我调用通常的构建,变量就会被创建。
我采取的策略是运行"mvn validate docker:build“而不是"mvn docker:build”来强制执行验证步骤,因此创建了变量。
https://stackoverflow.com/questions/25483586
复制相似问题