简体   繁体   English

Maven build-helper-maven-plugin 正则表达式无法使用属性作为dependency.version

[英]Maven build-helper-maven-plugin regex unable to use property as dependency.version

I'm trying to use the build-helper-maven-plugin regex to convert a default property before it is used in the dependency section.我正在尝试使用 build-helper-maven-plugin 正则表达式来转换默认属性,然后再将其用于依赖项部分。

My pom.xml file property sections looks like this...我的 pom.xml 文件属性部分看起来像这样......

<properties>
    <some.version>114.6.9</some.version>
</properties>

My pom.xml file build plugin section looks like...我的 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>

My pom.xml dependency version looks like...我的 pom.xml 依赖版本看起来像...

<dependencies>
    <dependency>
        <groupId>someArtifactGroup</groupId>
        <artifactId>someArtifact</artifactId>
        <version>${some.version}</version>
    </dependency>
</dependencies>

The idea being that if Jenkins is used and passes a dependency override it will be stripped of its pre-fix and used instead of the default value.这个想法是,如果使用 Jenkins 并传递依赖项覆盖,它将被剥离其前缀并使用而不是默认值。
However it appears that this plugin does not run before the dependencies are validated - is it possible to get this working or is there a better way?但是,在验证依赖项之前,此插件似乎不会运行 - 是否可以使其正常工作或有更好的方法?

I was kind of in a similar situation, but an override with -D is no solution (just don't ask) and since I've got a few variables, profiles are none either.我处于类似的情况,但是使用 -D 覆盖不是解决方案(只是不要问),而且由于我有一些变量,因此配置文件也没有。

In my case it's like this: The fabric8 docker maven plugin uses a variable.就我而言,它是这样的:fabric8 docker maven 插件使用一个变量。 That variable is generated by the "build-helper-maven-plugin" regex-property.该变量由“build-helper-maven-plugin”正则表达式属性生成。

If "mvn docker:build" is invoked, the validate phase is not used and the variable is not there (so I get a "${blabla}" literal) and the build fails.如果调用“mvn docker:build”,则不使用验证阶段并且变量不存在(所以我得到一个“${blabla}”文字)并且构建失败。 If I invoke the usual build, the variable gets created.如果我调用通常的构建,则会创建变量。

I took the strategy to run "mvn validate docker:build" instead of "mvn docker:build" to force the validation step, so the variable gets created.我采取了运行“mvn validate docker:build”而不是“mvn docker:build”的策略来强制执行验证步骤,因此创建了变量。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 build-helper-maven-plugin目标:正则表达式属性如何访问生成的属性 - build-helper-maven-plugin goal:regex-property how to access generated property build-helper-maven-plugin导致AnnotationTypeMismatchException - build-helper-maven-plugin causing AnnotationTypeMismatchException Maven | 如何在Gradle中使用build-helper-maven-plugin? - Maven | How can I use build-helper-maven-plugin in Gradle? 什么是需要JDK 1.6的build-helper-maven-plugin的最新版本? - What's the latest version of build-helper-maven-plugin that requires JDK 1.6? build-helper-maven-plugin add-test-resource错误 - build-helper-maven-plugin add-test-resource error 是否可以使用org.codehaus.mojo:build-helper-maven-plugin将本机dll捆绑到war文件中? - Is it possible to use the org.codehaus.mojo:build-helper-maven-plugin to bundle native dlls into a war file? build-helper-maven-plugin 添加额外的源 - build-helper-maven-plugin adding additional source 使用 build-helper-maven-plugin 从 Jar 中排除文件 - Excluding Files From Jar With build-helper-maven-plugin 使用 build-helper-maven-plugin 添加生成的 Apache Avro 源 - Add generated Apache Avro source with build-helper-maven-plugin maven不会识别来自build-helper-maven-plugin的execution'a标签 - maven doesnt recognize execution'a tag from build-helper-maven-plugin
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM