Typical maven release:prepare problems

Today I experienced two new maven problem that took me some time to understand, both of which appeared when running the mvn release:preare goal. The first problem was a show-stopper in that it refused to run, giving me the following error:

Cannot run program "mvn" (in directory "/opt/hudson/.hudson/jobs/MySuperApp/workspace"): java.io.IOException: error=2, No such file or directory
at java.lang.ProcessBuilder.start(ProcessBuilder.java:460)

It basically says that mvn cannot be found – even though I just started the problem. When I analyzed the stacktrace I found a clue to what was happening: «…ForkedMavenExecutor.executeCommandLine…».
Maven makes a fork of its own process. I am not sure whether commands executed in this forked process go through the shell, but one thing was clear; it does not make use of any aliases you might have defined. And since the maven binary was not in my PATH, but simply defined as an alias to the executable in the maven directoy, the forked process could not execute it. The simple fix was to add the path containing the maven binary to the PATH (for instance in .bashrc). My path now looks like: /usr/local/bin:/usr/bin:/usr/X11R6/bin:/bin:/opt/tools/apache-maven-3.0.3/bin

The other problem was revealed now that the goal was running. Even though I had specified -Dmaven.test.skip on the commandline, the tests still ran. Turns out you need to make a hack to get the arguments to pass through. Just pack all the arguments into -Darguments=’your arguments here’, e.g. -Darguments='-Dmaven.test.skip=true'

Legg igjen en kommentar

Fyll inn i feltene under, eller klikk på et ikon for å logge inn:


Du kommenterer med bruk av din WordPress.com konto. Logg ut / Endre )

Twitter picture

Du kommenterer med bruk av din Twitter konto. Logg ut / Endre )


Du kommenterer med bruk av din Facebook konto. Logg ut / Endre )

Google+ photo

Du kommenterer med bruk av din Google+ konto. Logg ut / Endre )

Kobler til %s

%d bloggers like this: