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

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

Closed
Andrei-Pozolotin opened this issue Oct 30, 2017 · 5 comments · Fixed by #152
Closed

Comments

@Andrei-Pozolotin
Copy link

  1. when using flatten with:
<pomElements>
   <profiles>keep</profiles>
  1. and pom profile with:
<activation>
   <file>
      <exists>${user.dir}/pom-service.md</exists>
  1. most profile variables are kept, but <exists> is interpolated:
   <activation>
      <file>
         <exists>/some/absolute/path/pom-service.md</exists>
@hohwille
Copy link
Member

Indeed, I can see that behavior as unexpected or even more clear as a bug.
The question is: Should variable interpolation happen for

  • no property at all?
  • only specific standard properties (user.dir, java.home, etc.)?

@hohwille hohwille changed the title keep interpolates profile/activation/file/exists Prevent interpolation of specific system properties (e.g. user.dir, java.home) Jan 14, 2019
@hohwille
Copy link
Member

hohwille commented Jan 14, 2019

To answer my own question:
IMHO the interpolation should not depend on POM element but instead by system property. Here I start a blacklist of variables that should not be interpolated:

  • user.dir
  • user.language
  • user.country
  • user.name
  • java.home
  • java.io.tmpdir
  • file.encoding
  • file.separator
  • line.separator
  • path.separator
  • java.version
  • os.arch
  • os.name
  • os.version
  • basedir
  • project.* (to be discussed, but IMHO project.groupId, project.artirfactId, project.version, etc. should also not be interpolated even though there are rare situations where it could be beneficial.- e.g. when releasing parent POM used by children with different groupId.)

The main thing remaing are the custom properties defined in the properties section of the POM (or provided externally not in the list above).

@hohwille hohwille added this to the release:1.2.0 milestone Jan 14, 2019
@stonedu1011
Copy link

stonedu1011 commented Jun 24, 2019

Is there any update on this issue?

We have a multi-module project serves as framework of another project and also provide common pom parent for the other project. There are couple of profiles defined in the pom with file activation.

We only plan to use this plugin for <flattenMode>resolveCiFriendliesOnly</flattenMode>. This bug is currently blocking us from using it. Any suggestions for workaround?

If the 1.2.0 is not going to get released soon, is there a plan to release a bug fixes (v1.1.1)?

I'd make a suggestion: when to-be-flattened pom is pom packaging, it might be served as parent of other project, so we need an option to keep everything untouched in profiles instead of blacklisted properties.

@stonedu1011
Copy link

Just want to add some information:

In my project described above, we don't use any properties but relative path to current project (this is equivalent to use ${basedir} ).

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>flatten-maven-plugin</artifactId>
    <version>1.1.0</version>
    <configuration>
        <updatePomFile>true</updatePomFile>
        <flattenMode>resolveCiFriendliesOnly</flattenMode>
    </configuration>
</plugin>

The profile looks like:

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

And the published pom looks like

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

dehasi pushed a commit to dehasi/flatten-maven-plugin that referenced this issue May 27, 2020
Problem:
There is a bug in maven [MNG-6802].
FileProfileActivator interpolates model.

Solution:
Read raw maven model directly from the pom file.
@oburgosm
Copy link

What is the status of this issue?

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

Successfully merging a pull request may close this issue.

4 participants