*** empty log message ***
git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@114645 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
1 parent
69f76de01e
commit
ae555005ab
6 files changed
+5
-213
No files matched your search
@@ -27,6 +27,8 @@
|
||||
<j:if test="${unitTestSourcesPresent == 'true'}">
|
||||
|
||||
<javac
|
||||
srcdir="${pom.testCompileSourceRoots}"
|
||||
classpath="${pom.dependencyClasspath}:${maven.build.dest}:${plugin.getDependencyPath('junit')}"
|
||||
destdir="${maven.test.dest}"
|
||||
excludes="**/package.html"
|
||||
debug="${maven.compile.debug}"
|
||||
@@ -35,15 +37,14 @@
|
||||
<j:if test="${context.getVariable('maven.test.source') != null}">
|
||||
<setProperty name="source" value="${maven.test.source}" />
|
||||
</j:if>
|
||||
<!--
|
||||
<classpath>
|
||||
<pathelement path="${maven.test.dest}"/>
|
||||
<pathelement path="${maven.build.dest}"/>
|
||||
<path refid="maven.dependency.classpath"/>
|
||||
<pathelement path="${pom.dependencyClasspath}"/>
|
||||
<pathelement path="${plugin.getDependencyPath('junit')}"/>
|
||||
</classpath>
|
||||
<src>
|
||||
<path refid="maven.test.compile.src.set"/>
|
||||
</src>
|
||||
-->
|
||||
<j:if test="${context.getVariable('maven.compile.compilerargs') != null}">
|
||||
<compilerarg line="${maven.compile.compilerargs}" />
|
||||
</j:if>
|
||||
|
||||
@@ -18,30 +18,10 @@
|
||||
<developers>
|
||||
</developers>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>3.8.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>maven</groupId>
|
||||
<artifactId>test-runner</artifactId>
|
||||
<version>1.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>maven</groupId>
|
||||
<artifactId>maven-model</artifactId>
|
||||
<version>2.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>maven</groupId>
|
||||
<artifactId>maven-project</artifactId>
|
||||
<version>2.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>plexus</groupId>
|
||||
<artifactId>plexus</artifactId>
|
||||
<version>0.14-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
Binary file not shown.
@@ -1,59 +0,0 @@
|
||||
package org.apache.maven.test;
|
||||
|
||||
import java.net.URLClassLoader;
|
||||
import java.net.URL;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
|
||||
*
|
||||
* @version $Id: IsolatedClassLoader.java,v 1.1 2004/01/09 16:22:59 jvanzyl Exp $
|
||||
*/
|
||||
public class IsolatedClassLoader
|
||||
extends URLClassLoader
|
||||
{
|
||||
private ClassLoader parent = ClassLoader.getSystemClassLoader();
|
||||
|
||||
public IsolatedClassLoader()
|
||||
{
|
||||
super( new URL[0], null );
|
||||
}
|
||||
|
||||
public void addURL( URL url )
|
||||
{
|
||||
super.addURL( url );
|
||||
}
|
||||
|
||||
public synchronized Class loadClass( String className )
|
||||
throws ClassNotFoundException
|
||||
{
|
||||
Class c = findLoadedClass( className );
|
||||
|
||||
ClassNotFoundException ex = null;
|
||||
|
||||
if ( c == null )
|
||||
{
|
||||
try
|
||||
{
|
||||
c = findClass( className );
|
||||
}
|
||||
catch ( ClassNotFoundException e )
|
||||
{
|
||||
ex = e;
|
||||
|
||||
if ( parent != null )
|
||||
{
|
||||
c = parent.loadClass( className );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( c == null )
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -1,130 +0,0 @@
|
||||
package org.apache.maven.test;
|
||||
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.model.Dependency;
|
||||
import org.apache.maven.project.Project;
|
||||
import org.codehaus.plexus.util.DirectoryScanner;
|
||||
import org.codehaus.plexus.util.StringUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.MalformedURLException;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
public class TestRunnerBooter
|
||||
{
|
||||
private Project project;
|
||||
|
||||
public void setProject( Project project )
|
||||
{
|
||||
this.project = project;
|
||||
}
|
||||
|
||||
public void execute()
|
||||
throws Exception
|
||||
{
|
||||
// maven.build.dest
|
||||
// maven.test.dest
|
||||
|
||||
IsolatedClassLoader classLoader = new IsolatedClassLoader();
|
||||
|
||||
File basedir = project.getFile().getParentFile();
|
||||
|
||||
System.setProperty( "basedir", basedir.getPath() );
|
||||
|
||||
Thread.currentThread().setContextClassLoader( classLoader );
|
||||
|
||||
String mavenRepoLocal = project.getProperty( "maven.repo.local" );
|
||||
|
||||
classLoader.addURL( new File ( mavenRepoLocal, "junit/jars/junit-3.8.1.jar" ).toURL() );
|
||||
|
||||
classLoader.addURL( new File ( mavenRepoLocal, "maven/jars/surefire-runner-1.0.jar" ).toURL() );
|
||||
|
||||
classLoader.addURL( new File( basedir, "target/classes/" ).toURL() );
|
||||
|
||||
classLoader.addURL( new File( basedir, "target/test-classes/" ).toURL() );
|
||||
|
||||
processDependencies( project, classLoader );
|
||||
|
||||
String[] tests = collectTests( basedir,
|
||||
project.getBuild().getUnitTest().getIncludes(),
|
||||
project.getBuild().getUnitTest().getExcludes() );
|
||||
|
||||
Class testRunnerClass = classLoader.loadClass( "org.apache.maven.test.TestRunner" );
|
||||
|
||||
Object testRunner = testRunnerClass.newInstance();
|
||||
|
||||
Method m = testRunnerClass.getMethod( "runTestClasses", new Class[] {
|
||||
ClassLoader.class,
|
||||
String[].class
|
||||
} );
|
||||
|
||||
m.invoke( testRunner, new Object[]{
|
||||
classLoader,
|
||||
tests
|
||||
} );
|
||||
}
|
||||
|
||||
// We need to deal with populating a plugin classloader with its requirements.
|
||||
private void processDependencies( Project project, IsolatedClassLoader classLoader )
|
||||
throws MalformedURLException
|
||||
{
|
||||
if ( project.getArtifacts() == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for ( Iterator i = project.getArtifacts().iterator(); i.hasNext(); )
|
||||
{
|
||||
Artifact artifact = (Artifact) i.next();
|
||||
|
||||
Dependency dependency = artifact.getDependency();
|
||||
|
||||
// Only add compile type dependencies to classloader
|
||||
if ( dependency.getType().equals( "jar" ) )
|
||||
{
|
||||
// We have the jar and the classloader to push it into so
|
||||
// lets do it!
|
||||
if ( artifact.exists() )
|
||||
{
|
||||
classLoader.addURL( artifact.getFile().toURL() );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String[] collectTests( File basedir, List includes, List excludes )
|
||||
throws Exception
|
||||
{
|
||||
DirectoryScanner scanner = new DirectoryScanner();
|
||||
|
||||
scanner.setBasedir( new File( basedir, "target/test-classes" ) );
|
||||
|
||||
String[] incs = new String[includes.size()];
|
||||
|
||||
for ( int i = 0; i < incs.length; i++ )
|
||||
{
|
||||
incs[i] = StringUtils.replace( (String) includes.get( i ), "java", "class" );
|
||||
}
|
||||
|
||||
scanner.setIncludes( incs );
|
||||
|
||||
String[] excls = new String[excludes.size() + 1];
|
||||
|
||||
for ( int i = 0; i < excls.length - 1; i++ )
|
||||
{
|
||||
excls[i] = StringUtils.replace( (String) excludes.get( i ), "java", "class" );
|
||||
}
|
||||
|
||||
// Exclude inner classes
|
||||
|
||||
excls[excludes.size()] = "**/*$*";
|
||||
|
||||
scanner.setExcludes( excls );
|
||||
|
||||
scanner.scan();
|
||||
|
||||
return scanner.getIncludedFiles();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user