ktoso/maven-git-commit-id-plugin — Issue #20: Could not find .git directory with findbugs
Author: diogoeag
Created: 2012-01-01 20:14:27+00:00
State: open

(using maven 2.2.1 on linux, with maven-git-commit-id-plugin 2.0.1)

Hi,

I'm using the findbugs plugin to analyse my code and when I run a
- mvn clean install checkstyle:checkstyle findbugs:findbugs

I get the following error:

[INFO] [checkstyle:checkstyle {execution: default-cli}]
[WARNING] Unable to locate Source XRef to link to - DISABLED
[INFO] Preparing findbugs:findbugs
[INFO] [git-commit-id:revision {execution: default}]
******************************************* false
------------------------------------------- /tmp/root/libs/lib1/.git
=========================================== /tmp/root/libs/lib1
******************************************* null
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Could not find .git directory. Please specify a valid dotGitDirectory in your pom.xml
[INFO] ------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.lifecycle.LifecycleExecutionException: Could not find .git directory. Please specify a valid dotGitDirectory in your pom.xml
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:719)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:556)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.forkProjectLifecycle(DefaultLifecycleExecutor.java:1205)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.forkLifecycle(DefaultLifecycleExecutor.java:1038)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:643)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:569)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:539)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.maven.plugin.MojoExecutionException: Could not find .git directory. Please specify a valid dotGitDirectory in your pom.xml
at pl.project13.maven.git.GitCommitIdMojo.lookupGitDirectory(GitCommitIdMojo.java:202)
at pl.project13.maven.git.GitCommitIdMojo.execute(GitCommitIdMojo.java:137)
at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
... 21 more

My structure is:

- root (where I define the use of maven-git-commit-id-plugin)
- libs
- lib1
- lib2

On lib1 and lib2 I get this error.

Meanwhile I've got the code and tried with v 2.0.1 and put some prints on the code:

dotGitDirectory = new File(mavenProject.getBasedir(), Constants.DOT_GIT);
System.out.println("******************************************* "+mavenProject.hasParent());
System.out.println("------------------------------------------- "+dotGitDirectory.toString());
System.out.println("=========================================== "+mavenProject.getBasedir().toString());
System.out.println("******************************************* "+mavenProject.getParent());
if (dotGitDirectory.exists() && dotGitDirectory.isDirectory()) {

And on the first and last prints I get false and null when running under lib1 and lib2.

All the poms are linked to the parents and in the install goal the plugin runs just fine...