Author: jvanzyl Date: Wed Oct 4 20:38:17 2006 New Revision: 453100 URL: http://svn.apache.org/viewvc?view=rev&rev=453100 Log: MNG-2560 patch applied to make the bootstrap easier Submitted by: Dan Fabulich
Modified: maven/components/branches/maven-2.0.x/README.txt maven/components/branches/maven-2.0.x/bootstrap.bat maven/components/branches/maven-2.0.x/bootstrap.sh maven/components/branches/maven-2.0.x/bootstrap/bootstrap-installer/src/main/java/org/apache/maven/bootstrap/installer/BootstrapInstaller.java maven/components/branches/maven-2.0.x/bootstrap/bootstrap-mini/src/main/java/org/apache/maven/bootstrap/Bootstrap.java Modified: maven/components/branches/maven-2.0.x/README.txt URL: http://svn.apache.org/viewvc/maven/components/branches/maven-2.0.x/README.txt?view=diff&rev=453100&r1=453099&r2=453100 ============================================================================== --- maven/components/branches/maven-2.0.x/README.txt (original) +++ maven/components/branches/maven-2.0.x/README.txt Wed Oct 4 20:38:17 2006 @@ -9,6 +9,9 @@ or export PATH=$PATH:$M2_HOME/bin +In addition, the last part of the M2_HOME path MUST be of the form maven-$version, eg: +/usr/local/maven-2.1-SNAPSHOT + You can set the parameters passed to the Java VM when running Maven2 bootstrap, setting the environment variable MAVEN_OPTS, e.g. e.g. to run in offline mode, set MAVEN_OPTS=-o Modified: maven/components/branches/maven-2.0.x/bootstrap.bat URL: http://svn.apache.org/viewvc/maven/components/branches/maven-2.0.x/bootstrap.bat?view=diff&rev=453100&r1=453099&r2=453100 ============================================================================== --- maven/components/branches/maven-2.0.x/bootstrap.bat (original) +++ maven/components/branches/maven-2.0.x/bootstrap.bat Wed Oct 4 20:38:17 2006 @@ -108,10 +108,12 @@ call .\build copy target\bootstrap-mini.jar .. -%MAVEN_JAVA_EXE% %MAVEN_OPTS% -jar ..\bootstrap-mini.jar install %MAVEN_CMD_LINE_ARGS% +%MAVEN_JAVA_EXE% %MAVEN_OPTS% -Djava.compiler=NONE -jar ..\bootstrap-mini.jar install %MAVEN_CMD_LINE_ARGS% +if ERRORLEVEL 1 goto error cd ..\bootstrap-installer %MAVEN_JAVA_EXE% %MAVEN_OPTS% -jar ..\bootstrap-mini.jar package %MAVEN_CMD_LINE_ARGS% +if ERRORLEVEL 1 goto error cd ..\.. set PLUGINS_DIR=..\plugins @@ -126,15 +128,19 @@ :doBuild REM TODO: get rid of M2_HOME once integration tests are in here -set PREFIX=%M2_HOME%\.. +set DESTDIR=%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% +%MAVEN_JAVA_EXE% %MAVEN_OPTS% -jar bootstrap\bootstrap-installer\target\bootstrap-installer.jar --destDir=%DESTDIR% %BUILD_ARGS% +REM %MAVEN_JAVA_EXE% %MAVEN_OPTS% -Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -jar bootstrap\bootstrap-installer\target\bootstrap-installer.jar --destDir=%DESTDIR% %BUILD_ARGS% + set M2_HOME=%OLD_M2_HOME% +if ERRORLEVEL 1 goto error REM TODO: should we be going back to the mini now that we have the real thing? cd maven-core-it-verifier %MAVEN_JAVA_EXE% %MAVEN_OPTS% -jar ..\bootstrap\bootstrap-mini.jar package %MAVEN_CMD_LINE_ARGS% +if ERRORLEVEL 1 goto error cd .. @@ -147,6 +153,15 @@ cd maven-core-it call maven-core-it %MAVEN_CMD_LINE_ARGS% cd .. + +if ERRORLEVEL 1 goto error +goto end + +:error +echo ----------------------------------------------------------------------- +echo BUILD FAILED +echo ----------------------------------------------------------------------- + :end @REM set local scope for the variables with windows NT shell Modified: maven/components/branches/maven-2.0.x/bootstrap.sh URL: http://svn.apache.org/viewvc/maven/components/branches/maven-2.0.x/bootstrap.sh?view=diff&rev=453100&r1=453099&r2=453100 ============================================================================== --- maven/components/branches/maven-2.0.x/bootstrap.sh (original) +++ maven/components/branches/maven-2.0.x/bootstrap.sh Wed Oct 4 20:38:17 2006 @@ -29,7 +29,7 @@ ret=$?; if [ $ret != 0 ]; then exit $ret; fi # TODO: get rid of M2_HOME once integration tests are in here -PREFIX=`dirname $M2_HOME` +DESTDIR=$M2_HOME # OS specific support. $var _must_ be set to either true or false. cygwin=false; @@ -38,13 +38,13 @@ esac if [ "$cygwin" = "true" ]; then - PREFIX=`cygpath -w $PREFIX` + DESTDIR=`cygpath -w $DESTDIR` JAVA_HOME=`cygpath -w $JAVA_HOME` fi OLD_M2_HOME=$M2_HOME unset M2_HOME -$JAVACMD $MAVEN_OPTS -jar bootstrap/bootstrap-installer/target/bootstrap-installer.jar --prefix=$PREFIX $ARGS +$JAVACMD $MAVEN_OPTS -jar bootstrap/bootstrap-installer/target/bootstrap-installer.jar --destDir=$DESTDIR $ARGS ret=$?; if [ $ret != 0 ]; then exit $ret; fi M2_HOME=$OLD_M2_HOME export M2_HOME Modified: maven/components/branches/maven-2.0.x/bootstrap/bootstrap-installer/src/main/java/org/apache/maven/bootstrap/installer/BootstrapInstaller.java URL: http://svn.apache.org/viewvc/maven/components/branches/maven-2.0.x/bootstrap/bootstrap-installer/src/main/java/org/apache/maven/bootstrap/installer/BootstrapInstaller.java?view=diff&rev=453100&r1=453099&r2=453100 ============================================================================== --- maven/components/branches/maven-2.0.x/bootstrap/bootstrap-installer/src/main/java/org/apache/maven/bootstrap/installer/BootstrapInstaller.java (original) +++ maven/components/branches/maven-2.0.x/bootstrap/bootstrap-installer/src/main/java/org/apache/maven/bootstrap/installer/BootstrapInstaller.java Wed Oct 4 20:38:17 2006 @@ -47,7 +47,7 @@ private final Bootstrap bootstrapper; - private final String prefix; + private final String destDir; private String pluginsDirectory; @@ -62,7 +62,7 @@ { this.bootstrapper = new Bootstrap( parser ); - this.prefix = parser.getArgumentValue( "--prefix" ); + this.destDir = parser.getArgumentValue( "--destDir" ); this.buildPlugins = parser.isArgumentSet( "--build-plugins" ); @@ -78,7 +78,7 @@ throws Exception { SimpleArgumentParser parser = Bootstrap.createDefaultParser(); - parser.addArgument( "--prefix", "The location to install Maven", true, getDefaultPrefix() ); + parser.addArgument( "--destDir", "The location to install Maven", true, getDefaultPrefix() ); parser.addArgument( "--build-plugins", "Build the plugins from SVN" ); parser.addArgument( "--plugins-directory", "Where the plugins are located to build from", true ); parser.addArgument( "--update-snapshots", "Update snapshots during build" ); @@ -117,6 +117,17 @@ // buildProject( basedir, "", resolver, false ); // buildProject( basedir, "maven-artifact-manager", resolver ); + Model mavenRootModel = bootstrapper.readModel(new File(basedir, "pom.xml"), false); + + String finalName = "maven-" + mavenRootModel.getVersion(); + + File destDirFile = new File(destDir); + if (!finalName.equals(destDirFile.getName())) { + throw new Exception("The Maven install destination directory must end with '" + finalName + "'.\n" + + "Your destDir was = " + destDirFile.getAbsolutePath() + "\n" + + "we recommend = " + new File(destDirFile.getParent(), finalName).getAbsolutePath()); + } + bootstrapper.buildProject( new File( basedir ), true ); Model mavenCoreModel = bootstrapper.getCachedModel( MAVEN_GROUPID, "maven-core" ); @@ -130,10 +141,9 @@ File mavenCoreDir = mavenCoreModel.getProjectFile().getParentFile(); runMaven( installation, mavenCoreDir, new String[]{"clean", "assembly:assembly"} ); - String finalName = "maven-" + mavenCoreModel.getVersion(); File file = new File( mavenCoreDir, "target/" + finalName + "-bin.zip" ); - File mavenHome = new File( prefix, finalName ); + File mavenHome = new File( destDir ); System.out.println( "Installing Maven in " + mavenHome ); @@ -141,7 +151,7 @@ Expand expand = new Expand(); expand.setSrc( file ); - expand.setDest( new File( prefix ) ); + expand.setDest( new File( destDir ).getParentFile() ); expand.execute(); if ( !mavenHome.exists() ) Modified: maven/components/branches/maven-2.0.x/bootstrap/bootstrap-mini/src/main/java/org/apache/maven/bootstrap/Bootstrap.java URL: http://svn.apache.org/viewvc/maven/components/branches/maven-2.0.x/bootstrap/bootstrap-mini/src/main/java/org/apache/maven/bootstrap/Bootstrap.java?view=diff&rev=453100&r1=453099&r2=453100 ============================================================================== --- maven/components/branches/maven-2.0.x/bootstrap/bootstrap-mini/src/main/java/org/apache/maven/bootstrap/Bootstrap.java (original) +++ maven/components/branches/maven-2.0.x/bootstrap/bootstrap-mini/src/main/java/org/apache/maven/bootstrap/Bootstrap.java Wed Oct 4 20:38:17 2006 @@ -138,7 +138,7 @@ String basedir = System.getProperty( "user.dir" ); File pom = new File( basedir, "pom.xml" ); - Model reader = readModel( resolver, pom, true ); + Model reader = readModel( pom, true ); File jar = buildProject( reader ); if ( "install".equals( goal ) ) @@ -211,7 +211,7 @@ private void cacheModels( File basedir, ArtifactResolver resolver ) throws IOException, ParserConfigurationException, SAXException { - Model model = readModel( resolver, new File( basedir, "pom.xml" ), false ); + Model model = readModel( new File( basedir, "pom.xml" ), false ); for ( Iterator i = model.getModules().iterator(); i.hasNext(); ) { @@ -234,7 +234,7 @@ File file = new File( basedir, "pom.xml" ); - Model model = readModel( resolver, file, true ); + Model model = readModel( file, true ); String key = model.getGroupId() + ":" + model.getArtifactId() + ":" + model.getPackaging(); if ( inProgress.contains( key ) ) @@ -339,7 +339,7 @@ Dependency dependency = plugin.asDependencyPom(); resolver.downloadDependencies( Collections.singletonList( dependency ) ); File artifactFile = resolver.getArtifactFile( dependency ); - Model pluginReader = readModel( resolver, artifactFile, true ); + Model pluginReader = readModel( artifactFile, true ); List dependencies = new ArrayList(); for ( Iterator i = pluginReader.getAllDependencies().iterator(); i.hasNext(); ) @@ -395,7 +395,7 @@ return jarFile; } - private Model readModel( ArtifactResolver resolver, File file, boolean resolveTransitiveDependencies ) + public Model readModel( File file, boolean resolveTransitiveDependencies ) throws ParserConfigurationException, SAXException, IOException { ModelReader reader = new ModelReader( resolver, resolveTransitiveDependencies ); @@ -412,7 +412,7 @@ return model; } - private void line() + public void line() { System.out.println( "------------------------------------------------------------------" ); }