MNG-2560 patch applied to make the bootstrap easier

Submitted by: Dan Fabulich


git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@453099 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jason van Zyl 2006-10-05 03:10:27 +00:00
parent 2bdcc4f862
commit e7594ada3e
6 changed files with 56 additions and 27 deletions

View File

@ -2,19 +2,20 @@
Bootstrapping Maven 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 set PATH=%PATH%;%M2_HOME%\bin
or or
export PATH=$PATH:$M2_HOME/bin 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 /usr/local/maven-2.1-SNAPSHOT
You can set the parameters passed to the Java VM when running Maven2 bootstrap, You can set the parameters passed to the Java VM when running Maven2 bootstrap,
setting the environment variable MAVEN_OPTS, e.g. setting the environment variable MAVEN_OPTS, e.g. to run in offline mode,
e.g. to run in offline mode, set MAVEN_OPTS=-o set MAVEN_OPTS=-o
Then run bootstrap.bat (in Windows) or bootstrap.sh (in Unix) Then run bootstrap.bat (in Windows) or bootstrap.sh (in Unix)

View File

@ -108,10 +108,12 @@ cd bootstrap\bootstrap-mini
call .\build call .\build
copy target\bootstrap-mini.jar .. 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 cd ..\bootstrap-installer
%MAVEN_JAVA_EXE% %MAVEN_OPTS% -jar ..\bootstrap-mini.jar package %MAVEN_CMD_LINE_ARGS% %MAVEN_JAVA_EXE% %MAVEN_OPTS% -jar ..\bootstrap-mini.jar package %MAVEN_CMD_LINE_ARGS%
if ERRORLEVEL 1 goto error
cd ..\.. cd ..\..
set PLUGINS_DIR=..\plugins set PLUGINS_DIR=..\plugins
@ -126,15 +128,19 @@ 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
set PREFIX=%M2_HOME%\.. set DESTDIR=%M2_HOME%
set OLD_M2_HOME=%M2_HOME% set OLD_M2_HOME=%M2_HOME%
set 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% 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? 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
%MAVEN_JAVA_EXE% %MAVEN_OPTS% -jar ..\bootstrap\bootstrap-mini.jar package %MAVEN_CMD_LINE_ARGS% %MAVEN_JAVA_EXE% %MAVEN_OPTS% -jar ..\bootstrap\bootstrap-mini.jar package %MAVEN_CMD_LINE_ARGS%
if ERRORLEVEL 1 goto error
cd .. cd ..
@ -148,6 +154,15 @@ cd maven-core-it
call maven-core-it %MAVEN_CMD_LINE_ARGS% call maven-core-it %MAVEN_CMD_LINE_ARGS%
cd .. cd ..
if ERRORLEVEL 1 goto error
goto end
:error
echo -----------------------------------------------------------------------
echo BUILD FAILED
echo -----------------------------------------------------------------------
:end :end
@REM set local scope for the variables with windows NT shell @REM set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" goto endNT if "%OS%"=="Windows_NT" goto endNT

View File

@ -3,6 +3,10 @@
ARGS=$@ ARGS=$@
ORIG_ARGS=$ARGS ORIG_ARGS=$ARGS
echo $M2_HOME
exit
if [ -z "$JAVA_HOME" ]; then if [ -z "$JAVA_HOME" ]; then
echo You must specify the JAVA_HOME environment variable echo You must specify the JAVA_HOME environment variable
exit 1 exit 1
@ -29,7 +33,7 @@ BOOTSTRAP_JAR=bootstrap-mini/bootstrap-mini.jar
ret=$?; if [ $ret != 0 ]; then exit $ret; fi ret=$?; if [ $ret != 0 ]; then exit $ret; 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
PREFIX=`dirname $M2_HOME` DESTDIR=$M2_HOME
# OS specific support. $var _must_ be set to either true or false. # OS specific support. $var _must_ be set to either true or false.
cygwin=false; cygwin=false;
@ -38,13 +42,13 @@ case "`uname`" in
esac esac
if [ "$cygwin" = "true" ]; then if [ "$cygwin" = "true" ]; then
PREFIX=`cygpath -w $PREFIX` DESTDIR=`cygpath -w $DESTDIR`
JAVA_HOME=`cygpath -w $JAVA_HOME` JAVA_HOME=`cygpath -w $JAVA_HOME`
fi fi
OLD_M2_HOME=$M2_HOME OLD_M2_HOME=$M2_HOME
unset 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 ret=$?; if [ $ret != 0 ]; then exit $ret; fi
M2_HOME=$OLD_M2_HOME M2_HOME=$OLD_M2_HOME
export M2_HOME export M2_HOME

View File

