mirror of https://github.com/apache/maven.git
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:
parent
2bdcc4f862
commit
e7594ada3e
11
README.txt
11
README.txt
|
@ -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)
|
||||
|
||||
|
|
|
@ -108,10 +108,12 @@ cd bootstrap\bootstrap-mini
|
|||
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 @@ set BUILD_ARGS=%MAVEN_CMD_LINE_ARGS% --build-plugins --plugins-directory=%PLUGIN
|
|||
: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 ..
|
||||
|
||||
|
@ -148,6 +154,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
|
||||
if "%OS%"=="Windows_NT" goto endNT
|
||||
|
|
10
bootstrap.sh
10
bootstrap.sh
|
@ -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 @@ BOOTSTRAP_JAR=bootstrap-mini/bootstrap-mini.jar
|
|||
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 @@ case "`uname`" in
|
|||
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
|
||||
|
|
|
@ -17,8 +17,8 @@ package org.apache.maven.bootstrap.installer;
|
|||
*/
|
||||
|
||||
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 @@ public class BootstrapInstaller
|
|||
|
||||
private final Bootstrap bootstrapper;
|
||||
|
||||
private final String prefix;
|
||||
private final String destDir;
|
||||
|
||||
private String pluginsDirectory;
|
||||
|
||||
|
@ -62,7 +62,7 @@ public class BootstrapInstaller
|
|||
{
|
||||
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 @@ public class BootstrapInstaller
|
|||
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 @@ public class BootstrapInstaller
|
|||
// 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 @@ public class BootstrapInstaller
|
|||
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 @@ public class BootstrapInstaller
|
|||
|
||||
Expand expand = new Expand();
|
||||
expand.setSrc( file );
|
||||
expand.setDest( new File( prefix ) );
|
||||
expand.setDest( new File( destDir ).getParentFile() );
|
||||
expand.execute();
|
||||
|
||||
if ( !mavenHome.exists() )
|
||||
|
|
|
@ -138,7 +138,7 @@ public class Bootstrap
|
|||
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 @@ public class Bootstrap
|
|||
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 @@ public class Bootstrap
|
|||
|
||||
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 @@ public class Bootstrap
|
|||
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 @@ public class Bootstrap
|
|||
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 @@ public class Bootstrap
|
|||
return model;
|
||||
}
|
||||
|
||||
private void line()
|
||||
public void line()
|
||||
{
|
||||
System.out.println( "------------------------------------------------------------------" );
|
||||
}
|
||||
|
|
|
@ -95,7 +95,6 @@ public class MavenEmbedder
|
|||
|
||||
private ArtifactRepositoryFactory artifactRepositoryFactory;
|
||||
|
||||
|
||||
private LifecycleExecutor lifecycleExecutor;
|
||||
|
||||
private WagonManager wagonManager;
|
||||
|
|
Loading…
Reference in New Issue