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

#57 Prevent interpolation of a profile activation file #152

Conversation

dehasi
Copy link
Contributor

@dehasi dehasi commented May 16, 2020

Fixes #57
Relates #114
Relates MNG-6802, MNG-5612

A profile activation file is being interpolated during flatten-maven-plugin run.

Example

<profile>
    <id>dockerfile-update</id>
    <activation>
        <file>
            <exists>Dockerfile</exists> <!-- problem here -->
        </file>
    </activation>
</profile>

Result

<profile>
    <id>dockerfile-update</id>
    <activation>
        <file>
            <exists>aboslute/path/resolved/on/building/machine/Dockerfile</exists>
        </file>
    </activation>
</profile>

The root of the problem in FileProfileActivator.isActive()
method.

It is called in DefaultModelBuilder.build().
Which happens here.

That's why rawModel has already interpolated the file path.

It means when flatten-maven-plugin calls this.project.getOriginalModel()
it returns already interpolated activation file.

As a solution, we can load a raw model directly from the pom.xml.

That's why I introduced method getOriginalModel() which loads
Model from the proper pom.xml.

During troubleshooting, I added a unit-ish test FlattenMojoTest
to be able to debug.
That's why I added maven-plugin-testing-harness and maven-compat
dependencies. I can remove the test if you wish.

@hohwille @rfscholte could you take a look.

If you agree that FileProfileActivator.isActive() has a bug because it updates the input parameter profile, I'll be happy to fix it.

Problem:
There is a bug in maven [MNG-6802].
FileProfileActivator interpolates model.

Solution:
Read raw maven model directly from the pom file.
@Tijs-2
Copy link

Tijs-2 commented Jul 24, 2020

I have the same problem and I am wondering, because my build process needs to check for certain file, if and if so when fix will be released?

@christf
Copy link

christf commented Dec 10, 2020

This was tested and confirmed working in one of my projects too.
What can be done to bring this forward and get it released?

@hohwille
Copy link
Member

@lasselindqvist are you still maintaining this plugin? Looks like a reasonable PR to review and get merged...

@lasselindqvist
Copy link
Collaborator

I guess I could merge this and go for a release soon.

@lasselindqvist lasselindqvist merged commit 80dadfd into mojohaus:master Jan 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Prevent interpolation of specific system properties (e.g. user.dir, java.home)
6 participants