Author: jvanzyl
Date: Wed Oct  4 20:10:27 2006
New Revision: 453099

URL: http://svn.apache.org/viewvc?view=rev&rev=453099
Log:
MNG-2560 patch applied to make the bootstrap easier
Submitted by: Dan Fabulich

Modified:
    maven/components/trunk/README.txt
    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/src/main/java/org/apache/maven/bootstrap/Bootstrap.java
    
maven/components/trunk/maven-embedder/src/main/java/org/apache/maven/embedder/MavenEmbedder.java

Modified: maven/components/trunk/README.txt
URL: 
http://svn.apache.org/viewvc/maven/components/trunk/README.txt?view=diff&rev=453099&r1=453098&r2=453099
==============================================================================
--- maven/components/trunk/README.txt (original)
+++ maven/components/trunk/README.txt Wed Oct  4 20:10:27 2006
@@ -2,19 +2,20 @@
 Bootstrapping Maven
 -------------------------------------------------------------------------------
 
-Set the environment variable M2_HOME pointing to the dir where you want Maven2 
installed.
+Set the environment variable M2_HOME pointing to the dir where you want Maven2
+installed... with two key restrictions.
 
-NOTE: presently, the directory {M2_HOME}/bin must be in your path:
+1) presently, the directory {M2_HOME}/bin must be in your path:
 set PATH=%PATH%;%M2_HOME%\bin
 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:
+2) 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
+setting the environment variable MAVEN_OPTS, e.g. to run in offline mode,
+set MAVEN_OPTS=-o
 
 Then run bootstrap.bat (in Windows) or bootstrap.sh (in Unix)
 

Modified: maven/components/trunk/bootstrap.bat
URL: 
http://svn.apache.org/viewvc/maven/components/trunk/bootstrap.bat?view=diff&rev=453099&r1=453098&r2=453099
==============================================================================
--- maven/components/trunk/bootstrap.bat (original)
+++ maven/components/trunk/bootstrap.bat Wed Oct  4 20:10:27 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/trunk/bootstrap.sh
URL: 
http://svn.apache.org/viewvc/maven/components/trunk/bootstrap.sh?view=diff&rev=453099&r1=453098&r2=453099
==============================================================================
--- maven/components/trunk/bootstrap.sh (original)
+++ maven/components/trunk/bootstrap.sh Wed Oct  4 20:10:27 2006
@@ -3,6 +3,10 @@
 ARGS=$@
 ORIG_ARGS=$ARGS
 
+echo $M2_HOME
+
+exit
+
 if [ -z "$JAVA_HOME" ]; then
   echo You must specify the JAVA_HOME environment variable
   exit 1
@@ -29,7 +33,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 +42,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/trunk/bootstrap/bootstrap-installer/src/main/java/org/apache/maven/bootstrap/installer/BootstrapInstaller.java
URL: 
http://svn.apache.org/viewvc/maven/components/trunk/bootstrap/bootstrap-installer/src/main/java/org/apache/maven/bootstrap/installer/BootstrapInstaller.java?view=diff&rev=453099&r1=453098&r2=453099
==============================================================================
--- 
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 Oct  4 20:10:27 2006
@@ -17,8 +17,8 @@
  */
 
 import org.apache.maven.bootstrap.Bootstrap;
-import org.apache.maven.bootstrap.model.Dependency;
-import org.apache.maven.bootstrap.model.Model;
+import org.apache.maven.bootstrap.download.*;
+import org.apache.maven.bootstrap.model.*;
 import org.apache.maven.bootstrap.util.FileUtils;
 import org.apache.maven.bootstrap.util.SimpleArgumentParser;
 import org.codehaus.plexus.util.Expand;
@@ -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,10 +117,21 @@
 //        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 mavenCliModel = bootstrapper.getCachedModel( MAVEN_GROUPID, 
"maven-cli" );
-
+        
         File installation = new File( basedir, "bootstrap/target/installation" 
);
         createInstallation( installation, mavenCliModel );
 
@@ -130,10 +141,9 @@
         File mavenCliDir = mavenCliModel.getProjectFile().getParentFile();
         runMaven( installation, mavenCliDir, new String[]{"clean", 
"assembly:assembly"} );
 
-        String finalName = "maven-" + mavenCliModel.getVersion();
         File file = new File( mavenCliDir, "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/trunk/bootstrap/bootstrap-mini/src/main/java/org/apache/maven/bootstrap/Bootstrap.java
URL: 
http://svn.apache.org/viewvc/maven/components/trunk/bootstrap/bootstrap-mini/src/main/java/org/apache/maven/bootstrap/Bootstrap.java?view=diff&rev=453099&r1=453098&r2=453099
==============================================================================
--- 
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 Oct  4 20:10:27 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 ) )
@@ -353,7 +353,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(); )
@@ -409,7 +409,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 );
@@ -426,7 +426,7 @@
         return model;
     }
 
-    private void line()
+    public void line()
     {
         System.out.println( 
"------------------------------------------------------------------" );
     }

Modified: 
maven/components/trunk/maven-embedder/src/main/java/org/apache/maven/embedder/MavenEmbedder.java
URL: 
http://svn.apache.org/viewvc/maven/components/trunk/maven-embedder/src/main/java/org/apache/maven/embedder/MavenEmbedder.java?view=diff&rev=453099&r1=453098&r2=453099
==============================================================================
--- 
maven/components/trunk/maven-embedder/src/main/java/org/apache/maven/embedder/MavenEmbedder.java
 (original)
+++ 
maven/components/trunk/maven-embedder/src/main/java/org/apache/maven/embedder/MavenEmbedder.java
 Wed Oct  4 20:10:27 2006
@@ -95,7 +95,6 @@
 
     private ArtifactRepositoryFactory artifactRepositoryFactory;
 
-
     private LifecycleExecutor lifecycleExecutor;
 
     private WagonManager wagonManager;


Reply via email to