[ http://jira.codehaus.org/browse/MNG-372?page=all ]
     
Brett Porter closed MNG-372:
----------------------------

    Fix Version: 2.0-alpha-2
     Resolution: Fixed

applied with modifications. 
- Made discovering the classworlds JAR in the bat file work.
- added back maven.home passing in maven-core-it.sh, your change didn't work if 
jvm_args was non-empty.

"All of this investigation led me to ask why you guys didn't use Ant instead of 
native scripts?!"

Because the hardest changes were in m2.bat and the m2 shell which we need to 
work anyway :)

Ultimately, m2 should build with itself as much as possible.


> 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
>
>
> 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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to