Author: brett Date: Wed Nov 16 19:39:28 2005 New Revision: 345178 URL: http://svn.apache.org/viewcvs?rev=345178&view=rev Log: fix bootstrap on Windows
Modified: maven/components/trunk/bootstrap.bat maven/components/trunk/bootstrap.sh maven/components/trunk/bootstrap/bootstrap-installer/src/main/java/org/apache/maven/bootstrap/installer/BootstrapInstaller.java maven/components/trunk/bootstrap/bootstrap-mini/ (props changed) maven/components/trunk/bootstrap/bootstrap-mini/build maven/components/trunk/bootstrap/bootstrap-mini/build.bat maven/components/trunk/bootstrap/bootstrap-mini/src/main/java/org/apache/maven/bootstrap/Bootstrap.java maven/components/trunk/bootstrap/bootstrap-mini/src/main/java/org/apache/maven/bootstrap/model/Repository.java maven/components/trunk/maven-core-it/maven-core-it.bat Modified: maven/components/trunk/bootstrap.bat URL: http://svn.apache.org/viewcvs/maven/components/trunk/bootstrap.bat?rev=345178&r1=345177&r2=345178&view=diff ============================================================================== --- maven/components/trunk/bootstrap.bat (original) +++ maven/components/trunk/bootstrap.bat Wed Nov 16 19:39:28 2005 @@ -126,7 +126,11 @@ :doBuild REM TODO: get rid of M2_HOME once integration tests are in here -%MAVEN_JAVA_EXE% %MAVEN_OPTS% -jar bootstrap\bootstrap-installer\target\bootstrap-installer.jar --prefix=%M2_HOME%\.. %BUILD_ARGS% +set PREFIX=%M2_HOME%\.. +set OLD_M2_HOME=%M2_HOME% +set M2_HOME= +%MAVEN_JAVA_EXE% %MAVEN_OPTS% -jar bootstrap\bootstrap-installer\target\bootstrap-installer.jar --prefix=%PREFIX% %BUILD_ARGS% +set M2_HOME=%OLD_M2_HOME% REM TODO: should we be going back to the mini now that we have the real thing? cd maven-core-it-verifier Modified: maven/components/trunk/bootstrap.sh URL: http://svn.apache.org/viewcvs/maven/components/trunk/bootstrap.sh?rev=345178&r1=345177&r2=345178&view=diff ============================================================================== --- maven/components/trunk/bootstrap.sh (original) +++ maven/components/trunk/bootstrap.sh Wed Nov 16 19:39:28 2005 @@ -7,16 +7,16 @@ cd bootstrap/bootstrap-mini ./build ret=$?; if [ $ret != 0 ]; then exit $ret; fi - java -jar target/bootstrap-mini.jar install $ARGS + java $MAVEN_OPTS -jar bootstrap-mini.jar install $ARGS ret=$?; if [ $ret != 0 ]; then exit $ret; fi ) ret=$?; if [ $ret != 0 ]; then exit $ret; fi -BOOTSTRAP_JAR=bootstrap-mini/target/bootstrap-mini.jar +BOOTSTRAP_JAR=bootstrap-mini/bootstrap-mini.jar ( cd bootstrap/bootstrap-installer - java -jar ../$BOOTSTRAP_JAR package $ARGS + java $MAVEN_OPTS -jar ../$BOOTSTRAP_JAR package $ARGS ret=$?; if [ $ret != 0 ]; then exit $ret; fi ) ret=$?; if [ $ret != 0 ]; then exit $ret; fi @@ -27,15 +27,31 @@ fi # TODO: get rid of M2_HOME once integration tests are in here -java -jar bootstrap/bootstrap-installer/target/bootstrap-installer.jar --prefix=`dirname $M2_HOME` $ARGS +PREFIX=`dirname $M2_HOME` + +# OS specific support. $var _must_ be set to either true or false. +cygwin=false; +case "`uname`" in + CYGWIN*) cygwin=true ;; +esac + +if [ "$cygwin" = "true" ]; then + PREFIX=`cygpath -w $PREFIX` + JAVA_HOME=`cygpath -w $JAVA_HOME` +fi + +OLD_M2_HOME=$M2_HOME +unset M2_HOME +java $MAVEN_OPTS -jar bootstrap/bootstrap-installer/target/bootstrap-installer.jar --prefix=$PREFIX $ARGS ret=$?; if [ $ret != 0 ]; then exit $ret; fi +M2_HOME=$OLD_M2_HOME ARGS=$ORIG_ARGS ( # TODO: should w ebe going back to the mini now that we have the real thing? cd maven-core-it-verifier - java -jar ../bootstrap/$BOOTSTRAP_JAR package $ARGS + java $MAVEN_OPTS -jar ../bootstrap/$BOOTSTRAP_JAR package $ARGS ret=$?; if [ $ret != 0 ]; then exit $ret; fi ) ret=$?; if [ $ret != 0 ]; then exit $ret; fi @@ -44,7 +60,7 @@ cd ./maven-core-it echo echo "Running maven-core integration tests ..." - echo + echo ./maven-core-it.sh $ARGS ret=$?; if [ $ret != 0 ]; then exit $ret; fi ) Modified: maven/components/trunk/bootstrap/bootstrap-installer/src/main/java/org/apache/maven/bootstrap/installer/BootstrapInstaller.java URL: http://svn.apache.org/viewcvs/maven/components/trunk/bootstrap/bootstrap-installer/src/main/java/org/apache/maven/bootstrap/installer/BootstrapInstaller.java?rev=345178&r1=345177&r2=345178&view=diff ============================================================================== --- maven/components/trunk/bootstrap/bootstrap-installer/src/main/java/org/apache/maven/bootstrap/installer/BootstrapInstaller.java (original) +++ maven/components/trunk/bootstrap/bootstrap-installer/src/main/java/org/apache/maven/bootstrap/installer/BootstrapInstaller.java Wed Nov 16 19:39:28 2005 @@ -186,54 +186,6 @@ } } - private Properties getEnvVars() - throws Exception - { - // TODO : put this method in Commandline class - Process p = null; - - Properties envVars = new Properties(); - - Runtime r = Runtime.getRuntime(); - - String os = System.getProperty( "os.name" ).toLowerCase(); - - //If this is windows set the shell to command.com or cmd.exe with correct arguments. - if ( os.indexOf( "Windows" ) != -1 ) - { - if (os.indexOf("95") != -1 || os.indexOf("98") != -1 || os.indexOf("Me") != -1) - { - p = r.exec( "command.com /c set" ); - } - else - { - p = r.exec( "cmd.exe /c set" ); - } - } - else - { - p = r.exec( "env" ); - } - - BufferedReader br = new BufferedReader( new InputStreamReader( p.getInputStream() ) ); - - String line; - - while( ( line = br.readLine() ) != null ) - { - int idx = line.indexOf( '=' ); - - String key = line.substring( 0, idx ); - - String value = line.substring( idx + 1 ); - - envVars.setProperty( key, value ); - // System.out.println( key + " = " + value ); - } - - return envVars; - } - private void runMaven( File installation, File basedir, String[] args ) throws Exception, InterruptedException { @@ -241,22 +193,6 @@ cli.setExecutable( new File( installation, "bin/mvn" ).getAbsolutePath() ); - // we need to add actual environment variable, because they don't added in commandline when - //we add new environment variables - Properties envVars = getEnvVars(); - - for ( Iterator i = envVars.keySet().iterator(); i.hasNext(); ) - { - String key = (String) i.next(); - - cli.addEnvironment( key, envVars.getProperty( key ) ); - } - - // TODO: should we just remove this from the equation? - cli.addEnvironment( "M2_HOME", installation.getAbsolutePath() ); - // No env is passed through - cli.addEnvironment( "JAVA_HOME", System.getProperty( "java.home" ) ); - cli.setWorkingDirectory( basedir.getAbsolutePath() ); cli.createArgument().setValue( "-e" ); @@ -311,18 +247,19 @@ { Dependency dep = (Dependency) i.next(); + File artifactFile = bootstrapper.getArtifactFile( dep ); if ( dep.getArtifactId().equals( "classworlds" ) ) { - FileUtils.copyFileToDirectory( bootstrapper.getArtifactFile( dep ), bootDirectory ); + FileUtils.copyFileToDirectory( artifactFile, bootDirectory ); } else if ( dep.getArtifactId().equals( "plexus-container-default" ) || dep.getArtifactId().equals( "plexus-utils" ) ) { - FileUtils.copyFileToDirectory( bootstrapper.getArtifactFile( dep ), coreDirectory ); + FileUtils.copyFileToDirectory( artifactFile, coreDirectory ); } else { - FileUtils.copyFileToDirectory( bootstrapper.getArtifactFile( dep ), libDirectory ); + FileUtils.copyFileToDirectory( artifactFile, libDirectory ); } } Propchange: maven/components/trunk/bootstrap/bootstrap-mini/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Wed Nov 16 19:39:28 2005 @@ -1,2 +1,3 @@ *.iml target +bootstrap-mini.jar Modified: maven/components/trunk/bootstrap/bootstrap-mini/build URL: http://svn.apache.org/viewcvs/maven/components/trunk/bootstrap/bootstrap-mini/build?rev=345178&r1=345177&r2=345178&view=diff ============================================================================== --- maven/components/trunk/bootstrap/bootstrap-mini/build (original) +++ maven/components/trunk/bootstrap/bootstrap-mini/build Wed Nov 16 19:39:28 2005 @@ -4,12 +4,12 @@ classesDir=${buildDir}/classes srcDir=src/main/java -rm -rf ${buildDir} > /dev/null 2>&1 +rm -rf bootstrap-mini.jar ${buildDir} > /dev/null 2>&1 mkdir -p ${classesDir} "$JAVA_HOME/bin/javac" -g -d ${classesDir} `find ${srcDir} -name '*.java'` ret=$?; if [ $ret != 0 ]; then exit $ret; fi -( cd ${classesDir} ; "$JAVA_HOME/bin/jar" -cfm ../bootstrap-mini.jar ../../src/main/resources/META-INF/MANIFEST.MF * ) +( cd ${classesDir} ; "$JAVA_HOME/bin/jar" -cfm ../../bootstrap-mini.jar ../../src/main/resources/META-INF/MANIFEST.MF * ) ret=$?; if [ $ret != 0 ]; then exit $ret; fi Modified: maven/components/trunk/bootstrap/bootstrap-mini/build.bat URL: http://svn.apache.org/viewcvs/maven/components/trunk/bootstrap/bootstrap-mini/build.bat?rev=345178&r1=345177&r2=345178&view=diff ============================================================================== --- maven/components/trunk/bootstrap/bootstrap-mini/build.bat (original) +++ maven/components/trunk/bootstrap/bootstrap-mini/build.bat Wed Nov 16 19:39:28 2005 @@ -10,10 +10,12 @@ mkdir %buildDir% mkdir %classesDir% +del bootstrap-mini.jar + dir /B /s %srcDir%\*.java >sources "%JAVA_HOME%\bin\javac" -d %classesDir% @sources del /F/Q sources cd %classesDir% -"%JAVA_HOME%\bin\jar" -cfm ..\bootstrap-mini.jar ..\..\src\main\resources\META-INF\MANIFEST.MF *.* +"%JAVA_HOME%\bin\jar" -cfm ..\..\bootstrap-mini.jar ..\..\src\main\resources\META-INF\MANIFEST.MF *.* cd ..\.. Modified: maven/components/trunk/bootstrap/bootstrap-mini/src/main/java/org/apache/maven/bootstrap/Bootstrap.java URL: http://svn.apache.org/viewcvs/maven/components/trunk/bootstrap/bootstrap-mini/src/main/java/org/apache/maven/bootstrap/Bootstrap.java?rev=345178&r1=345177&r2=345178&view=diff ============================================================================== --- maven/components/trunk/bootstrap/bootstrap-mini/src/main/java/org/apache/maven/bootstrap/Bootstrap.java (original) +++ maven/components/trunk/bootstrap/bootstrap-mini/src/main/java/org/apache/maven/bootstrap/Bootstrap.java Wed Nov 16 19:39:28 2005 @@ -734,7 +734,11 @@ throw new FileNotFoundException( "Missing dependency: " + dependency + msg ); } - cl.addURL( f.toURL() ); + // Classes won't be unloaded, but we might delete the JAR, so they need to be copied to a temporary location + File newFile = File.createTempFile( "maven-bootstrap", "dep" ); + newFile.deleteOnExit(); + FileUtils.copyFile( f, newFile ); + cl.addURL( newFile.toURL() ); } return cl; Modified: maven/components/trunk/bootstrap/bootstrap-mini/src/main/java/org/apache/maven/bootstrap/model/Repository.java URL: http://svn.apache.org/viewcvs/maven/components/trunk/bootstrap/bootstrap-mini/src/main/java/org/apache/maven/bootstrap/model/Repository.java?rev=345178&r1=345177&r2=345178&view=diff ============================================================================== --- maven/components/trunk/bootstrap/bootstrap-mini/src/main/java/org/apache/maven/bootstrap/model/Repository.java (original) +++ maven/components/trunk/bootstrap/bootstrap-mini/src/main/java/org/apache/maven/bootstrap/model/Repository.java Wed Nov 16 19:39:28 2005 @@ -54,14 +54,6 @@ this.releases = releases; } - private File getArtifactFile( String groupId, String artifactId, String version, String type ) - { - Dependency d = new Dependency( groupId, artifactId, version, type, Collections.EMPTY_LIST ); - - return getArtifactFile( d ); - - } - public File getArtifactFile( Dependency dependency ) { String repositoryPath = getArtifactPath( dependency ); Modified: maven/components/trunk/maven-core-it/maven-core-it.bat URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core-it/maven-core-it.bat?rev=345178&r1=345177&r2=345178&view=diff ============================================================================== --- maven/components/trunk/maven-core-it/maven-core-it.bat (original) +++ maven/components/trunk/maven-core-it/maven-core-it.bat Wed Nov 16 19:39:28 2005 @@ -20,5 +20,5 @@ @REM NOTE: for simplicity, only Windows NT/2000/XP is current supported @REM This also assumes that M2_HOME and JAVA_HOME are set, which are verified in the bootstrap script only -"%JAVA_HOME%\bin\java.exe" -Dmaven.home="%M2_HOME%" -cp "..\maven-core-it-verifier\target\maven-core-it-verifier-1.0.jar" org.apache.maven.it.Verifier %* +"%JAVA_HOME%\bin\java.exe" -Dmaven.home="%M2_HOME%" %MAVEN_OPTS% -cp "..\maven-core-it-verifier\target\maven-core-it-verifier.jar" org.apache.maven.it.Verifier %*