How do I inherit the current path when calling Maven exec-maven-plugin?

I have <exec-maven-plugin>

one that calls an external command (in this case svnversion

). The command is in the path for the current user.

However, when a separate wrapper is generated by a plugin, the path is not initialized. I don't want to hardcode or define a variable for every external command (it would be too much to maintain, especially for 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>

      

I am currently getting 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'.

Thanks!

+2


a source to share


2 answers


This is weird because, as the documentation says, the parameter is executable

not necessarily the full path to the executable:

Executable file. Can be the full path or name of the executable file. In the latter case, the executable must be in the PATH to do the job.

And on my machine (where svnversion

is at /usr/bin/

, which is at PATH

), the configuration you just performed (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

user who is running maven. Also, why are you saying the shell is spawned? Who generates this shell?

0


a source


I read this :

The plugin will search for an executable file in the following order:

  • relative to the project root
  • as toolchain executable
  • relative to working directory (Windows only)
  • relative to the directories specified in the system PATH property (Windows only)


Otherwise, use the executable as is.

So, "Windows Only"!

0


a source







All Articles