make surefire and rest of m2 independent of repo layout

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@163751 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Leslie Porter 2005-04-04 03:48:01 +00:00
parent 0b06278758
commit baca1f7841
4 changed files with 22 additions and 25 deletions

View File

@ -19,7 +19,7 @@ package org.apache.maven;
public class MavenConstants public class MavenConstants
{ {
public static final String MAVEN_VERSION = "2.0-alpha-1-SNAPSHOT"; public static final String MAVEN_VERSION = "2.0-alpha-1-SNAPSHOT";
public static final String MAVEN_MODEL_VERSION = "4.0.0"; public static final String MAVEN_MODEL_VERSION = "4.0.0";
@ -37,7 +37,5 @@ public class MavenConstants
// maven.properties // maven.properties
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
public static final String MAVEN_REPO_LOCAL = "maven.repo.local";
public static final String MAVEN_ONLINE = "maven.online"; public static final String MAVEN_ONLINE = "maven.online";
} }

View File

@ -409,9 +409,6 @@ public class MavenCli
new File( userConfigurationDirectory, MavenConstants.MAVEN_REPOSITORY ).getAbsolutePath(); new File( userConfigurationDirectory, MavenConstants.MAVEN_REPOSITORY ).getAbsolutePath();
} }
// TODO [BP]: this should not be necessary - grep for and remove
System.setProperty( MavenConstants.MAVEN_REPO_LOCAL, localRepository );
Repository repo = new Repository(); Repository repo = new Repository();
repo.setId( "local" ); repo.setId( "local" );

View File

@ -55,11 +55,6 @@ public class PluginParameterExpressionEvaluator
{ {
value = context.getLocalRepository(); value = context.getLocalRepository();
} }
else if ( expression.equals( "#maven.repo.local" ) )
{
// TODO: remove this alias: but note that it is a string instead of an ArtifactRepository
value = context.getLocalRepository().getUrl().substring( "file://".length() );
}
else if ( expression.equals( "#maven.final.name" ) ) else if ( expression.equals( "#maven.final.name" ) )
{ {
// TODO: remove this alias // TODO: remove this alias

View File

@ -16,6 +16,9 @@ package org.apache.maven.test;
* limitations under the License. * limitations under the License.
*/ */
import org.apache.maven.artifact.DefaultArtifact;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.layout.ArtifactPathFormatException;
import org.apache.maven.plugin.AbstractPlugin; import org.apache.maven.plugin.AbstractPlugin;
import org.apache.maven.plugin.PluginExecutionException; import org.apache.maven.plugin.PluginExecutionException;
import org.codehaus.surefire.SurefireBooter; import org.codehaus.surefire.SurefireBooter;
@ -31,12 +34,6 @@ import java.util.StringTokenizer;
* @version $Id$ * @version $Id$
* @goal test * @goal test
* @description Run tests using surefire * @description Run tests using surefire
* @parameter name="mavenRepoLocal"
* type="String"
* required="true"
* validator="validator"
* expression="#maven.repo.local"
* description=""
* @parameter name="basedir" * @parameter name="basedir"
* type="String" * type="String"
* required="true" * required="true"
@ -85,14 +82,13 @@ import java.util.StringTokenizer;
* validator="" * validator=""
* expression="#test" * expression="#test"
* description="Specify this parameter if you want to use the test regex notation to select tests to run." * description="Specify this parameter if you want to use the test regex notation to select tests to run."
* @parameter name="localRepository" type="ArtifactRepository" required="true" validator="" expression="#localRepository" description=""
* @todo make version of junit and surefire configurable * @todo make version of junit and surefire configurable
* @todo make report to be produced configurable * @todo make report to be produced configurable
*/ */
public class SurefirePlugin public class SurefirePlugin
extends AbstractPlugin extends AbstractPlugin
{ {
private String mavenRepoLocal;
private String basedir; private String basedir;
private String classesDirectory; private String classesDirectory;
@ -109,6 +105,8 @@ public class SurefirePlugin
private List excludes; private List excludes;
private ArtifactRepository localRepository;
public void execute() public void execute()
throws PluginExecutionException throws PluginExecutionException
{ {
@ -118,8 +116,7 @@ public class SurefirePlugin
SurefireBooter surefireBooter = new SurefireBooter(); SurefireBooter surefireBooter = new SurefireBooter();
System.out.println( "Setting reports dir: " + reportsDirectory ); getLog().info( "Setting reports dir: " + reportsDirectory );
System.out.flush();
surefireBooter.setReportsDirectory( reportsDirectory ); surefireBooter.setReportsDirectory( reportsDirectory );
@ -170,10 +167,20 @@ public class SurefirePlugin
System.setProperty( "basedir", basedir ); System.setProperty( "basedir", basedir );
surefireBooter.addClassPathUrl( new File( mavenRepoLocal, "junit/jars/junit-3.8.1.jar" ).getPath() ); // TODO: we should really just trust the plugin classloader?
try
surefireBooter.addClassPathUrl( {
new File( mavenRepoLocal, "surefire/jars/surefire-1.2-SNAPSHOT.jar" ).getPath() ); DefaultArtifact artifact = new DefaultArtifact( "junit", "junit", "3.8.1", "jar" );
File file = new File( localRepository.getBasedir(), localRepository.pathOf( artifact ) );
surefireBooter.addClassPathUrl( file.getAbsolutePath() );
artifact = new DefaultArtifact( "surefire", "surefire", "1.2", "jar" );
file = new File( localRepository.getBasedir(), localRepository.pathOf( artifact ) );
surefireBooter.addClassPathUrl( file.getAbsolutePath() );
}
catch ( ArtifactPathFormatException e )
{
throw new PluginExecutionException( "Error finding surefire JAR", e );
}
surefireBooter.addClassPathUrl( new File( classesDirectory ).getPath() ); surefireBooter.addClassPathUrl( new File( classesDirectory ).getPath() );