git-commit-id-maven-plugin icon indicating copy to clipboard operation
git-commit-id-maven-plugin copied to clipboard

multi-module config with pluginManagement

Open if6was9 opened this issue 13 years ago • 5 comments

Somewhere between 2.1.4 and now the behavior of the plugin has changed with regard to multi-module configuration.

Specifically, if the git-commit-id-plugin is configured in a section of a parent POM, the value of is now expanded with respect to the parent pom.

So even though the plugin may run multiple times in multiple maven submodules, it will overwrite the same file repeatedly.

In 2.1.4, the behavior was different. If was set to resources/git.properties in the parent pom, then it would be generated for each maven module:

submodule1/resources/git.properties
submodule2/resources/git.properties

if6was9 avatar Nov 16 '13 15:11 if6was9

I suspect that the behavior change was introduced here:

https://github.com/ktoso/maven-git-commit-id-plugin/commit/d1a3a842fc00d5e443f01f537b41302e09c73a7a

if6was9 avatar Nov 16 '13 15:11 if6was9

Just landed in London and... Great find! Definitely a bug, will look into bringing back the expected behavior. Thanks!

ktoso avatar Nov 16 '13 15:11 ktoso

Hello Rob, I tried debugging this problem. For me it works fine with 2.1.8-SNAPSHOT.

That's my output:

ktoso @ 月~/code/maven-plugins/testing-deep [master*]
$ mvn clean install

...
[INFO] Git Commit Id Plugin Maven Mojo ................... SUCCESS [0.786s]
[INFO] submodule-one ..................................... SUCCESS [0.932s]
[INFO] submodule-two ..................................... SUCCESS [0.327s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.206s
[INFO] Finished at: Sat Nov 16 23:16:59 GMT 2013
[INFO] Final Memory: 11M/310M
[INFO] ------------------------------------------------------------------------


ktoso @ 月~/code/maven-plugins/testing-deep [master*]
$ find . -name git.properties | grep example    # because I configured it to "example/git.properties"
./submodule-one/example/git.properties
./submodule-two/example/git.properties

Could you help me out, and bring this project: https://github.com/ktoso/git-commit-id-debugging into the problematic state you're encountering? Then I'll fix the problem.

Thanks a lot for the help in advance :-)

ktoso avatar Nov 16 '13 23:11 ktoso

I understand what it is happening.

In the parent pom's pluginManagement section, if the location is specified like this:

<generateGitPropertiesFilename>mypath/git.properties</generateGitPropertiesFilename%gt;

Then during the execution within the sub-modules, only the single file is written (multiple times) relative to the parent pom's directory.

But if it is specified like so, then it behaves as expected.

<generateGitPropertiesFilename>${project.basedir}/mypath/git.properties</generateGitPropertiesFilename>

I'm not positive how Maven is supposed to behave, so this could very well be expected behavior.

if6was9 avatar Nov 18 '13 01:11 if6was9

Even though this issue is already open for quite some time I did some debugging (https://github.com/TheSnoozer/git-commit-id-debugging)

Project structure:

  • Parent-pom with maven-antrun-plugin that echo's the properties ${user.dir}, ${basedir} and ${project.basedir}
  • submodule-one that inherits parent without any additional settings
  • submodule-two that inherits parent without any additional settings

Output (mvn clean package):

[INFO] ------------------------------------------------------------------------
[INFO] Building Git Commit Id Plugin Maven Mojo Debugging 0.0.1 (Parent)
[INFO] ------------------------------------------------------------------------
     [echo] user.dir: ~/workspace/git-commit-id-debugging
     [echo] basedir: ~/workspace/git-commit-id-debugging
     [echo] project.basedir: ~/workspace/git-commit-id-debugging

[INFO] ------------------------------------------------------------------------
[INFO] Building submodule-one 0.0.1
[INFO] ------------------------------------------------------------------------
     [echo] user.dir: ~/workspace/git-commit-id-debugging
     [echo] basedir: ~/workspace/git-commit-id-debugging/submodule-one
     [echo] project.basedir: ~/workspace/git-commit-id-debugging/submodule-one

[INFO] ------------------------------------------------------------------------
[INFO] Building submodule-two 0.0.1
[INFO] ------------------------------------------------------------------------
     [echo] user.dir: ~/workspace/git-commit-id-debugging
     [echo] basedir: ~/workspace/git-commit-id-debugging/submodule-two
     [echo] project.basedir: ~/workspace/git-commit-id-debugging/submodule-two

Didn't find any documents / manuals but with native maven without having the git-commit-id-mojo involved the property basedir and project.basedir are relative to the current pom (which makes a lot of sense) and user.dir always seems to point to the current execution path....

~ Closing as Not a Bug ~

TheSnoozer avatar Jul 17 '17 09:07 TheSnoozer