Skip to content

regex-properties is not able to re-use a generated property in same execution #236

Description

@donatelloOo

Reproducer:

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <!-- this generates ${groupId:artifactId:type:[classifier]} properties for all dependencies -->
                        <!-- which contains the path to each one -->
                        <id>generate-dependencies-properties</id>
                        <goals>
                            <goal>properties</goal>
                        </goals>
                        <phase>validate</phase>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>properties-maven-plugin</artifactId>
                <version>1.3.0</version>
                <executions>
                    <execution>
                        <!-- this dumps all properties in app.properties, for debugging purpose -->
                        <id>write-debug-properties</id>
                        <phase>initialize</phase>
                        <goals>
                            <goal>write-project-properties</goal>
                        </goals>
                        <configuration>
                            <outputFile>${project.build.outputDirectory}/app.properties</outputFile>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <version>${build-helper-maven-plugin.version}</version>
                <executions>
                    <execution>
                        <id>generate-computed-properties</id>
                        <phase>initialize</phase>
                        <goals>
                            <goal>regex-properties</goal>
                        </goals>
                        <configuration>
                            <regexPropertySettings>
                                <regexPropertySetting>
                                    <name>dependency.myArtifactId.fileSuffix</name>
                                    <!--suppress UnresolvedMavenProperty: injected by maven-dependency-plugin:properties -->
                                    <value>${com.my.groupId:com.my.artifactId:tgz}</value>
                                    <regex>.*/myArtifactId-</regex>
                                    <replacement />
                                    <failIfNoMatch>true</failIfNoMatch>
                                </regexPropertySetting>
                                <regexPropertySetting>
                                    <name>dependency.myArtifactId.version</name>
                                    <!--suppress UnresolvedMavenProperty: injected by build-helper-maven-plugin:regex-properties -->
                                    <value>${dependency.myArtifactId.fileSuffix}</value> <!-- NOT RESOLVED HERE -->
                                    <regex>.tgz</regex>
                                    <replacement />
                                    <failIfNoMatch>true</failIfNoMatch>
                                </regexPropertySetting>
                            </regexPropertySettings>
                        </configuration>
                    </execution>

The workaround is basically to split the two replacements in 2 different executions

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions