jvanzyl 2004/02/14 09:07:42
Modified: maven-plugins/maven-compiler-plugin/src/java/org/apache/maven/plugin
CompilerPlugin.java
maven-plugins/maven-jar-plugin/src/java/org/apache/maven/plugin
JarPlugin.java
maven-plugins/maven-surefire-plugin/src/main/org/apache/maven/test
SurefirePlugin.java
Log:
o first pass at the removing of maven as a dependency on the plugins. i would
like them to be simple POJOs and for the most part this has been done with
a little bit of OGNL magic to extract the parameters required for plugin
execution from the maven project. almost there.
Revision Changes Path
1.4 +17 -24
maven-components/maven-plugins/maven-compiler-plugin/src/java/org/apache/maven/plugin/CompilerPlugin.java
Index: CompilerPlugin.java
===================================================================
RCS file:
/home/cvs/maven-components/maven-plugins/maven-compiler-plugin/src/java/org/apache/maven/plugin/CompilerPlugin.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- CompilerPlugin.java 13 Feb 2004 00:03:46 -0000 1.3
+++ CompilerPlugin.java 14 Feb 2004 17:07:42 -0000 1.4
@@ -8,7 +8,9 @@
import java.util.Map;
/**
- *
+ * @property sourceDirectory
+ * @property outputDirectory
+ * @property compiler
*
* @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
*
@@ -19,32 +21,23 @@
{
private Map compilers;
- public void execute( MavenProject project, Map parameters )
+ public void execute( Map parameters )
throws Exception
{
- // sourceDirectory
- // targetDirectory
- // compiler: jikes|eclipse|aspectj|javac
- // options specific to the compiler
-
- String destinationDirectory = project.getBasedir() + "/target/classes";
-
- Compiler compiler = (Compiler) compilers.get( "jikes" );
-
- List messages = compiler.compile( classpathElements( project ),
- new
String[]{project.getBuild().getSourceDirectory()},
- destinationDirectory );
- }
+ //---
- private String[] classpathElements( MavenProject project )
- {
- String[] classpathElements = new String[project.getArtifacts().size()];
+ String sourceDirectory = (String) parameters.get( "sourceDirectory" );
+
+ String outputDirectory = (String) parameters.get( "outputDirectory" );
+
+ String[] classpathElements = (String[]) parameters.get( "classpathElements"
);
+
+ String compilerName = (String) parameters.get( "compiler" );
+
+ //---
- for ( int i = 0; i < classpathElements.length; i++ )
- {
- classpathElements[i] = ( (MavenArtifact) project.getArtifacts().get( i
) ).getPath();
- }
+ Compiler compiler = (Compiler) compilers.get( compilerName );
- return classpathElements;
+ List messages = compiler.compile( classpathElements, new String[]{
sourceDirectory }, outputDirectory );
}
}
1.3 +16 -13
maven-components/maven-plugins/maven-jar-plugin/src/java/org/apache/maven/plugin/JarPlugin.java
Index: JarPlugin.java
===================================================================
RCS file:
/home/cvs/maven-components/maven-plugins/maven-jar-plugin/src/java/org/apache/maven/plugin/JarPlugin.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- JarPlugin.java 13 Feb 2004 00:03:46 -0000 1.2
+++ JarPlugin.java 14 Feb 2004 17:07:42 -0000 1.3
@@ -56,26 +56,21 @@
* ====================================================================
*/
-import org.apache.maven.project.MavenProject;
import org.apache.maven.model.Resource;
-import org.apache.maven.plugin.AbstractPlugin;
+import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.util.FileUtils;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
-
+import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
-import java.util.ArrayList;
import java.util.Map;
+import java.util.jar.JarEntry;
import java.util.jar.JarOutputStream;
import java.util.jar.Manifest;
-import java.util.jar.JarEntry;
-import java.util.zip.Deflater;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipOutputStream;
/**
*
@@ -92,14 +87,22 @@
public class JarPlugin
extends AbstractPlugin
{
- public void execute( MavenProject project, Map parameters )
+ public void execute( Map parameters )
throws Exception
{
- String jarName = project.getProperty( "maven.final.name" ) + ".jar";
+ //---
+
+ String jarName = (String) parameters.get( "jarName" ) + ".jar";
+
+ String outputDirectory = (String) parameters.get( "outputDirectory" );
+
+ File basedir = new File( (String) parameters.get( "basedir" ) );
+
+ MavenProject project = (MavenProject) parameters.get( "project" );
- File jarFile = new File( new File( project.getBasedir(), "target" ),
jarName );
+ //---
- File basedir = new File( project.getBasedir(), "target/classes" );
+ File jarFile = new File( new File( outputDirectory ), jarName );
List files = FileUtils.getFileNames( basedir, "**/**", "**/package.html",
false );
1.4 +15 -14
maven-components/maven-plugins/maven-surefire-plugin/src/main/org/apache/maven/test/SurefirePlugin.java
Index: SurefirePlugin.java
===================================================================
RCS file:
/home/cvs/maven-components/maven-plugins/maven-surefire-plugin/src/main/org/apache/maven/test/SurefirePlugin.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- SurefirePlugin.java 13 Feb 2004 00:03:47 -0000 1.3
+++ SurefirePlugin.java 14 Feb 2004 17:07:42 -0000 1.4
@@ -1,12 +1,9 @@
package org.apache.maven.test;
import org.apache.maven.plugin.AbstractPlugin;
-import org.apache.maven.artifact.MavenArtifact;
-import org.apache.maven.project.MavenProject;
import org.codehaus.surefire.SurefireBooter;
import java.io.File;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -20,18 +17,24 @@
public class SurefirePlugin
extends AbstractPlugin
{
- public void execute( MavenProject project, Map parameters )
+ public void execute( Map parameters )
throws Exception
{
- String mavenRepoLocal = project.getProperty( "maven.repo.local" );
+ //---
- String basedir = project.getFile().getParentFile().getPath();
+ String mavenRepoLocal = (String) parameters.get( "mavenRepoLocal" );
- System.setProperty( "basedir", basedir );
+ String basedir = (String) parameters.get( "basedir" );
+
+ List includes = (List) parameters.get( "includes" );
+
+ List excludes = (List) parameters.get( "excludes" );
- List includes = project.getBuild().getUnitTest().getIncludes();
+ String[] classpathElements = (String[]) parameters.get( "classpathElements"
);
- List excludes = project.getBuild().getUnitTest().getExcludes();
+ //---
+
+ System.setProperty( "basedir", basedir );
SurefireBooter surefireBooter = new SurefireBooter();
@@ -45,11 +48,9 @@
surefireBooter.addClassPathUrl( new File( basedir, "target/test-classes"
).getPath() );
- for ( Iterator i = project.getArtifacts().iterator(); i.hasNext(); )
+ for ( int i = 0; i < classpathElements.length; i++ )
{
- MavenArtifact artifact = (MavenArtifact) i.next();
-
- surefireBooter.addClassPathUrl( artifact.getFile().getPath() );
+ surefireBooter.addClassPathUrl( classpathElements[i] );
}
surefireBooter.addReport( "org.codehaus.surefire.report.ConsoleReport" );
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]