tags:

views:

247

answers:

1

I have an <exec-maven-plugin> which calls an external command (in this case, svnversion). The command is in the path for the current user.

However, when a separate shell is spawned by the plugin, the path is not initialized. I don't want to hardcode or define a variable for each external command (there would be too much to maintain, especially that there are both Windows and *nix users).

My pom.xml contains the following:

  <plugin>
 <groupId>org.codehaus.mojo</groupId>
 <artifactId>exec-maven-plugin</artifactId>
 <version>1.1</version>
 <executions>
  <execution>
   <id>svnversion-exec</id>
   <phase>process-resources</phase>
   <goals>
    <goal>exec</goal>
   </goals>
   <configuration>
    <executable>svnversion</executable>
    <arguments>
     <argument><![CDATA[ >version.txt ]]></argument>
    </arguments>
   </configuration>
  </execution>
 </executions>
  </plugin>

Currently I get the following output:

[INFO] [exec:exec {execution: svnversion-exec}] 'svnversion' is not recognized as an internal or external command, operable program or batch file.

[ERROR] BUILD ERROR: Result of cmd.exe /X /C "svnversion >version.txt" execution is: '1'.

Thank you!

A: 

That's weird because as written in the documentation, the executable parameter is not necessarily the full path to an executable:

The executable. Can be a full path or a the name executable. In the latter case, the executable must be in the PATH for the execution to work.

And on my machine (where svnversion is in /usr/bin/ which is in the PATH), the configuration you posted just works (I used the exact same snippet):

$ mvn process-resources
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building Q2821100
[INFO]    task-segment: [process-resources]
[INFO] ------------------------------------------------------------------------
[INFO] [resources:resources {execution: default-resources}]
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/pascal/Projects/stackoverflow/Q2821100/src/main/resources
[INFO] [exec:exec {execution: svnversion-exec}]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5 seconds
[INFO] Finished at: Wed May 12 21:30:35 CEST 2010
[INFO] Final Memory: 7M/87M
[INFO] ------------------------------------------------------------------------
$ cat version.txt 
exported

Maybe double check the PATH of the user that is running maven. Also, why do you say that a shell is spawned? Who is spawning that shell?

Pascal Thivent
Hmm - my comment added yesterday is gone. I was saying that on Windows a new shell (cmd.exe) is spawned by the plugin, this doesn't seem to be happening on Linux.
wishihadabettername
@wishihadabettername Ah, wasn't aware of that (I'm under Linux) and I can't find any mention of this, weird. On top of that, I don't get why the spawned shell is not inheriting the environment of the user. Really weird.
Pascal Thivent
I use windows and no shell pops up for me, everything works just fine
seanizer
@seanizer Thanks for confirming this. The OP's issue has to be environment related then.
Pascal Thivent