From 92fe67108778fff51490a4cb6776199f1074ee75 Mon Sep 17 00:00:00 2001 From: Brett Leslie Porter Date: Wed, 9 Mar 2005 03:35:33 +0000 Subject: [PATCH] original mboot no longer required git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@163500 13f79535-47bb-0310-9956-ffa450edef68 --- maven-mboot/.cvsignore | 4 - maven-mboot/README.txt | 13 - maven-mboot/TODO.txt | 5 - maven-mboot/build | 33 - maven-mboot/pom.xml | 16 - maven-mboot/src/bash/deps | 8 - maven-mboot/src/bash/maven.functions | 517 ----------- maven-mboot/src/bash/mboot | 71 -- maven-mboot/src/bash/modello | 83 -- maven-mboot/src/bash/pluggy | 75 -- maven-mboot/src/main/ArtifactDownloader.java | 234 ----- maven-mboot/src/main/Base64.java | 386 -------- maven-mboot/src/main/Bootstrapper.java | 915 ------------------- maven-mboot/src/main/HttpUtils.java | 399 -------- maven-mboot/src/sea/sea-header | 45 - maven-mboot/src/site/apt/index.apt | 26 - 16 files changed, 2830 deletions(-) delete mode 100644 maven-mboot/.cvsignore delete mode 100644 maven-mboot/README.txt delete mode 100644 maven-mboot/TODO.txt delete mode 100755 maven-mboot/build delete mode 100644 maven-mboot/pom.xml delete mode 100644 maven-mboot/src/bash/deps delete mode 100755 maven-mboot/src/bash/maven.functions delete mode 100755 maven-mboot/src/bash/mboot delete mode 100755 maven-mboot/src/bash/modello delete mode 100755 maven-mboot/src/bash/pluggy delete mode 100644 maven-mboot/src/main/ArtifactDownloader.java delete mode 100644 maven-mboot/src/main/Base64.java delete mode 100644 maven-mboot/src/main/Bootstrapper.java delete mode 100644 maven-mboot/src/main/HttpUtils.java delete mode 100644 maven-mboot/src/sea/sea-header delete mode 100644 maven-mboot/src/site/apt/index.apt diff --git a/maven-mboot/.cvsignore b/maven-mboot/.cvsignore deleted file mode 100644 index c31ed89240..0000000000 --- a/maven-mboot/.cvsignore +++ /dev/null @@ -1,4 +0,0 @@ -*~ -target -.classpath -.project diff --git a/maven-mboot/README.txt b/maven-mboot/README.txt deleted file mode 100644 index 2fd748e95e..0000000000 --- a/maven-mboot/README.txt +++ /dev/null @@ -1,13 +0,0 @@ -How to use mboot ----------------- - -o ./build -o cd target -o export MBOOT_HOME=; export PATH=$PATH:$MBOOT_HOME (optional) -o ./mboot-install.sh -o mboot - -mboot will build Maven projects that are relatively simple. It will build -a JAR and package any resources into the JAR. Good enough for Maven itself -and the plugins but appears to be useful for other things. - diff --git a/maven-mboot/TODO.txt b/maven-mboot/TODO.txt deleted file mode 100644 index ba4fd2e05e..0000000000 --- a/maven-mboot/TODO.txt +++ /dev/null @@ -1,5 +0,0 @@ -o obey jar overrides -o transitive deps -o move all code for gathering pieces of the model to java, the mix of grabbing - some stuff with java and some from bash is crappy. It works, but it's still - crappy. Use the generated xpp3 reader. diff --git a/maven-mboot/build b/maven-mboot/build deleted file mode 100755 index ded0809cb1..0000000000 --- a/maven-mboot/build +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/sh - -rm -rf target > /dev/null 2>&1 - -. src/bash/maven.functions - -downloadMBootDependencies - -createMBootClasspath - -compile ".:$MBOOT_CP" target/classes src/main - -isCommandSuccessful $? "Failed compiling Maven bootstrapper classes!" - -DIST=target/mboot - -mkdir -p $DIST - -cp -r target/classes $DIST - -cp src/bash/* $DIST > /dev/null 2>&1 - -( - cd target/mboot - - tar czf ../mboot.tar.gz * -) - -cat src/sea/sea-header target/mboot.tar.gz > target/mboot-install.sh - -chmod +x target/mboot-install.sh - -rm -f bootstrap.repo > /dev/null 2>&1 diff --git a/maven-mboot/pom.xml b/maven-mboot/pom.xml deleted file mode 100644 index fd4bef988e..0000000000 --- a/maven-mboot/pom.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - 4.0.0 - - maven - maven-component - 2.0-SNAPSHOT - - Maven MBoot - maven - maven-mboot - 2.0-SNAPSHOT - Tool used to bootstrap m2. - Tool used to bootstrap m2. - diff --git a/maven-mboot/src/bash/deps b/maven-mboot/src/bash/deps deleted file mode 100644 index 309ad68d9e..0000000000 --- a/maven-mboot/src/bash/deps +++ /dev/null @@ -1,8 +0,0 @@ -junit/jars/junit-3.8.1.jar -surefire/jars/surefire-booter-1.1.jar -surefire/jars/surefire-1.1.jar -modello/jars/modello-1.0-SNAPSHOT.jar -xpp3/jars/xpp3-1.1.3.3.jar -xstream/jars/xstream-1.0-SNAPSHOT.jar -qdox/jars/qdox-1.2.jar -maven/jars/maven-plugin-2.0-SNAPSHOT.jar diff --git a/maven-mboot/src/bash/maven.functions b/maven-mboot/src/bash/maven.functions deleted file mode 100755 index 032c408cbf..0000000000 --- a/maven-mboot/src/bash/maven.functions +++ /dev/null @@ -1,517 +0,0 @@ -#!/bin/sh -# ----------------------------------------------------------------------------- -# Maven functions -# -# @author Jason van Zyl -# @author Emmanuel Venisse -# ----------------------------------------------------------------------------- - -POM=pom.xml - -downloadMBootDependencies() -{ - findAndSetMavenRepoLocal - - for i in `cat ${MBOOT_HOME}/deps` - do - echo $i | grep SNAPSHOT > /dev/null 2>&1 - snapshot=$? - - if [ "$snapshot" = "0" ] || [ ! -f $repoLocal/$i ] - then - mkdir -p `dirname $repoLocal/$i` > /dev/null 2>&1 - wget -q -O $repoLocal/$i http://www.ibiblio.org/maven/$i - fi - done -} - -createMBootClasspath() -{ - findAndSetMavenRepoLocal - - if [ "$cygwin" = "true" ] - then - MBOOT_CP=`cygpath -pu "$MBOOT_CP"` - fi - - for i in `cat ${MBOOT_HOME}/deps` - do - MBOOT_CP=${MBOOT_CP}:$repoLocal/$i - done -} - -findAndSetMavenRepoLocal() -{ - if [ -f $HOME/maven.properties ] - then - repoLocal=`cat $HOME/maven.properties | egrep "^maven.repo.local" | sed 's/^.*= *//'` - else - repoLocal=$HOME/.maven/repository - fi - - if [ "$cygwin" = "true" ] - then - repoLocal=`cygpath -pu "$repoLocal"` - fi -} - -isCommandSuccessful() -{ - # $1 == $? - # $2 == Error message on failure - - ret=$1 - if [ $ret != 0 ]; then - echo $2 - exit $ret - fi -} - -runJava() -{ - # $1 == classpath - # $2 == Main class - # $3 == Main args - - if $cygwin; then - CP=`cygpath -pw "$1"` - else - CP=$1 - fi - - "${JAVACMD}" -classpath "$CP" $2 "$3" -} - -runTests() -{ - # $1 == classpath - # $2 == home args - # $3 == repo local - # $4 == dependencies file - # $5 == includes file - # $6 == excludes file - - if $cygwin; then - CP=`cygpath -pw "$1"` - else - CP=$1 - fi - - if $cygwin; then - repo=`cygpath -pw "$3"` - else - repo=$3 - fi - - if [ -f $5 ] - then - "${JAVACMD}" -classpath "$CP" org.codehaus.surefire.SurefireBooter "$2" "$repo" $4 $5 $6 - fi -} - -compile() -{ - # $1 == classpath - # $2 == destination for compiled classes - # $3 == source directory - # $4 == generated source directory - - if [ -d $3 ] || [ -d $4 ] - then - - if [ ! -d $2 ] - then - mkdir -p $2 - fi - - if [ ! -z $3 ] && [ -d $3 ] - then - sources=`find $3 -name '*.java'` - fi - - if [ ! -z $4 ] && [ -d $4 ] - then - generatedSources=`find $4 -name '*.java'` - fi - - if $cygwin; then - CP=`cygpath -pw "$1"` - else - CP=$1 - fi - - "${JAVAC}" -classpath "$CP" -d $2 ${sources} ${generatedSources} - fi -} - -buildJar() -{ - # $1 == directory to JAR - # $2 == JAR path relative to the cwd - - ( - dir=`pwd` - cd $1 - if $cygwin; then - JARFILE=`cygpath -pw ${dir}/$2` - else - JARFILE=${dir}/$2 - fi - - ${JAVA_HOME}/bin/jar -cf $JARFILE * - ) -} - -buildMavenProject() -{ - # 1. Parse the model - # 2. Download any required dependencies - # 3. Compile the sources - # 4. Move required resources into location - # 5. Create JAR. - - # $1 == directory where project lives - # $2 == jar name - # $3 == flag to install - # $4 == flag to install pom - # $5 == flag to leave mboot files - - ( - home=`pwd` - - cd $1 - - # If the user only want to install the POM skip the rest - if [ "$3" = "0" ] && [ "$4" = "1" ] - then - - installPom - - return - - fi - - # Look for source directory in pom.xml - sourceDirectory=`grep sourceDirectory ${POM} | sed -e 's/^*//;s///;s/<\/sourceDirectory>//;s/\${basedir}\///'` - - [ -z $sourceDirectory ] && sourceDirectory=src/main/java - - buildDir=target - buildDest=target/classes - - # Look for unit test source directory in pom.xml - unitTestSourceDirectory=`grep unitTestSourceDirectory ${POM} | sed -e 's/^*//;s///;s/<\/unitTestSourceDirectory>//;s/\${basedir}\///'` - - [ -z $unitTestSourceDirectory ] && unitTestSourceDirectory=src/test/java - - buildTestDest=target/test-classes - - ##[ -d $buildDir ] && rm -rf $buildDir - - echo "Building project in `pwd`" - - if $cygwin = true; then - home=`cygpath -pw $home` - fi - - runJava ${MBOOT_HOME}/classes Bootstrapper ${home} - - isCommandSuccessful $? "Failed running project parser!" - - bootstrapClasspath=`cat bootstrap.classpath` - - if $cygwin = true; then - bootstrapClasspath=`cygpath -pu "$bootstrapClasspath"` - fi - - projectDependencyClassPath=$bootstrapClasspath:. - - generatedSourceDirectory=target/generated-sources - - compile "$projectDependencyClassPath" $buildDest $sourceDirectory $generatedSourceDirectory - - isCommandSuccessful $? "Failed compiling classes!" - - echo "Building tests in `pwd`" - - repoLocal=`cat bootstrap.repo` - - if $cygwin = true; then - repoLocal=`cygpath -pu "$repoLocal"` - fi - - createMBootClasspath - - if [ ! -z $unitTestSourceDirectory ] && [ -d $unitTestSourceDirectory ] - then - compile "$buildDest:$projectDependencyClassPath:${MBOOT_CP}" $buildTestDest $unitTestSourceDirectory - - isCommandSuccessful $? "Failed compiling test classes!" - fi - - copyResources bootstrap.resources target/classes - - copyResources bootstrap.tests.resources target/test-classes - - echo "Running tests in `pwd`" - - # We only need the booter jar in the classpath, it will load everything else. - - runTests ".:${MBOOT_HOME}/classes:$repoLocal/surefire/jars/surefire-booter-1.1.jar" "$1" "$repoLocal" bootstrap.libs bootstrap.tests.includes bootstrap.tests.excludes - - isCommandSuccessful $? "Failed running project tests!" - - if [ "$2" = "default" ] - then - jarName=`getJarName ${POM}` - else - jarName=$2 - fi - - echo "Building jars (${jarName}) in `pwd`/target" - - buildJar $buildDest target/${jarName} - - if [ "$3" = "1" ] - then - - findAndSetMavenRepoLocal - - groupId=`getGroupId` - - echo "Installing ${jarName} in ${repoLocal}/${groupId}/jars" - - mkdir -p ${repoLocal}/${groupId}/jars > /dev/null 2>&1 - - cp target/${jarName} ${repoLocal}/${groupId}/jars - - installPom - - fi - - if [ "$5" = "0" ] - then - rm -f bootstrap.classpath > /dev/null 2>&1 - rm -f bootstrap.libs > /dev/null 2>&1 - rm -f bootstrap.deps > /dev/null 2>&1 - rm -f bootstrap.resources > /dev/null 2>&1 - rm -f bootstrap.repo > /dev/null 2>&1 - rm -f bootstrap.tests.includes > /dev/null 2>&1 - rm -f bootstrap.tests.excludes > /dev/null 2>&1 - rm -f bootstrap.tests.resources > /dev/null 2>&1 - fi - - ) -} - -installPom() -{ - findAndSetMavenRepoLocal - - groupId=`getGroupId` - - pomName=`getPomName ${POM}` - - dir=${repoLocal}/${groupId}/poms - - echo "Installing POM in ${dir}/${pomName}" - - mkdir -p ${dir} - - cp ${POM} ${dir}/${pomName} -} - -getJarName() -{ - # $1 == pom.xml - - version=`cat $1 | tr '\n' ' ' | sed 's#.*##' | sed 's#.*##' | grep '' | sed -e 's#^.*##;s#.*$##'` - - if [ -z $version ] - then - version=`grep currentVersion $1 | sed -e 's/^ *//;s///;s/<\/currentVersion>//'` - fi - - artifactId=`cat $1 | tr '\n' ' ' | sed 's#.*##' | grep '' | sed -e 's#^.*##;s#.*$##'` - - if [ -z $artifactId ] - then - artifactId=`cat $1 | tr '\n' ' ' | sed 's#.*##' | sed 's#.*##' | sed 's#.*##' | grep '' | sed -e 's#^.*##;s#.*$##'` - fi - - jarName="${artifactId}-${version}.jar" - - echo $jarName -} - -# returns the name under which the pom should be installed -getPomName() -{ - version=`cat $1 | tr '\n' ' ' | sed 's#.*##' | sed 's#.*##' | grep '' | sed -e 's#^.*##;s#.*$##'` - - if [ -z $version ] - then - version=`grep currentVersion $1 | sed -e 's/^ *//;s///;s/<\/currentVersion>//'` - fi - - artifactId=`cat $1 | tr '\n' ' ' | sed 's#.*##' | grep '' | sed -e 's#^.*##;s#.*$##'` - - if [ -z $artifactId ] - then - artifactId=`cat $1 | tr '\n' ' ' | sed 's#.*##' | sed 's#.*##' | sed 's#.*##' | grep '' | sed -e 's#^.*##;s#.*$##'` - fi - - pomName="${artifactId}-${version}.pom" - - echo $pomName -} - -getGroupId() -{ - groupId=`cat ${POM} | tr '\n' ' ' | sed 's#.*##' | grep '' | sed -e 's#^.*##;s#.*$##'` - - echo $groupId -} - -copyResources() -{ - # $1 == resourcesfile - # $2 == target directory - - if [ -f $1 ] - then - - resources=`cat $1` - - for i in $resources - do - directory=`echo $i | awk 'BEGIN { FS = "@" } { print $1 }' | awk 'BEGIN { FS = "," } { print $1 }'` - targetPath=`echo $i | awk 'BEGIN { FS = "@" } { print $1 }' | awk 'BEGIN { FS = "," } { print $2 }'` - includes=`echo $i | awk 'BEGIN { FS = "@" } { print $2 }' | awk 'BEGIN { FS = "," } { for ( j = 1; j <= NF; j++ ) { printf( "%s ", $j ) } }'` - - for include in $includes - do - if [ ! -d "$directory" ] - then - continue - fi - - files=`eval "find $directory -name $include"` - - for file in $files - do - # Replace the "/" with "@" to prevent shell expansion of *.properties - # to *.properties in the CWD. - tmpDirectory=`echo $directory | sed "s/\//@/g"` - tmpFile=`echo $file | sed "s/\//@/g"` - - # Now grab the path excluding the original directory so we can translate that - # path into the target directory. - path=`echo $tmpFile | sed "s/$tmpDirectory//;s/\@/\//g;s/^\///"` - - targetDirectory=$2 - - [ ! -z $MBOOT_DEBUG ] && echo "path = $path" - - [ ! -z $path ] && translatedPath=`dirname $path` - - [ ! -z $MBOOT_DEBUG ] && echo "translatedPath = $translatedPath" - - if [ ! -z $targetPath ] - then - [ ! -z $MBOOT_DEBUG ] && echo "targetPath = $targetPath" - targetDirectory="${targetDirectory}/${targetPath}/${translatedPath}" - else - targetDirectory="${targetDirectory}/${translatedPath}" - fi - - [ ! -z $MBOOT_DEBUG ] && echo "targetDirectory = $targetDirectory" - - [ ! -d $targetDirectory ] && mkdir -p $targetDirectory - - cp $file $targetDirectory > /dev/null 2>&1 - - done - done - done - - find $2 -name 'CVS*' -exec rm -rf {} > /dev/null 2>&1 \; - - fi -} - -# OS specific support. $var _must_ be set to either true or false. -cygwin=false; -darwin=false; -case "`uname`" in - CYGWIN*) cygwin=true ;; - Darwin*) darwin=true - if [ -z "$JAVA_HOME" ] ; then - JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Home - fi - ;; -esac - -# For Cygwin, ensure paths are in UNIX format before anything is touched -if $cygwin ; then - [ -n "$JAVA_HOME" ] && - JAVA_HOME=`cygpath --unix "$JAVA_HOME"` - [ -n "$CLASSPATH" ] && - CLASSPATH=`cygpath --path --unix "$CLASSPATH"` -fi - -# You will need to specify JAVA_HOME if compiling with 1.2 or later. - -if [ -n "$JAVA_HOME" ] ; then - if [ -f "$JAVA_HOME/lib/tools.jar" ] ; then - CLASSPATH=$CLASSPATH:$JAVA_HOME/lib/tools.jar - fi - - if [ -f "$JAVA_HOME/lib/classes.zip" ] ; then - CLASSPATH=$CLASSPATH:$JAVA_HOME/lib/classes.zip - fi -else - echo "Warning: JAVA_HOME environment variable not set." - echo " If build fails because sun.* classes could not be found" - echo " you will need to set the JAVA_HOME environment variable" - echo " to the installation directory of java." -fi - -# IBM's JDK on AIX uses strange locations for the executables: -# JAVA_HOME/jre/sh for java and rmid -# JAVA_HOME/sh for javac and rmic -if [ -z "$JAVAC" ] ; then - if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/sh/javac" ] ; then - JAVAC=${JAVA_HOME}/sh/javac; - else - JAVAC=${JAVA_HOME}/bin/javac; - fi - else - JAVAC=javac - fi -fi -if [ -z "$JAVACMD" ] ; then - if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - JAVACMD=$JAVA_HOME/jre/sh/java - else - JAVACMD=$JAVA_HOME/bin/java - fi - else - JAVACMD=java - fi -fi - -if [ ! -x "$JAVACMD" ] ; then - echo "Error: JAVA_HOME is not defined correctly." - echo " We cannot execute $JAVACMD" - exit 1 -fi - -# For Cygwin, switch to Windows format before running java -if $cygwin; then - CLASSPATH=`cygpath --path --windows "$CLASSPATH"` -fi - -export CLASSPATH diff --git a/maven-mboot/src/bash/mboot b/maven-mboot/src/bash/mboot deleted file mode 100755 index fe4540711a..0000000000 --- a/maven-mboot/src/bash/mboot +++ /dev/null @@ -1,71 +0,0 @@ -#!/bin/sh - -VERSION=1.0 - -POM=pom.xml - -usage () -{ - echo "usage: `basename $0` [--dir=] [--jar=] [--install] [--pom-install] [-v] [--leave-boot-files] [--version] [--help]" >&2 - echo "" >&2 - echo " (ex: `basename $0` --dir=../builds/plexus --jar=plexus.jar)" >&2 - exit 1 -} - -dir="." -jar="default" -leaveBootFiles="0" -install="0" -pomInstall="0" - -while [ $# -gt 0 ]; do - case $1 in - --help) - usage - ;; - --version) - echo "mboot: version $VERSION" - exit 0 - ;; - -v) - verbose=-v - ;; - --dir*) - if echo $1 | grep -q '=' ; then - dir=`echo $1 | sed 's/^--dir=//'` - else - dir=$2 - shift - fi - ;; - --jar*) - if echo $1 | grep -q '=' ; then - jar=`echo $1 | sed 's/^--jar=//'` - else - jar=$2 - shift - fi - ;; - --leave-boot-files) - leaveBootFiles=1; - ;; - --install) - install=1; - ;; - --pom-install) - pomInstall=1; - ;; - esac - - shift -done - -export MBOOT_HOME=`dirname $0` - -. ${MBOOT_HOME}/maven.functions - -[ ! -d $dir ] && echo "Specified directory doesn't exist!" && exit 1 - -[ ! -f $dir/${POM} ] && echo "No ${POM} in specified directory!" && exit 1 - -buildMavenProject $dir $jar $install $pomInstall $leaveBootFiles diff --git a/maven-mboot/src/bash/modello b/maven-mboot/src/bash/modello deleted file mode 100755 index 247639a58b..0000000000 --- a/maven-mboot/src/bash/modello +++ /dev/null @@ -1,83 +0,0 @@ -#!/bin/sh - -VERSION=1.0 - -usage () -{ - echo "usage: `basename $0` --model= --version= --mode=java|xsd|xpp3 --dir= --package-with-version" >&2 - echo "" >&2 - echo " (ex: `basename $0` --model=model.mdo --version=4.0.0 --mode=java --dir=target/src)" >&2 - exit 1 -} - -dir="target/src/java" -model="model.mdo" -model_version="" -mode="java" -package_with_version=false - -while [ $# -gt 0 ]; do - case $1 in - --help) - usage - ;; - -v) - verbose=-v - ;; - --dir*) - if echo $1 | grep -q '=' ; then - dir=`echo $1 | sed 's/^--dir=//'` - else - dir=$2 - shift - fi - ;; - --version*) - if echo $1 | grep -q '=' ; then - model_version=`echo $1 | sed 's/^--version=//'` - else - model_version=$2 - shift - fi - ;; - --model*) - if echo $1 | grep -q '=' ; then - model=`echo $1 | sed 's/^--model=//'` - else - model=$2 - shift - fi - ;; - --mode*) - if echo $1 | grep -q '=' ; then - mode=`echo $1 | sed 's/^--mode=//'` - else - mode=$2 - shift - fi - ;; - --package-with-version) - package_with_version=true - ;; - esac - - shift -done - -export MBOOT_HOME=`dirname $0` - -. ${MBOOT_HOME}/maven.functions - -[ ! -f $model ] && echo "Specified model doesn't exist!" && exit 1 - -[ ! -d $dir ] && mkdir -p $dir - -findAndSetMavenRepoLocal - -CP=$repoLocal/modello/jars/modello-1.0-SNAPSHOT.jar:$repoLocal/xstream/jars/xstream-1.0-SNAPSHOT.jar:$repoLocal/xpp3/jars/xpp3-1.1.3.3.jar - -if $cygwin; then - CP=`cygpath -pw "$CP"` -fi - -java -classpath "$CP" org.codehaus.modello.Modello $model $mode "$dir" "$model_version" "$package_with_version" diff --git a/maven-mboot/src/bash/pluggy b/maven-mboot/src/bash/pluggy deleted file mode 100755 index 00480685a6..0000000000 --- a/maven-mboot/src/bash/pluggy +++ /dev/null @@ -1,75 +0,0 @@ -#!/bin/sh - -VERSION=1.0 - -usage () -{ - echo "usage: `basename $0` --mode=descriptor|xdoc --source= --destination= --pom=" >&2 - echo "" >&2 - echo " (ex: `basename $0` --mode=descriptor --source=src/main/java --destination=target --pom=project.xml)" >&2 - exit 1 -} - -dir="target/src/java" -mode="descriptor" - -while [ $# -gt 0 ]; do - case $1 in - --help) - usage - ;; - -v) - verbose=-v - ;; - --destination*) - if echo $1 | grep -q '=' ; then - destination=`echo $1 | sed 's/^--destination=//'` - else - destination=$2 - shift - fi - ;; - --source*) - if echo $1 | grep -q '=' ; then - source=`echo $1 | sed 's/^--source=//'` - else - source=$2 - shift - fi - ;; - --mode*) - if echo $1 | grep -q '=' ; then - mode=`echo $1 | sed 's/^--mode=//'` - else - mode=$2 - shift - fi - ;; - --pom*) - if echo $1 | grep -q '=' ; then - pom=`echo $1 | sed 's/^--pom=//'` - else - pom=$2 - shift - fi - ;; - esac - - shift -done - -export MBOOT_HOME=`dirname $0` - -. ${MBOOT_HOME}/maven.functions - -[ ! -d $destination ] && mkdir -p $destination - -findAndSetMavenRepoLocal - -CP=$repoLocal/modello/jars/modello-1.0-SNAPSHOT.jar:$repoLocal/maven/jars/maven-plugin-2.0-SNAPSHOT.jar:$repoLocal/qdox/jars/qdox-1.2.jar:$repoLocal/xstream/jars/xstream-1.0-SNAPSHOT.jar:$repoLocal/xpp3/jars/xpp3-1.1.3.3.jar - -if $cygwin; then - CP=`cygpath -pw "$CP"` -fi - -java -classpath "$CP" org.apache.maven.plugin.generator.Main $mode "$source" "$destination" "$pom" diff --git a/maven-mboot/src/main/ArtifactDownloader.java b/maven-mboot/src/main/ArtifactDownloader.java deleted file mode 100644 index b0c7da31c3..0000000000 --- a/maven-mboot/src/main/ArtifactDownloader.java +++ /dev/null @@ -1,234 +0,0 @@ -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileWriter; -import java.io.Writer; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.Properties; -import java.util.StringTokenizer; - -public class ArtifactDownloader -{ - public static final String SNAPSHOT_SIGNATURE = "-SNAPSHOT"; - - private File mavenRepoLocal; - - private List remoteRepos; - - private boolean useTimestamp = true; - - private boolean ignoreErrors = true; - - private String proxyHost; - - private String proxyPort; - - private String proxyUserName; - - private String proxyPassword; - - public ArtifactDownloader( Properties properties ) throws Exception - { - setRemoteRepo( properties.getProperty( "maven.repo.remote" ) ); - - String mavenRepoLocalProperty = properties.getProperty( "maven.repo.local" ); - - if ( mavenRepoLocalProperty == null ) - { - mavenRepoLocalProperty = System.getProperty( "user.home" ) + "/.maven/repository"; - } - - mavenRepoLocal = new File( mavenRepoLocalProperty ); - - if ( !mavenRepoLocal.exists() ) - { - if ( !mavenRepoLocal.mkdirs() ) - { - System.err.println( "Cannot create the specified maven.repo.local: " + mavenRepoLocal ); - - System.exit( 1 ); - } - } - - if ( !mavenRepoLocal.canWrite() ) - { - System.err.println( "Can't write to " + mavenRepoLocal.getAbsolutePath() ); - - System.exit( 1 ); - } - - writeFile( "bootstrap.repo", mavenRepoLocal.getPath() ); - - System.out.println( "Using the following for your maven.repo.local: " + mavenRepoLocal ); - } - - private void writeFile( String name, String contents ) - throws Exception - { - Writer writer = new FileWriter( name ); - - writer.write( contents ); - - writer.close(); - } - - public File getMavenRepoLocal() - { - return mavenRepoLocal; - } - - public void downloadDependencies( List files ) - throws Exception - { - for ( Iterator j = files.iterator(); j.hasNext(); ) - { - try - { - String file = (String) j.next(); - - File destinationFile = new File( mavenRepoLocal, file ); - - // The directory structure for this project may - // not exists so create it if missing. - File directory = destinationFile.getParentFile(); - - if ( directory.exists() == false ) - { - directory.mkdirs(); - } - - if ( destinationFile.exists() && file.indexOf( SNAPSHOT_SIGNATURE ) < 0 ) - { - continue; - } - - log( "Downloading dependency: " + file ); - - getRemoteArtifact( file, destinationFile ); - - if ( !destinationFile.exists() ) - { - throw new Exception( "Failed to download " + file ); - } - } - catch ( Exception e ) - { - throw new Exception( e ); - } - } - } - - private void setRemoteRepo( String repos ) - { - remoteRepos = new ArrayList(); - - if ( repos == null ) - { - remoteRepos.add( "http://www.ibiblio.org/maven/" ); - return; - } - - StringTokenizer st = new StringTokenizer( repos, "," ); - while ( st.hasMoreTokens() ) - { - remoteRepos.add( st.nextToken().trim() ); - } - } - - private List getRemoteRepo() - { - return remoteRepos; - } - - private boolean getRemoteArtifact( String file, File destinationFile ) - { - boolean fileFound = false; - - for ( Iterator i = getRemoteRepo().iterator(); i.hasNext(); ) - { - String remoteRepo = (String) i.next(); - - // The username and password parameters are not being - // used here. Those are the "" parameters you see below. - String url = remoteRepo + "/" + file; - - if ( !url.startsWith( "file" ) ) - { - url = replace( url, "//", "/" ); - if ( url.startsWith( "https" ) ) - { - url = replace( url, "https:/", "https://" ); - } - else - { - url = replace( url, "http:/", "http://" ); - } - } - - // Attempt to retrieve the artifact and set the checksum if retrieval - // of the checksum file was successful. - try - { - HttpUtils.getFile( url, - destinationFile, - ignoreErrors, - useTimestamp, - proxyHost, - proxyPort, - proxyUserName, - proxyPassword, - true ); - - // Artifact was found, continue checking additional remote repos (if any) - // in case there is a newer version (i.e. snapshots) in another repo - fileFound = true; - } - catch ( FileNotFoundException e ) - { - // Ignore - } - catch ( Exception e ) - { - // If there are additional remote repos, then ignore exception - // as artifact may be found in another remote repo. If there - // are no more remote repos to check and the artifact wasn't found in - // a previous remote repo, then artifactFound is false indicating - // that the artifact could not be found in any of the remote repos - // - // arguably, we need to give the user better control (another command- - // line switch perhaps) of what to do in this case? Maven already has - // a command-line switch to work in offline mode, but what about when - // one of two or more remote repos is unavailable? There may be multiple - // remote repos for redundancy, in which case you probably want the build - // to continue. There may however be multiple remote repos because some - // artifacts are on one, and some are on another. In this case, you may - // want the build to break. - // - // print a warning, in any case, so user catches on to mistyped - // hostnames, or other snafus - log( "Error retrieving artifact from [" + url + "]: " ); - } - } - - return fileFound; - } - - private String replace( String text, String repl, String with ) - { - StringBuffer buf = new StringBuffer( text.length() ); - int start = 0, end = 0; - while ( ( end = text.indexOf( repl, start ) ) != -1 ) - { - buf.append( text.substring( start, end ) ).append( with ); - start = end + repl.length(); - } - buf.append( text.substring( start ) ); - return buf.toString(); - } - - private void log( String message ) - { - System.out.println( message ); - } -} \ No newline at end of file diff --git a/maven-mboot/src/main/Base64.java b/maven-mboot/src/main/Base64.java deleted file mode 100644 index 28bc85b795..0000000000 --- a/maven-mboot/src/main/Base64.java +++ /dev/null @@ -1,386 +0,0 @@ -/* - * ==================================================================== - * Copyright 2001-2004 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy - * of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * ==================================================================== - */ - -import java.io.ByteArrayOutputStream; - -// import org.apache.commons.logging.Log; -// import org.apache.commons.logging.LogFactory; - -/** - * Encode/Decode Base-64. - * - * @author John Casey - */ -public final class Base64 -{ - - // private static final Log LOG = LogFactory.getLog( Base64.class ); - - private static final String CRLF = System.getProperty( "line.separator" ); - - private static final int LINE_END = 64; - - public static String encode( byte[] data ) - { - return Base64.encode( data, true ); - } - - public static String encode( byte[] data, boolean useLineDelimiter ) - { - if ( data == null ) - { - return null; - } - else if ( data.length == 0 ) - { - return ""; - } - - int padding = 3 - ( data.length % 3 ); - - // if ( LOG.isDebugEnabled() ) - // { - // LOG.debug( "padding = " + padding + "characters." ); - // } - - StringBuffer buffer = new StringBuffer(); - - for ( int i = 0; i < data.length; i += 3 ) - { - // if ( LOG.isDebugEnabled() ) - // { - // LOG.debug( "iteration base offset = " + i ); - // } - - int neutral = ( data[i] < 0 ? data[i] + 256 : data[i] ); - - int block = ( neutral & 0xff ); - // if ( LOG.isDebugEnabled() ) - // { - // LOG.debug( "after first byte, block = " + Integer.toBinaryString( block ) ); - // } - - boolean inLastSegment = false; - - block <<= 8; - if ( i + 1 < data.length ) - { - neutral = ( data[i + 1] < 0 ? data[i + 1] + 256 : data[i + 1] ); - block |= ( neutral & 0xff ); - } - else - { - inLastSegment = true; - } - // if ( LOG.isDebugEnabled() ) - // { - // LOG.debug( "after second byte, block = " + Integer.toBinaryString( block ) + "; inLastSegment = " - // + inLastSegment ); - // } - - block <<= 8; - if ( i + 2 < data.length ) - { - neutral = ( data[i + 2] < 0 ? data[i + 2] + 256 : data[i + 2] ); - block |= ( neutral & 0xff ); - } - else - { - inLastSegment = true; - } - // if ( LOG.isDebugEnabled() ) - // { - // LOG.debug( "after third byte, block = " + Integer.toBinaryString( block ) + "; inLastSegment = " - // + inLastSegment ); - // } - - char[] encoded = new char[4]; - int encIdx = 0; - encoded[0] = toBase64Char( ( block >>> 18 ) & 0x3f ); - // if ( LOG.isDebugEnabled() ) - // { - // LOG.debug( "first character = " + encoded[0] ); - // } - - encoded[1] = toBase64Char( ( block >>> 12 ) & 0x3f ); - // if ( LOG.isDebugEnabled() ) - // { - // LOG.debug( "second character = " + encoded[1] ); - // } - - if ( inLastSegment && padding > 1 ) - { - encoded[2] = '='; - } - else - { - encoded[2] = toBase64Char( ( block >>> 6 ) & 0x3f ); - } - // if ( LOG.isDebugEnabled() ) - // { - // LOG.debug( "third character = " + encoded[2] ); - // } - - if ( inLastSegment && padding > 0 ) - { - encoded[3] = '='; - } - else - { - encoded[3] = toBase64Char( block & 0x3f ); - } - // if ( LOG.isDebugEnabled() ) - // { - // LOG.debug( "fourth character = " + encoded[3] ); - // } - - buffer.append( encoded ); - } - - if ( useLineDelimiter ) - { - return canonicalize( buffer.toString() ); - } - else - { - return buffer.toString(); - } - } - - public static byte[] decode( String src ) - { - return Base64.decode( src, true ); - } - - public static byte[] decode( String src, boolean useLineDelimiter ) - { - if ( src == null ) - { - return null; - } - else if ( src.length() < 1 ) - { - return new byte[0]; - } - - // if ( LOG.isDebugEnabled() ) - // { - // LOG.debug( "pre-canonicalization = \n" + src ); - // } - String data = src; - - if ( useLineDelimiter ) - { - data = deCanonicalize( src ); - } - // if ( LOG.isDebugEnabled() ) - // { - // LOG.debug( "post-canonicalization = \n" + data ); - // } - - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - - char[] input = data.toCharArray(); - - int index = 0; - for ( int i = 0; i < input.length; i += 4 ) - { - // if ( LOG.isDebugEnabled() ) - // { - // LOG.debug( "iteration base offset = " + i ); - // } - - int block = ( toBase64Int( input[i] ) & 0x3f ); - // if ( LOG.isDebugEnabled() ) - // { - // LOG.debug( "block after first char [" + input[i] + "] = " + Integer.toBinaryString( block ) ); - // } - - block <<= 6; - block |= ( toBase64Int( input[i + 1] ) & 0x3f ); - // if ( LOG.isDebugEnabled() ) - // { - // LOG.debug( "block after second char [" + input[i + 1] + "] = " + Integer.toBinaryString( block ) ); - // } - - boolean inPadding = false; - boolean twoCharPadding = false; - block <<= 6; - if ( input[i + 2] != '=' ) - { - block |= ( toBase64Int( input[i + 2] ) & 0x3f ); - } - else - { - twoCharPadding = true; - inPadding = true; - } - - // if ( LOG.isDebugEnabled() ) - // { - // LOG.debug( "block after third char [" + input[i + 2] + "] = " + Integer.toBinaryString( block ) ); - // } - - block <<= 6; - if ( input[i + 3] != '=' ) - { - block |= ( toBase64Int( input[i + 3] ) & 0x3f ); - } - else - { - inPadding = true; - } - - // if ( LOG.isDebugEnabled() ) - // { - // LOG.debug( "block after fourth char [" + input[i + 3] + "] = " + Integer.toBinaryString( block ) ); - // } - - baos.write( ( block >>> 16 ) & 0xff ); - // if ( LOG.isDebugEnabled() ) - // { - // LOG.debug( "byte[" + ( index++ ) + "] = " + ( ( block >>> 16 ) & 0xff ) ); - // } - - if ( !inPadding || !twoCharPadding ) - { - baos.write( ( block >>> 8 ) & 0xff ); - // if ( LOG.isDebugEnabled() ) - // { - // LOG.debug( "byte[" + ( index++ ) + "] = " + ( ( block >>> 8 ) & 0xff ) ); - // } - } - - if ( !inPadding ) - { - baos.write( block & 0xff ); - // if ( LOG.isDebugEnabled() ) - // { - // LOG.debug( "byte[" + ( index++ ) + "] = " + ( block & 0xff ) ); - // } - } - } - - byte[] result = baos.toByteArray(); - // if ( LOG.isDebugEnabled() ) - // { - // LOG.debug( "byte array is " + result.length + " bytes long." ); - // } - - return result; - } - - private static char toBase64Char( int input ) - { - if ( input > -1 && input < 26 ) - { - return ( char ) ( 'A' + input ); - } - else if ( input > 25 && input < 52 ) - { - return ( char ) ( 'a' + input - 26 ); - } - else if ( input > 51 && input < 62 ) - { - return ( char ) ( '0' + input - 52 ); - } - else if ( input == 62 ) - { - return '+'; - } - else if ( input == 63 ) - { - return '/'; - } - else - { - return '?'; - } - } - - private static int toBase64Int( char input ) - { - if ( input >= 'A' && input <= 'Z' ) - { - return input - 'A'; - } - else if ( input >= 'a' && input <= 'z' ) - { - return input + 26 - 'a'; - } - else if ( input >= '0' && input <= '9' ) - { - return input + 52 - '0'; - } - else if ( input == '+' ) - { - return 62; - } - else if ( input == '/' ) - { - return 63; - } - else - { - return 0; - } - } - - private static String deCanonicalize( String data ) - { - if ( data == null ) - { - return null; - } - - StringBuffer buffer = new StringBuffer( data.length() ); - for ( int i = 0; i < data.length(); i++ ) - { - char c = data.charAt( i ); - if ( c != '\r' && c != '\n' ) - { - buffer.append( c ); - } - } - - return buffer.toString(); - } - - private static String canonicalize( String data ) - { - StringBuffer buffer = new StringBuffer( ( int ) ( data.length() * 1.1 ) ); - - int col = 0; - for ( int i = 0; i < data.length(); i++ ) - { - if ( col == LINE_END ) - { - buffer.append( CRLF ); - col = 0; - } - - buffer.append( data.charAt( i ) ); - col++; - } - - buffer.append( CRLF ); - - return buffer.toString(); - } - -} diff --git a/maven-mboot/src/main/Bootstrapper.java b/maven-mboot/src/main/Bootstrapper.java deleted file mode 100644 index d229433120..0000000000 --- a/maven-mboot/src/main/Bootstrapper.java +++ /dev/null @@ -1,915 +0,0 @@ -import java.io.File; -import java.io.FileInputStream; -import java.io.FileWriter; -import java.io.IOException; -import java.io.InputStream; -import java.io.Serializable; -import java.io.Writer; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Properties; - -import javax.xml.parsers.SAXParser; -import javax.xml.parsers.SAXParserFactory; - -import org.xml.sax.Attributes; -import org.xml.sax.InputSource; -import org.xml.sax.SAXParseException; -import org.xml.sax.SAXException; -import org.xml.sax.helpers.DefaultHandler; - -public class Bootstrapper -{ - private ArtifactDownloader downloader; - - private BootstrapPomParser bootstrapPomParser; - - private int pomVersion; - - private List dependencies; - - private UnitTests unitTests; - - private Properties properties; - - public static void main( String[] args ) - throws Exception - { - Bootstrapper bootstrapper = new Bootstrapper(); - - bootstrapper.execute( args ); - } - - public void execute( String[] args ) - throws Exception - { - properties = loadProperties( new File( System.getProperty( "user.home" ), "maven.properties" ) ); - - downloader = new ArtifactDownloader( properties ); - - bootstrapPomParser = new BootstrapPomParser(); - - if( ! bootstrapPomParser.parse( new File( "pom.xml" ) ) ) - { - System.err.println( "Could not parse pom.xml" ); - System.exit( 1 ); - } - - dependencies = bootstrapPomParser.getDependencies(); - - downloadDependencies(); - - writeClasspath(); - - writeUnitTest(); - - if ( bootstrapPomParser.getResources().size() == 0 ) - { - writeFile( "bootstrap.resources", "src/main/resources@'*'" ); - } - else - { - writeResources( bootstrapPomParser.getResources(), "bootstrap.resources" ); - } - - writeFile( "bootstrap.repo", downloader.getMavenRepoLocal().getPath() ); - } - - private void downloadDependencies() - throws Exception - { - List list = new ArrayList(); - - for ( Iterator i = dependencies.iterator(); i.hasNext(); ) - { - Dependency d = (Dependency) i.next(); - - list.add( getArtifactPath( d, "/" ) ); - } - - downloader.downloadDependencies( list ); - } - - private void writeClasspath() - throws Exception - { - StringBuffer classPath = new StringBuffer(); - - StringBuffer libs = new StringBuffer(); - - StringBuffer deps = new StringBuffer(); - - String repoLocal = replace( downloader.getMavenRepoLocal().getPath(), "\\", "/" ); - String classpathSeparator; - if ( repoLocal.indexOf( ":" ) != -1 ) //Windows - { - classpathSeparator = ";"; - } - else - { - classpathSeparator = ":"; - } - - for ( Iterator i = dependencies.iterator(); i.hasNext(); ) - { - Dependency d = (Dependency) i.next(); - - classPath.append( repoLocal + "/" + getArtifactPath( d, "/" ) + classpathSeparator ); - - libs.append( repoLocal + "/" + getArtifactPath( d, "/" ) + "\n" ); - - deps.append( getArtifactPath( d, "/" ) + "\n" ); - } - - writeFile( "bootstrap.classpath", classPath.toString() ); - - writeFile( "bootstrap.libs", libs.toString() ); - - writeFile( "bootstrap.deps", deps.toString() ); - } - - private void writeUnitTest() - throws Exception - { - int size; - - unitTests = bootstrapPomParser.getUnitTests(); - - if ( unitTests != null ) - { - StringBuffer tests = new StringBuffer(); - - tests.append( "target/test-classes" ); - - tests.append( "@" ); - - size = unitTests.getIncludes().size(); - - // If there are no unitTestIncludes specified then we want it all. - if ( size == 0 ) - { - tests.append( "'*Test.java'" ); - } - - for ( int j = 0; j < size; j++ ) - { - String include = (String) unitTests.getIncludes().get( j ); - - tests.append( include ); - - if ( j != size - 1 ) - { - tests.append( "," ); - } - } - - tests.append( "\n" ); - - writeFile( "bootstrap.tests.includes", tests.toString() ); - - tests = new StringBuffer(); - - tests.append( "target/test-classes" ); - - tests.append( "@" ); - - size = unitTests.getExcludes().size(); - - if ( size == 0 ) - { - tests.append( "*Abstract*.java'" ); - } - - for ( int j = 0; j < size; j++ ) - { - String exclude = (String) unitTests.getExcludes().get( j ); - - tests.append( exclude ); - - if ( j != size - 1 ) - { - tests.append( "," ); - } - } - - tests.append( "\n" ); - - writeFile( "bootstrap.tests.excludes", tests.toString() ); - - writeResources( unitTests.getResources(), "bootstrap.tests.resources" ); - } - else - { - writeFile( "bootstrap.tests.includes", "target/test-classes@**/*Test.java" ); - - writeFile( "bootstrap.tests.excludes", "target/test-classes@**/*Abstract*.java" ); - - writeFile( "bootstrap.tests.resources", "src/test/resources@'*'" ); - } - } - - private void writeResources( List resources, String file ) - throws Exception - { - StringBuffer res = new StringBuffer(); - - int size; - - for ( Iterator i = resources.iterator(); i.hasNext(); ) - { - Resource r = (Resource) i.next(); - - // Not sure why r would be null. Happening in drools-core. - if ( r == null ) - { - continue; - } - - res.append( r.getDirectory() ); - - if ( r.getTargetPath() != null ) - { - res.append( "," ).append( r.getTargetPath() ); - } - - res.append( "@" ); - - size = r.getIncludes().size(); - - // If there are no unitTestIncludes specified then we want it all. - if ( size == 0 ) - { - res.append( "'*'" ); - } - - for ( int j = 0; j < size; j++ ) - { - String include = (String) r.getIncludes().get( j ); - - if ( include.startsWith( "**/" ) ) - { - include = include.substring( 3 ); - } - - res.append( "'" ).append( include ).append( "'" ); - - if ( j != size - 1 ) - { - res.append( "," ); - } - } - - res.append( "\n" ); - } - - writeFile( file, res.toString() ); - } - - private void writeFile( String name, String contents ) - throws Exception - { - Writer writer = new FileWriter( name ); - - writer.write( contents ); - - writer.flush(); - - writer.close(); - } - - private String getArtifactPath( Dependency d, String pathSeparator ) - { - return d.getArtifactDirectory() + pathSeparator + "jars" + pathSeparator + d.getArtifact(); - } - - private Properties loadProperties( File file ) - { - try - { - return loadProperties( new FileInputStream( file ) ); - } - catch ( Exception e ) - { - // ignore - } - - return new Properties(); - } - - private static Properties loadProperties( InputStream is ) - { - Properties properties = new Properties(); - - try - { - if ( is != null ) - { - properties.load( is ); - } - } - catch ( IOException e ) - { - // ignore - } - finally - { - try - { - if ( is != null ) - { - is.close(); - } - } - catch ( IOException e ) - { - // ignore - } - } - - return properties; - } - - private String interpolate( String text, Map namespace ) - { - Iterator keys = namespace.keySet().iterator(); - - while ( keys.hasNext() ) - { - String key = keys.next().toString(); - - Object obj = namespace.get( key ); - - String value = obj.toString(); - - text = replace( text, "${" + key + "}", value ); - - if ( key.indexOf( " " ) == -1 ) - { - text = replace( text, "$" + key, value ); - } - } - return text; - } - - private String replace( String text, String repl, String with ) - { - return replace( text, repl, with, -1 ); - } - - private String replace( String text, String repl, String with, int max ) - { - if ( text == null || repl == null || with == null || repl.length() == 0 ) - { - return text; - } - - StringBuffer buf = new StringBuffer( text.length() ); - int start = 0, end = 0; - while ( ( end = text.indexOf( repl, start ) ) != -1 ) - { - buf.append( text.substring( start, end ) ).append( with ); - start = end + repl.length(); - - if ( --max == 0 ) - { - break; - } - } - buf.append( text.substring( start ) ); - return buf.toString(); - } - - class BootstrapPomParser - extends DefaultHandler - { - private String parentGroupId; - - private String parentArtifactId; - - private String parentVersion; - - private List dependencies = new ArrayList(); - - private UnitTests unitTests; - - private List resources = new ArrayList(); - - private Dependency currentDependency; - - private Resource currentResource; - - private SAXParserFactory saxFactory; - - private boolean insideParent = false; - - private boolean insideDependency = false; - - private boolean insideUnitTest = false; - - private boolean insideResource = false; - - private StringBuffer bodyText = new StringBuffer(); - - private File file; - - public List getDependencies() - { - return dependencies; - } - - public UnitTests getUnitTests() - { - return unitTests; - } - - public List getResources() - { - return resources; - } - - public boolean parse( File file ) - { - this.file = file; - - try - { - saxFactory = SAXParserFactory.newInstance(); - - SAXParser parser = saxFactory.newSAXParser(); - - InputSource is = new InputSource( new FileInputStream( file ) ); - - parser.parse( is, this ); - - return true; - } - catch ( Exception e ) - { - e.printStackTrace(); - - return false; - } - } - - public void startElement( String uri, String localName, String rawName, Attributes attributes ) - { - if ( rawName.equals( "parent" ) ) - { - insideParent = true; - } - else if ( rawName.equals( "unitTest" ) ) - { - unitTests = new UnitTests(); - - insideUnitTest = true; - } - else if ( rawName.equals( "dependency" ) ) - { - currentDependency = new Dependency(); - - insideDependency = true; - } - else if ( rawName.equals( "resource" ) ) - { - currentResource = new Resource(); - - insideResource = true; - } - } - - public void characters( char buffer[], int start, int length ) - { - bodyText.append( buffer, start, length ); - } - - private String getBodyText() - { - return bodyText.toString().trim(); - } - - public void endElement( String uri, String localName, String rawName ) - throws SAXException - { - // support both v3 and v4 - if ( rawName.equals( "extend" ) || rawName.equals( "parent" ) ) - { - File f; - - if( rawName.equals( "extend" ) ) - { - String extend = interpolate( getBodyText(), properties ); - - f = new File( file.getParentFile(), extend ); - } - else - { - if ( parentArtifactId == null || parentArtifactId.trim().length() == 0 ) - throw new SAXException( "Missing required element in : artifactId." ); - - if ( parentGroupId == null || parentGroupId.trim().length() == 0 ) - throw new SAXException( "Missing required element in : groupId." ); - - if ( parentVersion == null || parentVersion.trim().length() == 0 ) - throw new SAXException( "Missing required element in : version." ); - - f = new File( downloader.getMavenRepoLocal(), parentGroupId + "/poms/" + parentArtifactId + "-" + parentVersion + ".pom" ); - } - - BootstrapPomParser p = new BootstrapPomParser(); - - if ( ! p.parse( f ) ) - throw new SAXException( "Could not parse parent pom.xml" ); - - dependencies.addAll( p.getDependencies() ); - - unitTests = p.getUnitTests(); - - resources.addAll( p.getResources() ); - - insideParent = false; - } - else if ( rawName.equals( "unitTest" ) ) - { - insideUnitTest = false; - } - else if ( rawName.equals( "dependency" ) ) - { - dependencies.add( currentDependency ); - - insideDependency = false; - } - else if ( rawName.equals( "resource" ) ) - { - if ( insideUnitTest ) - { - unitTests.addResource( currentResource ); - } - else - { - resources.add( currentResource ); - } - - insideResource = false; - } - else if ( insideParent ) - { - if ( rawName.equals( "groupId" ) ) - { - parentGroupId = getBodyText(); - } - else if ( rawName.equals( "artifactId" ) ) - { - parentArtifactId = getBodyText(); - } - else if ( rawName.equals( "version" ) ) - { - parentVersion = getBodyText(); - } - } - else if ( insideDependency ) - { - if ( rawName.equals( "id" ) ) - { - currentDependency.setId( getBodyText() ); - } - else if ( rawName.equals( "version" ) ) - { - currentDependency.setVersion( getBodyText() ); - } - else if ( rawName.equals( "jar" ) ) - { - currentDependency.setJar( getBodyText() ); - } - else if ( rawName.equals( "type" ) ) - { - currentDependency.setType( getBodyText() ); - } - else if ( rawName.equals( "groupId" ) ) - { - currentDependency.setGroupId( getBodyText() ); - } - else if ( rawName.equals( "artifactId" ) ) - { - currentDependency.setArtifactId( getBodyText() ); - } - } - else if ( insideResource ) - { - if ( rawName.equals( "directory" ) ) - { - currentResource.setDirectory( getBodyText() ); - } - else if ( rawName.equals( "targetPath" ) ) - { - currentResource.setTargetPath( getBodyText() ); - } - else if ( rawName.equals( "include" ) ) - { - currentResource.addInclude( getBodyText() ); - } - else if ( rawName.equals( "exclude" ) ) - { - currentResource.addExclude( getBodyText() ); - } - } - else if ( !insideResource && insideUnitTest ) - { - if ( rawName.equals( "include" ) ) - { - unitTests.addInclude( getBodyText() ); - } - else if ( rawName.equals( "exclude" ) ) - { - unitTests.addExclude( getBodyText() ); - } - } - - bodyText = new StringBuffer(); - } - - public void warning( SAXParseException spe ) - { - printParseError( "Warning", spe ); - } - - public void error( SAXParseException spe ) - { - printParseError( "Error", spe ); - } - - public void fatalError( SAXParseException spe ) - { - printParseError( "Fatal Error", spe ); - } - - private final void printParseError( String type, SAXParseException spe ) - { - System.err.println( type + " [line " + spe.getLineNumber() + - ", row " + spe.getColumnNumber() + "]: " + - spe.getMessage() ); - } - } - - public static class Dependency - { - private String id; - - private String version; - - private String url; - - private String jar; - - private String artifactId; - - private String groupId; - - private String type = "jar"; - - public Dependency() - { - } - - public void setId( String id ) - { - this.id = id; - } - - public String getId() - { - if ( isValid( getGroupId() ) - && isValid( getArtifactId() ) ) - { - return getGroupId() + ":" + getArtifactId(); - } - - return id; - } - - public void setGroupId( String groupId ) - { - this.groupId = groupId; - } - - public String getGroupId() - { - return groupId; - } - - public String getArtifactDirectory() - { - if ( isValid( getGroupId() ) ) - { - return getGroupId(); - } - - return getId(); - } - - public String getArtifactId() - { - return artifactId; - } - - public void setArtifactId( String artifactId ) - { - this.artifactId = artifactId; - } - - public String getArtifact() - { - // If the jar name has been explicty set then use that. This - // is when the element is explicity used in the POM. - if ( jar != null ) - { - return jar; - } - - if ( isValid( getArtifactId() ) ) - { - return getArtifactId() + "-" + getVersion() + "." + getType(); - } - else - { - return getId() + "-" + getVersion() + "." + getType(); - } - } - - public void setVersion( String version ) - { - this.version = version; - } - - public String getVersion() - { - return version; - } - - public void setJar( String jar ) - { - // This is a check we need because of the jelly interpolation - // process. If we don't check an empty string will be set and - // screw up getArtifact() above. - if ( jar.trim().length() == 0 ) - { - return; - } - - this.jar = jar; - } - - public String getJar() - { - return jar; - } - - public void setUrl( String url ) - { - this.url = url; - } - - public String getUrl() - { - return url; - } - - public String getType() - { - return type; - } - - public void setType( String type ) - { - this.type = type; - } - - private boolean isValid( String value ) - { - if ( value != null - && value.trim().equals( "" ) == false ) - { - return true; - } - - return false; - } - } - - public static class UnitTests - implements Serializable - { - private String directory; - - private List unitTestIncludes = new ArrayList(); - - private List unitTestExcludes = new ArrayList(); - - private List unitTestResources = new ArrayList(); - - public void addInclude( String pattern ) - { - unitTestIncludes.add( pattern ); - } - - public void addExclude( String pattern ) - { - unitTestExcludes.add( pattern ); - } - - public void addResource( Resource resource ) - { - unitTestResources.add( resource ); - } - - public List getIncludes() - { - return unitTestIncludes; - } - - public List getExcludes() - { - return unitTestExcludes; - } - - public List getResources() - { - return unitTestResources; - } - - public void setDirectory( String directory ) - { - this.directory = directory; - } - - public String getDirectory() - { - return this.directory; - } - } - - public static class Resource - implements Serializable - { - private String directory; - - private String targetPath; - - private List includes = new ArrayList(); - - private List excludes = new ArrayList(); - - private boolean filtering; - - public void addInclude( String pattern ) - { - this.includes.add( pattern ); - } - - public void addExclude( String pattern ) - { - this.excludes.add( pattern ); - } - - public List getIncludes() - { - return this.includes; - } - - public List getExcludes() - { - return this.excludes; - } - - public void setDirectory( String directory ) - { - this.directory = directory; - } - - public String getDirectory() - { - return this.directory; - } - - public void setTargetPath( String targetPath ) - { - this.targetPath = targetPath; - } - - public String getTargetPath() - { - return targetPath; - } - - public boolean getFiltering() - { - return filtering; - } - - public void setFiltering( boolean filtering ) - { - this.filtering = filtering; - } - } -} diff --git a/maven-mboot/src/main/HttpUtils.java b/maven-mboot/src/main/HttpUtils.java deleted file mode 100644 index e04d753f23..0000000000 --- a/maven-mboot/src/main/HttpUtils.java +++ /dev/null @@ -1,399 +0,0 @@ -/* ==================================================================== - * Copyright 2001-2004 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ==================================================================== - */ - -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.net.Authenticator; -import java.net.HttpURLConnection; -import java.net.PasswordAuthentication; -import java.net.URL; -import java.net.URLConnection; - -/** - * Http utils for retrieving files. - * - * @author costin@dnt.ro - * @author gg@grtmail.com (Added Java 1.1 style HTTP basic auth) - * @author Jason van Zyl - * - * @todo Need to add a timeout so we can flip to a backup repository. - * @todo Download everything in a single session. - * @todo Throw meaningful exception when authentication fails. - */ -public class HttpUtils -{ - /** - * Use a proxy to bypass the firewall with or without authentication - * - * @param proxyHost Proxy Host (if proxy is required), or null - * @param proxyPort Proxy Port (if proxy is required), or null - * @param proxyUserName Proxy Username (if authentification is required), - * or null - * @param proxyPassword Proxy Password (if authentification is required), - * or null - * @throws SecurityException if an operation is not authorized by the - * SecurityManager - */ - public static void useProxyUser( final String proxyHost, - final String proxyPort, - final String proxyUserName, - final String proxyPassword ) - { - if ( proxyHost != null && proxyPort != null ) - { - System.getProperties().put( "proxySet", "true" ); - System.getProperties().put( "proxyHost", proxyHost ); - System.getProperties().put( "proxyPort", proxyPort ); - - if ( proxyUserName != null ) - { - Authenticator.setDefault( new Authenticator() - { - protected PasswordAuthentication getPasswordAuthentication() - { - return new PasswordAuthentication( proxyUserName, - proxyPassword == null ? new char[0] : proxyPassword.toCharArray() ); - } - } ); - } - } - } - - /** - * Retrieve a remote file. Throws an Exception on errors unless the - * ifnoreErrors flag is set to True - * - * @param url the of the file to retrieve - * @param destinationFile where to store it - * @param ignoreErrors whether to ignore errors during I/O or throw an - * exception when they happen - * @param useTimestamp whether to check the modified timestamp on the - * destinationFile against the remote source - * @param proxyHost Proxy Host (if proxy is required), or null - * @param proxyPort Proxy Port (if proxy is required), or null - * @param proxyUserName Proxy Username (if authentification is required), - * or null. - * @param proxyPassword Proxy Password (if authentification is required), - * or null. - * @param useChecksum Flag to indicate the use of the checksum for the retrieved - * artifact if it is available. - * @throws IOException If an I/O exception occurs. - */ - public static void getFile( String url, - File destinationFile, - boolean ignoreErrors, - boolean useTimestamp, - String proxyHost, - String proxyPort, - String proxyUserName, - String proxyPassword, - boolean useChecksum ) - throws IOException - { - // Get the requested file. - getFile( url, - destinationFile, - ignoreErrors, - useTimestamp, - proxyHost, - proxyPort, - proxyUserName, - proxyPassword ); - - // Get the checksum if requested. - if ( useChecksum ) - { - File checksumFile = new File( destinationFile + ".md5" ); - - try - { - getFile( url + ".md5", - checksumFile, - ignoreErrors, - useTimestamp, - proxyHost, - proxyPort, - proxyUserName, - proxyPassword ); - } - catch ( Exception e ) - { - // do nothing we will check later in the process - // for the checksums. - } - } - } - - /** - * Retrieve a remote file. Throws an Exception on errors unless the - * ifnoreErrors flag is set to True - * - * @param url the of the file to retrieve - * @param destinationFile where to store it - * @param ignoreErrors whether to ignore errors during I/O or throw an - * exception when they happen - * @param useTimestamp whether to check the modified timestamp on the - * destinationFile against the remote source - * @param proxyHost Proxy Host (if proxy is required), or null - * @param proxyPort Proxy Port (if proxy is required), or null - * @param proxyUserName Proxy Username (if authentification is required), - * or null - * @param proxyPassword Proxy Password (if authentification is required), - * or null - * @throws IOException If an I/O exception occurs. - */ - public static void getFile( String url, - File destinationFile, - boolean ignoreErrors, - boolean useTimestamp, - String proxyHost, - String proxyPort, - String proxyUserName, - String proxyPassword ) - throws IOException - { - //set the timestamp to the file date. - long timestamp = -1; - if ( useTimestamp && destinationFile.exists() ) - { - timestamp = destinationFile.lastModified(); - } - - try - { - getFile( url, - destinationFile, - timestamp, - proxyHost, - proxyPort, - proxyUserName, - proxyPassword ); - } - catch ( IOException ex ) - { - if ( !ignoreErrors ) - { - throw ex; - } - } - } - - /** - * Retrieve a remote file. - * - * @param url the URL of the file to retrieve - * @param destinationFile where to store it - * @param timestamp if provided, the remote URL is only retrieved if it was - * modified more recently than timestamp. Otherwise, negative value indicates that - * the remote URL should be retrieved unconditionally. - * @param proxyHost Proxy Host (if proxy is required), or null - * @param proxyPort Proxy Port (if proxy is required), or null - * @param proxyUserName Proxy Username (if authentification is required), - * or null - * @param proxyPassword Proxy Password (if authentification is required), - * or null - * @throws IOException If an I/O exception occurs. - */ - public static void getFile( String url, - File destinationFile, - long timestamp, - String proxyHost, - String proxyPort, - String proxyUserName, - String proxyPassword ) - throws IOException - { - String[] s = parseUrl( url ); - String username = s[0]; - String password = s[1]; - String parsedUrl = s[2]; - - URL source = new URL( parsedUrl ); - - //set proxy connection - useProxyUser( proxyHost, proxyPort, proxyUserName, proxyPassword ); - - //set up the URL connection - URLConnection connection = source.openConnection(); - - //modify the headers - if ( timestamp >= 0 ) - { - connection.setIfModifiedSince( timestamp ); - } - // prepare Java 1.1 style credentials - if ( username != null || password != null ) - { - String up = username + ":" + password; - String encoding = Base64.encode(up.getBytes(), false); - connection.setRequestProperty( "Authorization", "Basic " + encoding ); - } - - //connect to the remote site (may take some time) - connection.connect(); - //next test for a 304 result (HTTP only) - if ( connection instanceof HttpURLConnection ) - { - HttpURLConnection httpConnection = (HttpURLConnection) connection; - // although HTTPUrlConnection javadocs says FileNotFoundException should be - // thrown on a 404 error, that certainly does not appear to be the case, so - // test for 404 ourselves, and throw FileNotFoundException as needed - if ( httpConnection.getResponseCode() == HttpURLConnection.HTTP_NOT_FOUND) - { - throw new FileNotFoundException(url.toString() + " (HTTP Error: " - + httpConnection.getResponseCode() + " " + httpConnection.getResponseMessage() + ")"); - } - if ( httpConnection.getResponseCode() == HttpURLConnection.HTTP_NOT_MODIFIED ) - { - return; - } - // test for 401 result (HTTP only) - if ( httpConnection.getResponseCode() == HttpURLConnection.HTTP_UNAUTHORIZED ) - { - throw new IOException( "Not authorized." ); - } - // test for 407 result (HTTP only) - if ( httpConnection.getResponseCode() == HttpURLConnection.HTTP_PROXY_AUTH ) - { - throw new IOException( "Not authorized by proxy." ); - } - } - - // REVISIT: at this point even non HTTP connections may support the - // if-modified-since behaviour - we just check the date of the - // content and skip the write if it is not newer. - // Some protocols (FTP) dont include dates, of course. - - InputStream is = null; - IOException isException = null; - for ( int i = 0; i < 3; i++ ) - { - try - { - is = connection.getInputStream(); - break; - } - catch ( IOException ex ) - { - isException = ex; - } - } - if ( is == null ) - { - throw isException; - } - - if ( connection.getLastModified() <= timestamp && - connection.getLastModified() != 0 ) - { - return; - } - - FileOutputStream fos = new FileOutputStream( destinationFile ); - - byte[] buffer = new byte[100 * 1024]; - int length; - - while ( ( length = is.read( buffer ) ) >= 0 ) - { - fos.write( buffer, 0, length ); - System.out.print( "." ); - } - - System.out.println(); - fos.close(); - is.close(); - - // if (and only if) the use file time option is set, then the - // saved file now has its timestamp set to that of the downloaded - // file - if ( timestamp >= 0 ) - { - long remoteTimestamp = connection.getLastModified(); - if ( remoteTimestamp != 0 ) - { - touchFile( destinationFile, remoteTimestamp ); - } - } - } - - /** - * Parse an url which might contain a username and password. If the - * given url doesn't contain a username and password then return the - * origin url unchanged. - * - * @param url The url to parse. - * @return The username, password and url. - * @throws RuntimeException if the url is (very) invalid - */ - static String[] parseUrl( String url ) - { - String[] parsedUrl = new String[3]; - parsedUrl[0] = null; - parsedUrl[1] = null; - parsedUrl[2] = url; - - // We want to be able to deal with Basic Auth where the username - // and password are part of the URL. An example of the URL string - // we would like to be able to parse is like the following: - // - // http://username:password@repository.mycompany.com - - int i = url.indexOf( "@" ); - if ( i > 0 ) - { - String protocol = url.substring( 0, url.indexOf("://") ) + "://"; - String s = url.substring( protocol.length(), i ); - int j = s.indexOf( ":" ); - parsedUrl[0] = s.substring( 0, j ); - parsedUrl[1] = s.substring( j + 1 ); - parsedUrl[2] = protocol + url.substring( i + 1 ); - } - - return parsedUrl; - } - - /** - * set the timestamp of a named file to a specified time. - * - * @param file the file to touch - * @param timemillis in milliseconds since the start of the era - * @return true if it succeeded. False means that this is a java1.1 system - * and that file times can not be set - * @throws RuntimeException Thrown in unrecoverable error. Likely this - * comes from file access failures. - */ - private static boolean touchFile( File file, long timemillis ) - { - long modifiedTime; - - if ( timemillis < 0 ) - { - modifiedTime = System.currentTimeMillis(); - } - else - { - modifiedTime = timemillis; - } - - file.setLastModified( modifiedTime ); - return true; - } -} diff --git a/maven-mboot/src/sea/sea-header b/maven-mboot/src/sea/sea-header deleted file mode 100644 index ddb1cdd067..0000000000 --- a/maven-mboot/src/sea/sea-header +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/sh - -echo "-----------------------------------------------------------------------" -echo Maven MBoot -echo "-----------------------------------------------------------------------" - -if [ -z $MBOOT_HOME ]; then - -echo -echo "Where would you like to install mboot? [ ~/mboot ] " -echo - -read MBOOT_HOME - -[ -z $MBOOT_HOME ] && MBOOT_HOME=$HOME/mboot - -export MBOOT_HOME -fi - -DIR=$MBOOT_HOME - -echo "Installing mboot in $DIR ..." - -export DIR - -[ -d $DIR ] && rm -rf $DIR - -mkdir $DIR - -SKIP=`awk '/^__ARCHIVE_FOLLOWS__/ { print NR + 1; exit 0; }' $0` - -# Take the TGZ portion of this file and pipe it to tar. -tail -n +$SKIP $0 | tar xz -C $DIR - -. ${MBOOT_HOME}/maven.functions - -echo "-----------------------------------------------------------------------" -echo "Installing MBoot dependencies ... " -echo "-----------------------------------------------------------------------" - -downloadMBootDependencies - -exit 0 - -__ARCHIVE_FOLLOWS__ diff --git a/maven-mboot/src/site/apt/index.apt b/maven-mboot/src/site/apt/index.apt deleted file mode 100644 index ab7d50a7e4..0000000000 --- a/maven-mboot/src/site/apt/index.apt +++ /dev/null @@ -1,26 +0,0 @@ - ----- - Maven MBoot - ----- - Jason van Zyl - ----- - -Maven MBoot - - Maven MBoot is the tool that is used to bootstrap m2. It is a mix of - some Java code and some bash glue which allows most m2 projects to be - built without m2 itself. The use of MBoot is limited to environments that - have access to a bash shell so any Linux system will do or Cygwin under - Windows. No attempt will be made to port MBoot to Windows so don't - bother asking. For consistency and reliability reasons that platform - for bootstrapping m2 will be a Linux machine. We have supported Cygwin - for some convenience but that's as far as we will go. - -What can MBoot do? - - MBoot can build m2 projects, but it also has some other capabilities that - are required by the m2 bootstrap process. MBoot also is a wrapper for - Modello and our plugin artifact generating tools. Modello is used to - generate the model sources, xpp3 reader, xpp3 writer, an XSD and the - documentation for m2's data model. We also generate the plugin - descriptors for the core m2 plugins as well as generating adapters - for m2 plugins that allow m2 plugins to run in maven 1.x.