Tuesday, January 6, 2009

Maven JNLP Jar Install Issue

While researching the creation of a POM for a JNLP Java Swing project, I came accross the following helpful Maven code to install a JNLP jar file via the command line:

mvn install:install-file -Dfile=%JAVA_HOME%\sample\jnlp\servlet\jnlp-servlet.jar \
-DgroupId=com.sun.java.jnlp -DartifactId=jnlp-servlet -Dversion=5.0 \
-Dpackaging=jar -DgeneratePom=true

This works fine if your %JAVA_HOME% variable doesn't contain whitespace. If it does, the Stacktrace below occurs.

Solution
Add double quotes to the file parameter as follows:

mvn install:install-file -Dfile="%JAVA_HOME%\sample\jnlp\servlet\jnlp-servlet.jar" -DgroupId=com.sun.java.jnlp -DartifactId=jnlp-servlet -Dversion=5.0 -Dpackaging=jar -DgeneratePom=true -e

Stacktrace


mvn install:install-file -Dfile=%JAVA_HOME%\sample\jnlp\servlet\jnlp-servlet.jar \
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'install'.
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE

[INFO] ------------------------------------------------------------------------
[INFO] Invalid task 'Files\Java\jdk1.6.0_06\sample\jnlp\servlet\jnlp-servlet.jar': you must specify a valid lifecycle phase, or a goal in the format plugin:goal or pluginGroupId:pluginArtifactId:pluginVersion:goal
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: <>
[INFO] Finished at: Tue Jan 06 11:02:13 CST 2009
[INFO] Final Memory: 1M/4M
[INFO] ------------------------------------------------------------------------
C:\JBuilder2007\workspace\H2HAdmin\bin>-DgroupId=com.sun.java.jnlp -DartifactId=jnlp-servlet -Dversion=5.0 \'-DgroupId' is not recognized as an internal or external command,operable program or batch file.
C:\JBuilder2007\workspace\H2HAdmin\bin>-Dpackaging=jar -DgeneratePom=true


References


http://mojo.codehaus.org/webstart/webstart-maven-plugin/jnlp101.html