You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by "Mark Hobson (JIRA)" <ji...@codehaus.org> on 2005/05/10 17:27:29 UTC
[jira] Commented: (MNG-372) Cannot build m2 with spaces in M2_HOME and/or JAVA_HOME
[ http://jira.codehaus.org/browse/MNG-372?page=comments#action_38824 ]
Mark Hobson commented on MNG-372:
---------------------------------
The cygpath -p switch was introduced when qualifying M2_HOME under cygwin - this produces an invalid maven.home property when passed into MBoot, e.g.:
[mark@mark components]$ echo $M2_HOME
C:\Program Files\maven-2.0
[mark@mark components]$ cygpath -pw "$M2_HOME"
C;c:\Program Files\maven-2.0
Results in:
Exception in thread "main" java.io.FileNotFoundException: c:\Documents and Settings\mark\My Documents\projects\oss\maven
\components\C;c:\Program Files\maven-2.0\bin\m2 (The filename, directory name, or volume label syntax is incorrect)
at java.io.FileOutputStream.open(Native Method)
at java.io.FileOutputStream.<init>(FileOutputStream.java:179)
at java.io.FileOutputStream.<init>(FileOutputStream.java:131)
at util.FileUtils.copyFile(FileUtils.java:726)
at util.FileUtils.copyFileToDirectory(FileUtils.java:686)
at util.FileUtils.copyFileToDirectory(FileUtils.java:663)
at MBoot.run(MBoot.java:382)
at MBoot.main(MBoot.java:117)
patch3.txt fixes this.
> Cannot build m2 with spaces in M2_HOME and/or JAVA_HOME
> -------------------------------------------------------
>
> Key: MNG-372
> URL: http://jira.codehaus.org/browse/MNG-372
> Project: m2
> Type: Bug
> Versions: 2.0-alpha-1
> Environment: Windows XP, Cygwin.
> Reporter: Mark Hobson
> Fix For: 2.0-alpha-2
> Attachments: patch, patch2.txt
>
>
> There are numerous problems when trying to build m2 in Windows when JAVA_HOME or M2_HOME contains spaces. The attached patch fixes enough of the scripts to build m2 under cygwin, but there still exist several major flaws when using the .bat versions.
> To detail the various problems, I shall annotate the patch here:
> > Index: m2-bootstrap-all.sh
> > ===================================================================
> > @@ -1,7 +1,7 @@
> > -[ -z $JAVA_HOME ] && echo && echo 'You must set $JAVA_HOME to use mboot!' && echo && exit 1
> > +[ -z "$JAVA_HOME" ] && echo && echo 'You must set $JAVA_HOME to use mboot!' && echo && exit 1
> Quote for spaces in JAVA_HOME.
>
> > @@ -19,7 +19,11 @@
> > - ARGS="$ARGS -Dmaven.home=$M2_HOME"
> > + if [ -n "$ARGS" ]; then
> > + ARGS="$ARGS -Dmaven.home=$M2_HOME"
> > + else
> > + ARGS="-Dmaven.home=$M2_HOME"
> > + fi
> Previously, if no ARGS are supplied then "$ARGS" equates to " -Dmaven.home=$M2_HOME" which is not recognised by javac and a typical -D arg. Basically ARGS cannot start or end with a space when later quoted.
>
> > @@ -39,7 +43,7 @@
> > - $JAVACMD $ARGS $MAVEN_OPTS -jar mboot.jar
> > + "$JAVACMD" "$ARGS" $MAVEN_OPTS -jar mboot.jar
> First quote for spaces in JAVA_HOME, second for spaces in M2_HOME. Not sure if "$ARGS" works for multiple arguments with spaces, i.e. "-Dprop1=C:/Program Files/a -Dprop2=C:/Program Files/b". From previous experience I seem to remember having to quote each -D seperately..
> > Index: maven-core/src/bin/m2.bat
> > ===================================================================
> > @@ -127,7 +127,7 @@
> > -%MAVEN_JAVA_EXE% %MAVEN_OPTS% -classpath %M2_HOME%\core\boot\classworlds-*.jar "-Dclassworlds.conf=%M2_HOME%\bin\m2.conf" "-Dmaven.home=%M2_HOME%" org.codehaus.classworlds.Launcher %MAVEN_CMD_LINE_ARGS%
> > +%MAVEN_JAVA_EXE% %MAVEN_OPTS% -classpath "%M2_HOME%\core\boot\classworlds-1.1-alpha-1.jar" "-Dclassworlds.conf=%M2_HOME%\bin\m2.conf" "-Dmaven.home=%M2_HOME%" org.codehaus.classworlds.Launcher %MAVEN_CMD_LINE_ARGS%
> m2.bat gets called eventually via the script even under cygwin, hence this fix. Normal quote for M2_HOME in -classpath here, but also the classworlds-*.jar part does not work under Windows when fully qualified. i.e. Within M2_HOME/core/boot a javac -cp classworlds-*.jar will work, but not once it's fully qualified as it is here. Not an ideal solution as we have to hardcode the classworlds version.
>
> > Index: maven-core/src/bin/m2
> > ===================================================================
> > @@ -126,7 +126,7 @@
> > -exec $JAVACMD \
> > +exec "$JAVACMD" \
> Quoted for spaces in JAVA_HOME.
> > Index: maven-mboot2/build
> > ===================================================================
> > @@ -9,8 +9,8 @@
> > -$JAVA_HOME/bin/javac -g -d ${classesDir} `find ${srcDir} -name '*.java'`
> > +"$JAVA_HOME/bin/javac" -g -d ${classesDir} `find ${srcDir} -name '*.java'`
> Quoted for spaces in JAVA_HOME.
>
> > -( cd ${classesDir} ; $JAVA_HOME/bin/jar -cfm ../mboot.jar ../../manifest.txt * )
> > +( cd ${classesDir} ; "$JAVA_HOME/bin/jar" -cfm ../mboot.jar ../../manifest.txt * )
> Quoted for spaces in JAVA_HOME.
>
> > Index: maven-core-it/maven-core-it.sh
> > ===================================================================
> > @@ -25,9 +25,5 @@
> > -if [ ! -z "$M2_HOME" ]; then
> > - jvm_args="$jvm_args -Dmaven.home=$M2_HOME"
> > -fi
> Potentially controversial, but maven-core-it.sh receives -Dmaven.home in it's args from the parent calling script, so applying this again here causes the following args to be used:
> -Dmaven.home=C:/Program Files/maven2 -Dmaven.home=C:/Program Files/maven2
> Which when quoted, results in maven.home equalling "C:/Program Files/maven2 -Dmaven.home=C:/Program Files/maven2". This is a symptom of quoting multiple args with spaces as described above.
> > +java "$jvm_args" -cp "$cp" $verifier
> > -java $jvm_args -cp "$cp" $verifier
> Quoted for spaces in M2_HOME.
> I started to look at fixing the bat files for the pure Windows build, but came across fundamental problems in maven-mboot2/build.bat - the @argfile form of javac only works under Windows if any paths with spaces are quoted within it. So knowing the 'power' of DOS, this didn't seem an easy task.
> All of this investigation led me to ask why you guys didn't use Ant instead of native scripts?!
> Any feedback would be welcome, cheers.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org