brett 2005/04/03 20:48:01
Modified: maven-core/src/main/java/org/apache/maven/cli MavenCli.java maven-core/src/main/java/org/apache/maven/plugin PluginParameterExpressionEvaluator.java maven-core/src/main/java/org/apache/maven MavenConstants.java maven-plugins/maven-surefire-plugin/src/main/java/org/apache/maven/test SurefirePlugin.java Log: make surefire and rest of m2 independent of repo layout Revision Changes Path 1.26 +1 -4 maven-components/maven-core/src/main/java/org/apache/maven/cli/MavenCli.java Index: MavenCli.java =================================================================== RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/cli/MavenCli.java,v retrieving revision 1.25 retrieving revision 1.26 diff -u -r1.25 -r1.26 --- MavenCli.java 30 Mar 2005 04:52:01 -0000 1.25 +++ MavenCli.java 4 Apr 2005 03:48:01 -0000 1.26 @@ -409,9 +409,6 @@ 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(); repo.setId( "local" ); 1.12 +1 -6 maven-components/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterExpressionEvaluator.java Index: PluginParameterExpressionEvaluator.java =================================================================== RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/plugin/PluginParameterExpressionEvaluator.java,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- PluginParameterExpressionEvaluator.java 1 Apr 2005 16:14:30 -0000 1.11 +++ PluginParameterExpressionEvaluator.java 4 Apr 2005 03:48:01 -0000 1.12 @@ -55,11 +55,6 @@ { 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" ) ) { // TODO: remove this alias 1.7 +1 -3 maven-components/maven-core/src/main/java/org/apache/maven/MavenConstants.java Index: MavenConstants.java =================================================================== RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/MavenConstants.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- MavenConstants.java 25 Dec 2004 16:26:24 -0000 1.6 +++ MavenConstants.java 4 Apr 2005 03:48:01 -0000 1.7 @@ -19,7 +19,7 @@ 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"; @@ -37,7 +37,5 @@ // maven.properties // ---------------------------------------------------------------------- - public static final String MAVEN_REPO_LOCAL = "maven.repo.local"; - public static final String MAVEN_ONLINE = "maven.online"; } 1.22 +22 -15 maven-components/maven-plugins/maven-surefire-plugin/src/main/java/org/apache/maven/test/SurefirePlugin.java Index: SurefirePlugin.java =================================================================== RCS file: /home/cvs/maven-components/maven-plugins/maven-surefire-plugin/src/main/java/org/apache/maven/test/SurefirePlugin.java,v retrieving revision 1.21 retrieving revision 1.22 diff -u -r1.21 -r1.22 --- SurefirePlugin.java 22 Mar 2005 13:40:14 -0000 1.21 +++ SurefirePlugin.java 4 Apr 2005 03:48:01 -0000 1.22 @@ -16,6 +16,9 @@ * 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.PluginExecutionException; import org.codehaus.surefire.SurefireBooter; @@ -31,12 +34,6 @@ * @version $Id$ * @goal test * @description Run tests using surefire - * @parameter name="mavenRepoLocal" - * type="String" - * required="true" - * validator="validator" - * expression="#maven.repo.local" - * description="" * @parameter name="basedir" * type="String" * required="true" @@ -85,14 +82,13 @@ * validator="" * expression="#test" * 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 report to be produced configurable */ public class SurefirePlugin extends AbstractPlugin { - private String mavenRepoLocal; - private String basedir; private String classesDirectory; @@ -109,6 +105,8 @@ private List excludes; + private ArtifactRepository localRepository; + public void execute() throws PluginExecutionException { @@ -118,8 +116,7 @@ SurefireBooter surefireBooter = new SurefireBooter(); - System.out.println( "Setting reports dir: " + reportsDirectory ); - System.out.flush(); + getLog().info( "Setting reports dir: " + reportsDirectory ); surefireBooter.setReportsDirectory( reportsDirectory ); @@ -170,10 +167,20 @@ System.setProperty( "basedir", basedir ); - surefireBooter.addClassPathUrl( new File( mavenRepoLocal, "junit/jars/junit-3.8.1.jar" ).getPath() ); - - surefireBooter.addClassPathUrl( - new File( mavenRepoLocal, "surefire/jars/surefire-1.2-SNAPSHOT.jar" ).getPath() ); + // TODO: we should really just trust the plugin classloader? + try + { + 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() );