mojohaus / flatten-maven-plugin

Flatten Maven Plugin
https://www.mojohaus.org/flatten-maven-plugin/
Apache License 2.0
206 stars 84 forks source link

properties in profile cannot be read by dependencyManagement #244

Open HelloDhero opened 2 years ago

HelloDhero commented 2 years ago
<flattenMode>resolveCiFriendliesOnly</flattenMode>
<maven-plugin-flatten.version>1.2.7</maven-plugin-flatten.version>
<dependencyManagement>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-dependencies</artifactId>
        <version>${spring-boot.version}</version>
        <type>pom</type>
        <scope>import</scope>
    </dependency>
</dependencyManagement>

<profile>
    <id>springboot_v2.6</id>
    <activation>
        <activeByDefault>true</activeByDefault>
    </activation>
    <properties>
        <java.version>8</java.version>
        <spring-boot.version>2.6.1</spring-boot.version>
    </properties>
</profile>
chiston commented 2 years ago

Faced the same issue.

<profile>
            <id>win.x86</id>
            <activation>
                <os>
                    <arch>x86</arch>
                    <family>windows</family>
                </os>
            </activation>
            <properties>
                <binaries-name>bin-win32</binaries-name>
                <package-type>zip</package-type>
                <build-os>windows</build-os>
                <build-arch>x86</build-arch>
            </properties>
</profile>

<dependency>
            <groupId>com.myproject</groupId>
            <artifactId>${binaries-name}</artifactId>
            <version>1.0.0</version>
            <classifier>${build-os}-${build-arch}</classifier>
            <type>${package-type}</type>
</dependency>

[ERROR] Failed to execute goal org.codehaus.mojo:flatten-maven-plugin:1.2.4:flatten (flatten) on project bin: 1 problem was encountered while building the effective model for com.myproject:bin:1.0.0-1 [ERROR] [ERROR] 'dependencies.dependency.artifactId' for com.myproject:${binaries-name}:${package-type}:${build-os}-${build-arch} with value '${binaries-name}' does not match a valid id pattern. @

Profile win.x86 is in list of active profiles according to mvn help:active-profiles

Flatten config is following:

<configuration>
    <updatePomFile>true</updatePomFile>
    <flattenMode>resolveCiFriendliesOnly</flattenMode>
</configuration>

To get it work I have to call profile manually using mvn -Pwin.x86 clean install