@ -17,8 +17,8 @@ package org.apache.maven.bootstrap.installer;
*/ */
import org.apache.maven.bootstrap.Bootstrap; import org.apache.maven.bootstrap.Bootstrap;
import org.apache.maven.bootstrap.model.Dependency; import org.apache.maven.bootstrap.download.*;
import org.apache.maven.bootstrap.model.Model; import org.apache.maven.bootstrap.model.*;
import org.apache.maven.bootstrap.util.FileUtils; import org.apache.maven.bootstrap.util.FileUtils;
import org.apache.maven.bootstrap.util.SimpleArgumentParser; import org.apache.maven.bootstrap.util.SimpleArgumentParser;
import org.codehaus.plexus.util.Expand; import org.codehaus.plexus.util.Expand;
@ -47,7 +47,7 @@ public class BootstrapInstaller
private final Bootstrap bootstrapper; private final Bootstrap bootstrapper;
private final String prefix; private final String destDir;
private String pluginsDirectory; private String pluginsDirectory;
@ -62,7 +62,7 @@ public class BootstrapInstaller
{ {
this.bootstrapper = new Bootstrap( parser ); this.bootstrapper = new Bootstrap( parser );
this.prefix = parser.getArgumentValue( "--prefix" ); this.destDir = parser.getArgumentValue( "--destDir" );
this.buildPlugins = parser.isArgumentSet( "--build-plugins" ); this.buildPlugins = parser.isArgumentSet( "--build-plugins" );
@ -78,7 +78,7 @@ public class BootstrapInstaller
throws Exception throws Exception
{ {
SimpleArgumentParser parser = Bootstrap.createDefaultParser(); 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( "--build-plugins", "Build the plugins from SVN" );
parser.addArgument( "--plugins-directory", "Where the plugins are located to build from", true ); parser.addArgument( "--plugins-directory", "Where the plugins are located to build from", true );
parser.addArgument( "--update-snapshots", "Update snapshots during build" ); parser.addArgument( "--update-snapshots", "Update snapshots during build" );
@ -117,6 +117,17 @@ public class BootstrapInstaller
// buildProject( basedir, "", resolver, false ); // buildProject( basedir, "", resolver, false );
// buildProject( basedir, "maven-artifact-manager", resolver ); // 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 ); bootstrapper.buildProject( new File( basedir ), true );
Model mavenCliModel = bootstrapper.getCachedModel( MAVEN_GROUPID, "maven-cli" ); Model mavenCliModel = bootstrapper.getCachedModel( MAVEN_GROUPID, "maven-cli" );
@ -130,10 +141,9 @@ public class BootstrapInstaller
File mavenCliDir = mavenCliModel.getProjectFile().getParentFile(); File mavenCliDir = mavenCliModel.getProjectFile().getParentFile();
runMaven( installation, mavenCliDir, new String[]{"clean", "assembly:assembly"} ); runMaven( installation, mavenCliDir, new String[]{"clean", "assembly:assembly"} );
String finalName = "maven-" + mavenCliModel.getVersion();
File file = new File( mavenCliDir, "target/" + finalName + "-bin.zip" ); 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 ); System.out.println( "Installing Maven in " + mavenHome );
@ -141,7 +151,7 @@ public class BootstrapInstaller
Expand expand = new Expand(); Expand expand = new Expand();
expand.setSrc( file ); expand.setSrc( file );
expand.setDest( new File( prefix ) ); expand.setDest( new File( destDir ).getParentFile() );
expand.execute(); expand.execute();
if ( !mavenHome.exists() ) if ( !mavenHome.exists() )

View File

@ -138,7 +138,7 @@ public class Bootstrap
String basedir = System.getProperty( "user.dir" ); String basedir = System.getProperty( "user.dir" );
File pom = new File( basedir, "pom.xml" ); File pom = new File( basedir, "pom.xml" );
Model reader = readModel( resolver, pom, true ); Model reader = readModel( pom, true );
File jar = buildProject( reader ); File jar = buildProject( reader );
if ( "install".equals( goal ) ) if ( "install".equals( goal ) )
@ -211,7 +211,7 @@ public class Bootstrap
private void cacheModels( File basedir, ArtifactResolver resolver ) private void cacheModels( File basedir, ArtifactResolver resolver )
throws IOException, ParserConfigurationException, SAXException 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(); ) for ( Iterator i = model.getModules().iterator(); i.hasNext(); )
{ {
@ -234,7 +234,7 @@ public class Bootstrap
File file = new File( basedir, "pom.xml" ); 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(); String key = model.getGroupId() + ":" + model.getArtifactId() + ":" + model.getPackaging();
if ( inProgress.contains( key ) ) if ( inProgress.contains( key ) )
@ -353,7 +353,7 @@ public class Bootstrap
Dependency dependency = plugin.asDependencyPom(); Dependency dependency = plugin.asDependencyPom();
resolver.downloadDependencies( Collections.singletonList( dependency ) ); resolver.downloadDependencies( Collections.singletonList( dependency ) );
File artifactFile = resolver.getArtifactFile( dependency ); File artifactFile = resolver.getArtifactFile( dependency );
Model pluginReader = readModel( resolver, artifactFile, true ); Model pluginReader = readModel( artifactFile, true );
List dependencies = new ArrayList(); List dependencies = new ArrayList();
for ( Iterator i = pluginReader.getAllDependencies().iterator(); i.hasNext(); ) for ( Iterator i = pluginReader.getAllDependencies().iterator(); i.hasNext(); )
@ -409,7 +409,7 @@ public class Bootstrap
return jarFile; return jarFile;
} }
private Model readModel( ArtifactResolver resolver, File file, boolean resolveTransitiveDependencies ) public Model readModel( File file, boolean resolveTransitiveDependencies )
throws ParserConfigurationException, SAXException, IOException throws ParserConfigurationException, SAXException, IOException
{ {
ModelReader reader = new ModelReader( resolver, resolveTransitiveDependencies ); ModelReader reader = new ModelReader( resolver, resolveTransitiveDependencies );
@ -426,7 +426,7 @@ public class Bootstrap
return model; return model;
} }
private void line() public void line()
{ {
System.out.println( "------------------------------------------------------------------" ); System.out.println( "------------------------------------------------------------------" );
} }

View File

@ -95,7 +95,6 @@ public class MavenEmbedder
private ArtifactRepositoryFactory artifactRepositoryFactory; private ArtifactRepositoryFactory artifactRepositoryFactory;
private LifecycleExecutor lifecycleExecutor; private LifecycleExecutor lifecycleExecutor;
private WagonManager wagonManager; private WagonManager wagonManager;