Closed arvidj01 closed 12 years ago
Thanks. I'm pretty sure the issue is you don't have either bash or git on your path when running mvn.
I should add better validations and error reporting on those cases. And I never tried it on Windows.
I do not believe the path is the issue.
Both bash and git are on the system path. I can open a simple Windows command window and type 'bash' and the response is a bash shell prompt or type 'git' and the response is the git help information.
If I use mvn from the command window everything works fine. If I do a build from within Eclipse then it fails.
If it works on the cmd line and fails only from within Eclipse, then the plugin itself is working fine... we just need to figure out what Eclipse is doing to launch Maven.
Could you please put together a minimal Eclipse project to reproduce the problem? Thanks
I think I know what is happening and would like to make a recommendation for an addition to the code to help others resolve the issue.
In git.clj this line ...
(sh/proc "bash" "-c" (str "cd " project-dir "; git " args))))
executes bash, which then does a change directory to the project directory and then executes git with several arguments. If the code could be modified to display the command passed to bash ... as in "cd xxx; git yyy" when Maven is run with the -X debugging command it would allow the user to see exactly what command was being executed and from where. It would then be reasonably easy to manually execute the command to see if it works.
The second suggestion would be to have (defn git-describe-log-lines [log-lines-seq] print each line it is process if -X is set thru Maven ... i.e. what were the results of the command.
The reason I bring this up is it would help in figuring out what is happening under the covers in each environment.
From the command line, with mvn -X compile, the relevant part of the log looks like this ...
[DEBUG] Configuring mojo com.code54.mojo:buildversion-plugin:1.0.0:set-properties from plugin realm ClassRealm[plugin>com.code54.mojo:buildversion-plugin:1.0.0,parent: sun.misc.Launcher$AppClassLoader@6b6a3075] [DEBUG] Configuring mojo 'com.code54.mojo:buildversion-plugin:1.0.0:set-properties' with basic configurator --> DEBUG project = MavenProject: waterResearch.core:waterResearch.core:0.0.1-SNAPSHOT @ C:\git\repros\waterResearch.foundation\waterResearch.core\pom.xml [DEBUG] -- end configuration -- [DEBUG] buildversion-plugin - Setting properties: [DEBUG] build-tag: N/A [DEBUG] build-version: N/A [DEBUG] build-tag-delta: 0 [DEBUG] build-tstamp: 20120816094111 [DEBUG] build-commit: daa9adfe52d8911bd75df91f000e358a480260dd [DEBUG] build-commit-abbrev: daa9adf
I have no idea what buildversion did in its interaction with git but I do see that the properties were set.
If I set the Maven logging in Eclipse to TRACE I get the following log items ...
8/16/12 12:36:18 PM CDT: [DEBUG] Configuring mojo com.code54.mojo:buildversion-plugin:1.0.0:set-properties from plugin realm ClassRealm[plugin>com.code54.mojo:buildversion-plugin:1.0.0, parent: sun.misc.Launcher$AppClassLoader@19789a96] 8/16/12 12:36:18 PM CDT: [DEBUG] Configuring mojo 'com.code54.mojo:buildversion-plugin:1.0.0:set-properties' with basic configurator --> 8/16/12 12:36:18 PM CDT: DEBUG project = MavenProject: waterResearch.core:waterResearch.core:0.0.1-SNAPSHOT @ C:\git\repros\waterResearch.foundation\waterResearch.core\pom.xml 8/16/12 12:36:18 PM CDT: [DEBUG] -- end configuration --
so I see that the plugin was called but have no idea what went on. What ever it was it was not enough to generate any properties and it was enough to generate this error message in the log ...
8/16/12 12:36:18 PM CDT: [DEBUG] Created marker 'Execution default of goal com.code54.mojo:buildversion-plugin:1.0.0:set-properties failed: For input string: "" (com.code54.mojo:buildversion-plugin:1.0.0:set-properties:default:initialize)' on resource '/waterResearch.core/pom.xml'.
which I have come to believe is related to either the bash command not being executed for some reason ... other than bach not being on the path as I have validated that many times and can run bash from a remote shell view within Eclipse ... or the results that come back from the command are not usable. I can't tell which.
I am more than happy to experiment with a debug enhanced version of the plugin if you would be willing to make the changes. I would make the changes but don't have the correct environment available.
Thanks, Arvid
You might try with the latest snapshot version "1.0.1-SNAPSHOT".
Thanks for the quick response and changes.
I must be missing something in my maven repository definitions as I get the following error when I run maven from the previously working command line. I did change the plugin repository so it would pick up the 1.0.1-SNAPSHOT but I must still be missing something.
<pluginRepository>
<id>sonatype-snapshots</id>
<url>http://oss.sonatype.org/content/repositories/snapshots</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>clojars.org</id>
<url>http://clojars.org/repo</url>
</pluginRepository>
[ERROR] Failed to execute goal com.code54.mojo:buildversion-plugin:1.0.1-SNAPSHOT:set-properties (default) on project waterResearch.core: Execution default of goal com.code54.mojo:buildversion-plugin:1.0.1-SNAPSHOT:set-properties failed: Plugin com.code54.mojo:buildversion-plugin:1.0.1-SNAPSHOT or one of its dependencies could not be resolved: The following artifacts could not be resolved: org.cloudhoist:clojure-maven-mojo:jar:0.3.2, org.cloudhoist:clojure-maven-mojo-annotations:jar:0.3.2, org.cloudhoist:clojure-maven-plexus-component-factory:jar:0.3.2: Could not find artifact org.cloudhoist:clojure-maven-mojo:jar:0.3.2 in spring-maven-release (http://maven.springframework.org/release) -> [Help 1]
You need both sonatype repos: snapshots and releases. I make this clear on the README.
I believe we are closing in on the issue.
I modified my pom file to have both repositories and the batch file is working again. The debugging output is great ...
[DEBUG] [buildversion-plugin] Running cmd: git log -n 1 --format=%ct [DEBUG] [buildversion-plugin] Running cmd: git log -n 1 --format=%h %H [DEBUG] [buildversion-plugin] Running cmd: git log --oneline --decorate=short --first-parent [DEBUG] [buildversion-plugin] Processing git-log line: 6fa0a0d (HEAD, master) Initial ..... [DEBUG] [buildversion-plugin] Processing git-log line: daa9adf Initial commit of the SQL ... [DEBUG] [buildversion-plugin] Setting properties: [DEBUG] [buildversion-plugin] build-tag: N/A [DEBUG] [buildversion-plugin] build-version: N/A [DEBUG] [buildversion-plugin] build-tag-delta: 0 [DEBUG] [buildversion-plugin] build-tstamp: 20120816135306 [DEBUG] [buildversion-plugin] build-commit: 6fa0a0d21b2e5300953b8d5b347b8e44ff42150a [DEBUG] [buildversion-plugin] build-commit-abbrev: 6fa0a0d
However when I run it as part of an Eclipse "clean and build" I get this ...
8/22/12 9:09:20 AM CDT: [DEBUG] Created marker 'Execution default of goal com.code54.mojo:buildversion-plugin:1.0.1-SNAPSHOT:set-properties failed: Execution of Git command failed: fatal: Not a git repository (or any of the parent directories): .git
Which makes me believe that the git command is being executed from the wrong location.
I followed the eGit recommendation for setting up multiple Eclipse projects with Git. I have my Eclipse workspace in C:\ws\project and the git repository is in C:\git\repros. This means that Eclipse has a PWD of C:\ws\project but everything for the project actually lives under C:\git\repro. When command is executed it is from the be executed from the PWD ... C:\ws\project ... and it really should be from where the project files and Git is ... C:\git\repros.
Does that make sense?
If it were at all possible to allow another parameter to be provided to define the "git execution directory" ... it could default to the current location that it is assuming now, which I assume to be ${basedir} ... and then the ..
(apply sh/proc `(~git-cmd ~@args :dir ~project-dir))))
modified to change the directory ... I think the previous version with bash actually did this ... then the git command will have all of the situations covered.
Thanks for taking the time to work on this, Arvid
Try now with the latest 1.0.1-SNAPSHOT. I was using the current directory instead of Maven's basedir property
I am waiting for the repository to update with a newer version. The latest in sonotype is buildversion-plugin-1.0.1-20120821.040752-3.jar.
Thank you very much!!! The command line and the Eclipse 'Clean and Build' work exactly the same now. I really appreciate it.
From the command line ...
[DEBUG] Configuring mojo com.code54.mojo:buildversion-plugin:1.0.1-SNAPSHOT:set-properties from plugin realm ClassRealm[plugin>com.code54.mojo:buildversion-plugin:1.0.1-SNAPSHOT, parent: sun.misc.Launcher$AppClassLoader@6b6a3075] [DEBUG] Configuring mojo 'com.code54.mojo:buildversion-plugin:1.0.1-SNAPSHOT:set-properties' with basic configurator --> DEBUG project = MavenProject: ...:0.0.1-SNAPSHOT @ C:\git\repros...\pom.xml DEBUG base_dir = C:\git\repros... [DEBUG] -- end configuration -- [DEBUG] [buildversion-plugin] Running cmd: git log -n 1 --format=%ct [DEBUG] [buildversion-plugin] Running cmd: git log -n 1 --format=%h %H [DEBUG] [buildversion-plugin] Running cmd: git log --oneline --decorate=short --first-parent [DEBUG] [buildversion-plugin] Processing git-log line: 6fa0a0d (HEAD, master) Initial ... [DEBUG] [buildversion-plugin] Processing git-log line: daa9adf Initial ... [DEBUG] [buildversion-plugin] Setting properties: [DEBUG] [buildversion-plugin] build-tag: N/A [DEBUG] [buildversion-plugin] build-version: N/A [DEBUG] [buildversion-plugin] build-tag-delta: 0 [DEBUG] [buildversion-plugin] build-tstamp: 20120816135306 [DEBUG] [buildversion-plugin] build-commit: 6fa0a0d21b2e5300953b8d5b347b8e44ff42150a [DEBUG] [buildversion-plugin] build-commit-abbrev: 6fa0a0d
And from a 'Clean and Build" withing Maven
8/23/12 5:00:58 PM CDT: [DEBUG] Configuring mojo com.code54.mojo:buildversion-plugin:1.0.1-SNAPSHOT:set-properties from plugin realm ClassRealm[plugin>com.code54.mojo:buildversion-plugin:1.0.1-SNAPSHOT, parent: sun.misc.Launcher$AppClassLoader@3cecfaea] 8/23/12 5:00:59 PM CDT: [DEBUG] Configuring mojo 'com.code54.mojo:buildversion-plugin:1.0.1-SNAPSHOT:set-properties' with basic configurator --> 8/23/12 5:00:59 PM CDT: DEBUG project = MavenProject: ...:0.0.1-SNAPSHOT @ C:\git\repros...\pom.xml 8/23/12 5:00:59 PM CDT: DEBUG base_dir = C:\git\repros... 8/23/12 5:00:59 PM CDT: [DEBUG] -- end configuration -- 8/23/12 5:00:59 PM CDT: [DEBUG] [buildversion-plugin] Running cmd: git log -n 1 --format=%ct 8/23/12 5:00:59 PM CDT: [DEBUG] [buildversion-plugin] Running cmd: git log -n 1 --format=%h %H 8/23/12 5:00:59 PM CDT: [DEBUG] [buildversion-plugin] Running cmd: git log --oneline --decorate=short --first-parent 8/23/12 5:00:59 PM CDT: [DEBUG] [buildversion-plugin] Processing git-log line: 6fa0a0d (HEAD, master) Initial ... 8/23/12 5:00:59 PM CDT: [DEBUG] [buildversion-plugin] Processing git-log line: daa9adf Initial ... 8/23/12 5:00:59 PM CDT: [DEBUG] [buildversion-plugin] Setting properties: 8/23/12 5:00:59 PM CDT: [DEBUG] [buildversion-plugin] build-tag: N/A 8/23/12 5:00:59 PM CDT: [DEBUG] [buildversion-plugin] build-version: N/A 8/23/12 5:00:59 PM CDT: [DEBUG] [buildversion-plugin] build-tag-delta: 0 8/23/12 5:00:59 PM CDT: [DEBUG] [buildversion-plugin] build-tstamp: 20120816135306 8/23/12 5:00:59 PM CDT: [DEBUG] [buildversion-plugin] build-commit: 6fa0a0d21b2e5300953b8d5b347b8e44ff42150a 8/23/12 5:00:59 PM CDT: [DEBUG] [buildversion-plugin] build-commit-abbrev: 6fa0a0d 8/23/12 5:00:59 PM CDT: [DEBUG] Finished executing build participant org.eclipse.m2e.core.project.configurator.MojoExecutionBuildParticipant for plugin execution com.code54.mojo:buildversion-plugin:1.0.1-SNAPSHOT:set-properties (execution: default, phase: initialize) in 1402 ms
Thanks. I'll cut release 1.0.1 (non-snapshot) hopefully this weekend.
While trying to execute the plugin I get the following error ...
[ERROR] Failed to execute goal com.code54.mojo:buildversion-plugin:1.0.0:set-properties (default) on project antTest: Execution default of goal com.code54.mojo:buildversion-plugin:1.0.0:set-properties failed: For input string: "" -> [Help 1]
In the pom.xml I have the plugin configured ... cut-n-paste from the site page ...
The environment is:
bash.exe"-3.1$ git --version git version 1.7.11.msysgit.0
C:\ws\wr\eclipse\antTest>mvn -version Apache Maven 3.0.3 (r1075438; 2011-02-28 11:31:09-0600) Maven home: c:\springsource\apache-maven-3.0.3\bin.. Java version: 1.7.0_04, vendor: Oracle Corporation Java home: C:\Program Files\Java\jdk1.7.0_04\jre Default locale: en_US, platform encoding: Cp1252 OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"
And what appears to be the relevant part of the results from a "mvn -X compile" command ...
[DEBUG] com.code54.mojo:buildversion-plugin:jar:1.0.0: [DEBUG] org.clojure:clojure:jar:1.3.0:compile [DEBUG] org.cloudhoist:clojure-maven-mojo-annotations:jar:0.3.1:compile [DEBUG] org.cloudhoist:clojure-maven-plexus-component-factory:jar:0.3.1:runti me [DEBUG] org.apache.maven:maven-plugin-api:jar:3.0.4:compile [DEBUG] org.apache.maven:maven-model:jar:3.0.4:compile [DEBUG] org.codehaus.plexus:plexus-utils:jar:2.0.6:compile [DEBUG] org.apache.maven:maven-artifact:jar:3.0.4:compile [DEBUG] org.sonatype.sisu:sisu-inject-plexus:jar:2.3.0:compile [DEBUG] org.codehaus.plexus:plexus-component-annotations:jar:1.5.5:comp ile [DEBUG] org.codehaus.plexus:plexus-classworlds:jar:2.4:compile [DEBUG] org.sonatype.sisu:sisu-inject-bean:jar:2.3.0:compile [DEBUG] org.sonatype.sisu:sisu-guice:jar:no_aop:3.1.0:compile [DEBUG] org.sonatype.sisu:sisu-guava:jar:0.9.9:compile [DEBUG] conch:conch:jar:0.2.1:compile [DEBUG] Created new class realm plugin>com.code54.mojo:buildversion-plugin:1.0.0
[DEBUG] Importing foreign packages into class realm plugin>com.code54.mojo:build version-plugin:1.0.0 [DEBUG] Imported: < maven.api [DEBUG] Populating class realm plugin>com.code54.mojo:buildversion-plugin:1.0.0 [DEBUG] Included: com.code54.mojo:buildversion-plugin:jar:1.0.0 [DEBUG] Included: org.clojure:clojure:jar:1.3.0 [DEBUG] Included: org.cloudhoist:clojure-maven-mojo-annotations:jar:0.3.1 [DEBUG] Included: org.cloudhoist:clojure-maven-plexus-component-factory:jar:0. 3.1 [DEBUG] Included: org.codehaus.plexus:plexus-utils:jar:2.0.6 [DEBUG] Included: org.codehaus.plexus:plexus-component-annotations:jar:1.5.5 [DEBUG] Included: org.sonatype.sisu:sisu-inject-bean:jar:2.3.0 [DEBUG] Included: org.sonatype.sisu:sisu-guice:jar:no_aop:3.1.0 [DEBUG] Included: org.sonatype.sisu:sisu-guava:jar:0.9.9 [DEBUG] Included: conch:conch:jar:0.2.1 [DEBUG] Excluded: org.apache.maven:maven-plugin-api:jar:3.0.4 [DEBUG] Excluded: org.apache.maven:maven-model:jar:3.0.4 [DEBUG] Excluded: org.apache.maven:maven-artifact:jar:3.0.4 [DEBUG] Excluded: org.sonatype.sisu:sisu-inject-plexus:jar:2.3.0 [DEBUG] Excluded: org.codehaus.plexus:plexus-classworlds:jar:2.4 [DEBUG] Configuring mojo com.code54.mojo:buildversion-plugin:1.0.0:set-propertie s from plugin realm ClassRealm[plugin>com.code54.mojo:buildversion-plugin:1.0.0, parent: sun.misc.Launcher$AppClassLoader@6b6a3075] [DEBUG] Configuring mojo 'com.code54.mojo:buildversion-plugin:1.0.0:set-properti es' with basic configurator --> DEBUG project = MavenProject: asj.test.com:antTest:0.0.1-SNAPSHOT @ C:\w s\wr\eclipse\antTest\pom.xml [DEBUG] -- end configuration -- [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 1.836s [INFO] Finished at: Thu Aug 02 16:27:54 CDT 2012 [INFO] Final Memory: 11M/154M [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal com.code54.mojo:buildversion-plugin:1.0.0:set-pro perties (default) on project antTest: Execution default of goal com.code54.mojo: buildversion-plugin:1.0.0:set-properties failed: For input string: "" -> [Help 1 ]