Maven cannot find .git (dotGitDirectory)

I have an issue similar to what has been asked here, but there is no answer.
Have following structure in maven project (which is standard):

parent-pom - which is a parent for all others
    |_reactor - which is a concrete project, parent-pom is a parent
        |_module_1 - reactor is a parent
        |_module_2
        ...
        |_module_n

git-commit-id-plugin is configured in parent-pom and nowhere else.

  • Deploy a php webapp with git
  • Provide passphrase to git in bash script
  • Github Push Not Appearing As Contribution
  • git for development and svn on production server
  • How to get previous tag in git
  • Git grep: Somtimes empty result even when the word exists in a file
  • Until recently everything was fine: I was able to build both the whole reactor project and all modules separately with mvn clean install.
    Then I added a new module (let’s say module_n1), I believe the build had been going fine until massive merge.
    Now I got following situation: reactor build is successful, each module separately from 1 to n builds successfully as well.
    But module_n1 fails with following error:

     [ERROR] Failed to execute goal pl.project13.maven:git-commit-id-plugin:2.1.7:revision (default) on project module_n1: .git directory could not be found! Please specify a valid [dotGitDirectory] in your pom.xml
    

    There is a .git folder under reactor module. As an experiment I removed it and get the same error for other modules.

    What could be a reason why one particular module cannot find .git folder during the build?

    Thanks.

  • Gitolite ACL partition activation with fstab ?
  • Two jekyll blogs on the same GitHub page
  • (Solved) Meteor: call method to execute shell (clone git repo)
  • How can i remove 'Changes not staged for commit'? in git
  • git clone can't resolve proxy
  • Git Merge: parallel identical additions are merged without conflict by including the same code block TWICE in the merged file without complaint. Why?
  • 4 Solutions collect form web for “Maven cannot find .git (dotGitDirectory)”

    I bumped into this problem today and the solution is pretty clear looking at this well documented maven plugin:

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

    Here you have declared the plugin in ‘module_n1’ and there is no .git directory in that folder. The solution would be to configure the plugin as follow if the .git directory is in the parent directory (eg. reactor):

            <plugin>
                <groupId>pl.project13.maven</groupId>
                <artifactId>git-commit-id-plugin</artifactId>
                <version>2.1.15</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>revision</goal>
                         </goals>
                    </execution>
                </executions>
                <configuration>
                    <dotGitDirectory>${project.basedir}/../.git</dotGitDirectory>
                    <!-- more config here as you see fit -->
                </configuration>
            </plugin>
    

    Not a solution, but if you want to skip git-commit-id-plugin execution defined in a parent pom until project is added to git, you can override execution in your pom.

            <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>pl.project13.maven</groupId>
                    <artifactId>git-commit-id-plugin</artifactId>
                    <configuration>
                        <skip>true</skip>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
    

    Updating maven to the latest version fixed the problem for me.

    I ran into something similar in a clean build system and it may be related to their not being a git user “installed”. On my local, I see

    [info]git.build.user.name=myuser

    etc, but nothing like that on the clean system.

    Git Baby is a git and github fan, let's start git clone.