mirror of
https://github.com/apache/maven.git
synced 2025-02-21 01:15:42 +00:00
o general cleanup
o add the ability to deal with test resources git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@162551 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
7cbde03de8
commit
0abaebbe29
@ -49,7 +49,8 @@ runTests()
|
||||
|
||||
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 @@ buildMavenProject()
|
||||
|
||||
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 @@ getJarName()
|
||||
|
||||
copyResources()
|
||||
{
|
||||
resources=`cat bootstrap.resources`
|
||||
# $1 == resourcesfile
|
||||
# $2 == target directory
|
||||
|
||||
resources=`cat $1`
|
||||
|
||||
for i in $resources
|
||||
do
|
||||
@ -250,7 +256,7 @@ copyResources()
|
||||
# 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,4 +1,3 @@
|
||||
|
||||
import org.xml.sax.Attributes;
|
||||
import org.xml.sax.InputSource;
|
||||
import org.xml.sax.SAXParseException;
|
||||
@ -38,8 +37,6 @@ public static void main( String[] args )
|
||||
public void execute( String[] args )
|
||||
throws Exception
|
||||
{
|
||||
String basedir = args[0];
|
||||
|
||||
downloader = new ArtifactDownloader();
|
||||
|
||||
bootstrapPomParser = new BootstrapPomParser();
|
||||
@ -48,6 +45,20 @@ public void execute( String[] args )
|
||||
|
||||
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 @@ public void execute( String[] args )
|
||||
}
|
||||
|
||||
downloader.downloadDependencies( list );
|
||||
}
|
||||
|
||||
private void writeClasspath()
|
||||
throws Exception
|
||||
{
|
||||
StringBuffer classPath = new StringBuffer();
|
||||
|
||||
StringBuffer libs = new StringBuffer();
|
||||
@ -75,7 +90,11 @@ public void execute( String[] args )
|
||||
writeFile( "bootstrap.classpath", classPath.toString() );
|
||||
|
||||
writeFile( "bootstrap.libs", libs.toString() );
|
||||
}
|
||||
|
||||
private void writeUnitTest()
|
||||
throws Exception
|
||||
{
|
||||
int size;
|
||||
|
||||
unitTests = bootstrapPomParser.getUnitTests();
|
||||
@ -84,13 +103,13 @@ public void execute( String[] args )
|
||||
{
|
||||
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 @@ public void execute( String[] args )
|
||||
|
||||
tests = new StringBuffer();
|
||||
|
||||
tests.append( unitTests.getDirectory() );
|
||||
tests.append( "target/test-classes" );
|
||||
|
||||
tests.append( "@" );
|
||||
|
||||
@ -135,12 +154,18 @@ public void execute( String[] args )
|
||||
tests.append( "\n" );
|
||||
|
||||
writeFile( "bootstrap.tests.excludes", tests.toString() );
|
||||
|
||||
writeResources( unitTests.getResources(), "bootstrap.test.resources" );
|
||||
}
|
||||
}
|
||||
|
||||
resources = bootstrapPomParser.getResources();
|
||||
|
||||
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 @@ public void execute( String[] args )
|
||||
|
||||
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 @@ public void execute( String[] args )
|
||||
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 parse( File file )
|
||||
|
||||
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 @@ public void endElement( String uri, String localName, String rawName )
|
||||
|
||||
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( "dependency" ) )
|
||||
}
|
||||
else if ( rawName.equals( "resource" ) )
|
||||
{
|
||||
resources.add( currentResource );
|
||||
if ( insideUnitTest )
|
||||
{
|
||||
unitTests.addResource( currentResource );
|
||||
}
|
||||
else
|
||||
{
|
||||
resources.add( currentResource );
|
||||
}
|
||||
|
||||
insideResource = false;
|
||||
}
|
||||
@ -369,18 +388,6 @@ else if ( rawName.equals( "artifactId" ) )
|
||||
{
|
||||
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 @@ 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();
|
||||
}
|
||||
@ -458,14 +476,6 @@ public String getId()
|
||||
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 @@ public static class UnitTests
|
||||
{
|
||||
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 )
|
||||
|
@ -8,29 +8,8 @@
|
||||
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 <a href="mailto:jason@zenplex.com">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 @@ protected PasswordAuthentication getPasswordAuthentication()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 @@ public static void getFile( String url,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 @@ public static void getFile( String url,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 @@ static String[] parseUrl( String url )
|
||||
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 @@ private static boolean touchFile( File file, long timemillis )
|
||||
}
|
||||
|
||||
file.setLastModified( modifiedTime );
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user