jvanzyl 2004/01/27 10:58:12
Modified: maven-mboot/src/bash maven.functions
maven-mboot/src/main Bootstrapper.java HttpUtils.java
Log:
o general cleanup
o add the ability to deal with test resources
Revision Changes Path
1.14 +11 -5 maven-components/maven-mboot/src/bash/maven.functions
Index: maven.functions
===================================================================
RCS file: /home/cvs/maven-components/maven-mboot/src/bash/maven.functions,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- maven.functions 26 Jan 2004 07:16:16 -0000 1.13
+++ maven.functions 27 Jan 2004 18:58:11 -0000 1.14
@@ -49,7 +49,8 @@
if [ -f $5 ]
then
- "${JAVACMD}" -classpath "$CP" TestRunnerBooter "$2" "$3" $4 $5 $6
+ echo ">>> $CP"
+ "${JAVACMD}" -classpath "$CP" org.codehaus.surefire.SureFire "$2" "$3" $4 $5 $6
fi
}
@@ -173,11 +174,13 @@
fi
- copyResources
+ copyResources bootstrap.resources target/classes
+
+ copyResources bootstrap.test.resources target/test-classes
echo "Running tests in `pwd`"
- runTests
".:${MBOOT_HOME}/classes:$repoLocal/junit/jars/junit-3.8.1.jar:$repoLocal/maven/jars/surefire-runner-1.0.jar:$repoLocal/plexus/jars/plexus-utils-1.0-beta-1.jar"
"$home" "$repoLocal" bootstrap.libs bootstrap.tests.includes bootstrap.tests.excludes
+ runTests ".:${MBOOT_HOME}/classes:$repoLocal/surefire/jars/surefire-0.5.jar"
"$home" "$repoLocal" bootstrap.libs bootstrap.tests.includes bootstrap.tests.excludes
if [ "$2" = "default" ]
then
@@ -227,7 +230,10 @@
copyResources()
{
- resources=`cat bootstrap.resources`
+ # $1 == resourcesfile
+ # $2 == target directory
+
+ resources=`cat $1`
for i in $resources
do
@@ -250,7 +256,7 @@
# path into the target directory.
path=`echo $tmpFile | sed "s/$tmpDirectory//;s/\@/\//g;s/^\///"`
- targetDirectory="target/classes"
+ targetDirectory=$2
[ ! -z $MBOOT_DEBUG ] && echo "path = $path"
1.12 +74 -52 maven-components/maven-mboot/src/main/Bootstrapper.java
Index: Bootstrapper.java
===================================================================
RCS file: /home/cvs/maven-components/maven-mboot/src/main/Bootstrapper.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- Bootstrapper.java 25 Jan 2004 00:27:01 -0000 1.11
+++ Bootstrapper.java 27 Jan 2004 18:58:11 -0000 1.12
@@ -1,4 +1,3 @@
-
import org.xml.sax.Attributes;
import org.xml.sax.InputSource;
import org.xml.sax.SAXParseException;
@@ -38,8 +37,6 @@
public void execute( String[] args )
throws Exception
{
- String basedir = args[0];
-
downloader = new ArtifactDownloader();
bootstrapPomParser = new BootstrapPomParser();
@@ -48,6 +45,20 @@
dependencies = bootstrapPomParser.getDependencies();
+ downloadDependencies();
+
+ writeClasspath();
+
+ writeUnitTest();
+
+ 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(); )
@@ -58,7 +69,11 @@
}
downloader.downloadDependencies( list );
+ }
+ private void writeClasspath()
+ throws Exception
+ {
StringBuffer classPath = new StringBuffer();
StringBuffer libs = new StringBuffer();
@@ -75,7 +90,11 @@
writeFile( "bootstrap.classpath", classPath.toString() );
writeFile( "bootstrap.libs", libs.toString() );
+ }
+ private void writeUnitTest()
+ throws Exception
+ {
int size;
unitTests = bootstrapPomParser.getUnitTests();
@@ -84,13 +103,13 @@
{
StringBuffer tests = new StringBuffer();
- tests.append( unitTests.getDirectory() );
+ tests.append( "target/test-classes" );
tests.append( "@" );
size = unitTests.getIncludes().size();
- // If there are no includes specified then we want it all.
+ // If there are no unitTestIncludes specified then we want it all.
if ( size == 0 )
{
tests.append( "'*'" );
@@ -114,7 +133,7 @@
tests = new StringBuffer();
- tests.append( unitTests.getDirectory() );
+ tests.append( "target/test-classes" );
tests.append( "@" );
@@ -135,12 +154,18 @@
tests.append( "\n" );
writeFile( "bootstrap.tests.excludes", tests.toString() );
- }
- resources = bootstrapPomParser.getResources();
+ writeResources( unitTests.getResources(), "bootstrap.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();
@@ -162,7 +187,7 @@
size = r.getIncludes().size();
- // If there are no includes specified then we want it all.
+ // If there are no unitTestIncludes specified then we want it all.
if ( size == 0 )
{
res.append( "'*'" );
@@ -188,9 +213,7 @@
res.append( "\n" );
}
- writeFile( "bootstrap.resources", res.toString() );
-
- writeFile( "bootstrap.repo", downloader.getMavenRepoLocal().getPath() );
+ writeFile( file, res.toString() );
}
private void writeFile( String name, String contents )
@@ -270,17 +293,10 @@
public void startElement( String uri, String localName, String rawName,
Attributes attributes )
{
- if ( insideUnitTest )
- {
- return;
- }
- else if ( rawName.equals( "unitTestSourceDirectory" ) )
- {
- unitTests = new UnitTests();
- }
- else if ( rawName.equals( "unitTest" ) )
+ if ( rawName.equals( "unitTest" ) )
{
unitTests = new UnitTests();
+
insideUnitTest = true;
}
else if ( rawName.equals( "dependency" ) )
@@ -323,10 +339,6 @@
resources.addAll( p.getResources() );
}
- else if ( rawName.equals( "unitTestSourceDirectory" ) )
- {
- unitTests.setDirectory( getBodyText() );
- }
else if ( rawName.equals( "unitTest" ) )
{
insideUnitTest = false;
@@ -339,7 +351,14 @@
}
else if ( rawName.equals( "resource" ) )
{
- resources.add( currentResource );
+ if ( insideUnitTest )
+ {
+ unitTests.addResource( currentResource );
+ }
+ else
+ {
+ resources.add( currentResource );
+ }
insideResource = false;
}
@@ -369,18 +388,6 @@
{
currentDependency.setArtifactId( getBodyText() );
}
-
- }
- else if ( insideUnitTest )
- {
- if ( rawName.equals( "include" ) )
- {
- unitTests.addInclude( getBodyText() );
- }
- else if ( rawName.equals( "exclude" ) )
- {
- unitTests.addExclude( getBodyText() );
- }
}
else if ( insideResource )
{
@@ -401,6 +408,17 @@
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();
}
@@ -458,14 +476,6 @@
if ( isValid( getGroupId() )
&& isValid( getArtifactId() ) )
{
- // We have something like:
- //
- // <dependency>
- // <groupId>commons-jelly</groupId>
- // <artifactId>commons-jelly-tags-velocity</artifactId>
- // <version>SNAPSHOT</version>
- // </dependency>
-
return getGroupId() + ":" + getArtifactId();
}
@@ -586,28 +596,40 @@
{
private String directory;
- private List includes = new ArrayList();
+ private List unitTestIncludes = new ArrayList();
- private List excludes = new ArrayList();
+ private List unitTestExcludes = new ArrayList();
+
+ private List unitTestResources = new ArrayList();
public void addInclude( String pattern )
{
- this.includes.add( pattern );
+ unitTestIncludes.add( pattern );
}
public void addExclude( String pattern )
{
- this.excludes.add( pattern );
+ unitTestExcludes.add( pattern );
+ }
+
+ public void addResource( Resource resource )
+ {
+ unitTestResources.add( resource );
}
public List getIncludes()
{
- return this.includes;
+ return unitTestIncludes;
}
public List getExcludes()
{
- return this.excludes;
+ return unitTestExcludes;
+ }
+
+ public List getResources()
+ {
+ return unitTestResources;
}
public void setDirectory( String directory )
1.2 +1 -75 maven-components/maven-mboot/src/main/HttpUtils.java
Index: HttpUtils.java
===================================================================
RCS file: /home/cvs/maven-components/maven-mboot/src/main/HttpUtils.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- HttpUtils.java 3 Jan 2004 05:33:27 -0000 1.1
+++ HttpUtils.java 27 Jan 2004 18:58:11 -0000 1.2
@@ -8,29 +8,8 @@
import java.net.URL;
import java.net.URLConnection;
-/**
- * Http utils for retrieving files.
- *
- * @author [EMAIL PROTECTED]
- * @author [EMAIL PROTECTED] (Added Java 1.1 style HTTP basic auth)
- * @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
- *
- * @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
- */
public static void useProxyUser( final String proxyHost,
final String proxyPort,
final String proxyUserName,
@@ -56,25 +35,6 @@
}
}
- /**
- * Retrieve a remote file. Returns true if the file was successfully
- * retrieved or if it is up to date (when the useTimestamp flag is set).
- *
- * @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
- * <code>destinationFile</code> against the remote <code>source</code>
- * @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.
- */
public static void getFile( String url,
File destinationFile,
boolean ignoreErrors,
@@ -120,23 +80,6 @@
}
}
- /**
- * Retrieve a remote file. Returns true if the file was successfully
- * retrieved or if it is up to date (when the useTimestamp flag is set).
- *
- * @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
- * <code>destinationFile</code> against the remote <code>source</code>
- * @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
- */
public static void getFile( String url,
File destinationFile,
boolean ignoreErrors,
@@ -272,14 +215,6 @@
}
}
- /**
- * 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.
- */
static String[] parseUrl( String url )
{
String[] parsedUrl = new String[3];
@@ -306,16 +241,6 @@
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
- * @exception Exception Thrown in unrecoverable error. Likely this
- * comes from file access failures.
- */
private static boolean touchFile( File file, long timemillis )
throws Exception
{
@@ -331,6 +256,7 @@
}
file.setLastModified( modifiedTime );
+
return true;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]