Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

flatten plugin is replacing ${} properties when profiles are activated by property #149

Closed
desiderati opened this issue May 14, 2020 · 5 comments

Comments

@desiderati
Copy link

Suppose that we have two POM files, the POM Parent A and the POM Child B. Inside the POM A we declare a profile, which will only be active if some file is missing in the child module.

<profiles>
        <profile>
            <id>generate-banner.txt-file</id>
            <activation>
                <file>
                    <missing>${banner.txt-source-dir}</missing>
                </file>
            </activation>
            <build>
                <plugins>
                    <!--
                        It copies the project banner which will be used to log the project name and version!
                    -->
                    <plugin>
                        <artifactId>maven-dependency-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>copy-project-banner</id>
                                <phase>generate-resources</phase>
                                <goals>
                                    <goal>unpack-dependencies</goal>
                                </goals>
                                <configuration>
                                    <overWriteIfNewer>true</overWriteIfNewer>
                                    <type>jar</type>
                                    <includeGroupIds>${banner.txt-group-id}</includeGroupIds>
                                    <includeArtifactIds>${banner.txt-artifact-id}</includeArtifactIds>
                                    <includes>banner.txt</includes>
                                    <outputDirectory>${generated-resources.dir}</outputDirectory>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

Which happens is the fact that when I flatten the POM A, even using Flatten Mode = resolveCiFriendliesOnly, those properties above are been replaced and with this, the child module POM B does not have the option to re-configured those properties, since they are fixed now.

But if I declare this plugin (I did just for test) directly inside the build section (without profile), those same properties now ARE NOT been replaced in the flattened version of POM A. Which is, by the way, the expected result. Now, the child module (POM B) can call the plugin with the properties configured by it.

@gpaulissen
Copy link

I have the same sort of experience:

I have a profile like this (to activate it only in the root when there is a README.md):

build README.md

After flattening (resolveCiFriendliesOnly) I get this flattened POM:

build "full path to README.md"

Now it is not portable anymore. If I use ${basedir} the same behaviour.

@jaapspiering
Copy link

jaapspiering commented Nov 30, 2020

We are experiencing this issue as well, ${basedir} is always being intrapolated, even if used implicitly such as within elements.

This issue is a duplicate of #57 as both are about the file element, it depends on a bug in Maven. PR is already here: #152

@BastianKanaan
Copy link

I am facing a similar problem. The master-branch looks fixed. Is a release of version 1.2.6 at mvnrepository planned or at least a snapshot?

@lasselindqvist
Copy link
Collaborator

See:
https://github.com/mojohaus/flatten-maven-plugin/pulls?q=is%3Apr+is%3Aclosed+sort%3Aupdated-desc
#152

If the master works for you, I could try to craft a release out of the current state of the branch to ease the pain.

@lasselindqvist
Copy link
Collaborator

Closing this as it seems to be fixed by another issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants