fix bootstrap on Windows

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@345178 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Leslie Porter 2005-11-17 03:39:28 +00:00
parent 3c5f84b6b6
commit e30e6ca949
8 changed files with 42 additions and 87 deletions

View File

@ -126,7 +126,11 @@ set BUILD_ARGS=%MAVEN_CMD_LINE_ARGS% --build-plugins --plugins-directory=%PLUGIN
:doBuild :doBuild
REM TODO: get rid of M2_HOME once integration tests are in here 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? REM TODO: should we be going back to the mini now that we have the real thing?
cd maven-core-it-verifier cd maven-core-it-verifier

View File

@ -7,16 +7,16 @@ ORIG_ARGS=$ARGS
cd bootstrap/bootstrap-mini cd bootstrap/bootstrap-mini
./build ./build
ret=$?; if [ $ret != 0 ]; then exit $ret; fi 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
) )
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 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
) )
ret=$?; if [ $ret != 0 ]; then exit $ret; fi ret=$?; if [ $ret != 0 ]; then exit $ret; fi
@ -27,15 +27,31 @@ if [ -d $PLUGINS_DIR ]; then
fi fi
# TODO: get rid of M2_HOME once integration tests are in here # 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 ret=$?; if [ $ret != 0 ]; then exit $ret; fi
M2_HOME=$OLD_M2_HOME
ARGS=$ORIG_ARGS ARGS=$ORIG_ARGS
( (
# TODO: should w ebe going back to the mini now that we have the real thing? # TODO: should w ebe going back to the mini now that we have the real thing?
cd maven-core-it-verifier 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
) )
ret=$?; if [ $ret != 0 ]; then exit $ret; fi ret=$?; if [ $ret != 0 ]; then exit $ret; fi

View File

@ -186,54 +186,6 @@ public class BootstrapInstaller
} }
} }
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 ) private void runMaven( File installation, File basedir, String[] args )
throws Exception, InterruptedException throws Exception, InterruptedException
{ {
@ -241,22 +193,6 @@ public class BootstrapInstaller
cli.setExecutable( new File( installation, "bin/mvn" ).getAbsolutePath() ); 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.setWorkingDirectory( basedir.getAbsolutePath() );
cli.createArgument().setValue( "-e" ); cli.createArgument().setValue( "-e" );
@ -311,18 +247,19 @@ public class BootstrapInstaller
{ {
Dependency dep = (Dependency) i.next(); Dependency dep = (Dependency) i.next();
File artifactFile = bootstrapper.getArtifactFile( dep );
if ( dep.getArtifactId().equals( "classworlds" ) ) if ( dep.getArtifactId().equals( "classworlds" ) )
{ {
FileUtils.copyFileToDirectory( bootstrapper.getArtifactFile( dep ), bootDirectory ); FileUtils.copyFileToDirectory( artifactFile, bootDirectory );
} }
else if ( dep.getArtifactId().equals( "plexus-container-default" ) || else if ( dep.getArtifactId().equals( "plexus-container-default" ) ||
dep.getArtifactId().equals( "plexus-utils" ) ) dep.getArtifactId().equals( "plexus-utils" ) )
{ {
FileUtils.copyFileToDirectory( bootstrapper.getArtifactFile( dep ), coreDirectory ); FileUtils.copyFileToDirectory( artifactFile, coreDirectory );
} }
else else
{ {
FileUtils.copyFileToDirectory( bootstrapper.getArtifactFile( dep ), libDirectory ); FileUtils.copyFileToDirectory( artifactFile, libDirectory );
} }
} }

View File

@ -4,12 +4,12 @@ buildDir=target
classesDir=${buildDir}/classes classesDir=${buildDir}/classes
srcDir=src/main/java srcDir=src/main/java
rm -rf ${buildDir} > /dev/null 2>&1 rm -rf bootstrap-mini.jar ${buildDir} > /dev/null 2>&1
mkdir -p ${classesDir} mkdir -p ${classesDir}
"$JAVA_HOME/bin/javac" -g -d ${classesDir} `find ${srcDir} -name '*.java'` "$JAVA_HOME/bin/javac" -g -d ${classesDir} `find ${srcDir} -name '*.java'`
ret=$?; if [ $ret != 0 ]; then exit $ret; fi 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 ret=$?; if [ $ret != 0 ]; then exit $ret; fi

View File

@ -10,10 +10,12 @@ if exist %buildDir% rmdir /S/Q %buildDir%
mkdir %buildDir% mkdir %buildDir%
mkdir %classesDir% mkdir %classesDir%
del bootstrap-mini.jar
dir /B /s %srcDir%\*.java >sources dir /B /s %srcDir%\*.java >sources
"%JAVA_HOME%\bin\javac" -d %classesDir% @sources "%JAVA_HOME%\bin\javac" -d %classesDir% @sources
del /F/Q sources del /F/Q sources
cd %classesDir% 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 ..\.. cd ..\..

View File

@ -734,7 +734,11 @@ public class Bootstrap
throw new FileNotFoundException( "Missing dependency: " + dependency + msg ); 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; return cl;

View File

@ -54,14 +54,6 @@ public class Repository
this.releases = releases; 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 ) public File getArtifactFile( Dependency dependency )
{ {
String repositoryPath = getArtifactPath( dependency ); String repositoryPath = getArtifactPath( dependency );

View File

@ -20,5 +20,5 @@
@REM NOTE: for simplicity, only Windows NT/2000/XP is current supported @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 @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 %*