Initial revision

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@162606 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jason van Zyl 2004-03-15 19:32:20 +00:00
parent 8889ee6f4b
commit ee951b1609
16 changed files with 1094 additions and 0 deletions

View File

@ -0,0 +1,5 @@
*~
*.log
target
*.ipr
*.iws

View File

@ -0,0 +1,72 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<project>
<pomVersion>3</pomVersion>
<id>maven-compiler-plugin</id>
<groupId>maven-compiler-plugin</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<name>Maven</name>
<currentVersion>1.0-SNAPSHOT</currentVersion>
<organization>
<name>Apache Software Foundation</name>
<url>http://www.apache.org/</url>
<logo>/images/apache-maven-project.png</logo>
</organization>
<inceptionYear>2001</inceptionYear>
<package>org.apache.maven</package>
<logo>/images/maven.gif</logo>
<repository>
<connection>scm:cvs:pserver:anoncvs@cvs.apache.org:/home/cvspublic:maven-components/maven-plugins/maven-compiler-plugin</connection>
<developerConnection>scm:cvs:ext:${maven.username}@cvs.apache.org:/home/cvs:maven-components/maven-plugins/maven-compiler-plugin</developerConnection>
<url>http://cvs.apache.org/viewcvs.cgi/maven/</url>
</repository>
<dependencies>
<dependency>
<groupId>xpp3</groupId>
<artifactId>xpp3</artifactId>
<version>1.1.3.3</version>
</dependency>
<dependency>
<groupId>plexus</groupId>
<artifactId>plexus</artifactId>
<version>0.14-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>plexus</groupId>
<artifactId>plexus-i18n</artifactId>
<version>1.0-beta-2-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>classworlds</groupId>
<artifactId>classworlds</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>xstream</groupId>
<artifactId>xstream</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>plexus</groupId>
<artifactId>plexus-compiler</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>src/main/java</sourceDirectory>
<unitTestSourceDirectory>src/test/java</unitTestSourceDirectory>
<unitTest>
<includes>
<include>**/*Test.java</include>
</includes>
</unitTest>
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
</build>
</project>

View File

@ -0,0 +1,88 @@
package org.apache.maven.plugin;
import org.codehaus.plexus.compiler.Compiler;
import org.codehaus.plexus.compiler.CompilerError;
import java.util.List;
import java.util.Map;
import java.util.Iterator;
import java.io.File;
/**
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
*
* @version $Id$
*/
// Conditions underwhich we fail
// - specified source directory does not exist
// - missing classpath Elements
// - compilation error
// How to accurately report failures to users
public class CompilerPlugin
{
private Map compilers;
private String sourceDirectory;
private String outputDirectory;
private String[] classpathElements;
private String compiler;
private boolean debug = true;
public void execute()
throws Exception
{
if ( ! new File( sourceDirectory ).exists() )
{
throw new Exception( "The specified source directory '"+ sourceDirectory + "' does not exist!" );
}
Compiler compiler = (Compiler) compilers.get( this.compiler );
List messages = compiler.compile( classpathElements, new String[]{sourceDirectory}, outputDirectory );
if ( debug )
{
for ( int i = 0; i < classpathElements.length; i++ )
{
String message;
if ( new File( classpathElements[i] ).exists() )
{
message = "present in repository.";
}
else
{
message = "Warning! not present in repository!";
}
System.out.println( "classpathElements[ "+ i +" ] = " + classpathElements[i] + ": " + message );
}
}
boolean compilationError = false;
for ( Iterator i = messages.iterator(); i.hasNext(); )
{
CompilerError message = (CompilerError) i.next();
if ( message.isError() )
{
compilationError = true;
}
System.out.println( message.getMessage() );
}
if ( compilationError )
{
throw new Exception( "Compilation failure!" );
}
}
}

View File

@ -0,0 +1,33 @@
<plugin>
<id>compiler</id>
<implementation>org.apache.maven.plugin.CompilerPlugin</implementation>
<requirements>
<requirement>
<role>org.codehaus.plexus.compiler.Compiler</role>
<field-name>compilers</field-name>
</requirement>
</requirements>
<goals>
<goal>
<name>compile</name>
<configuration>
<sourceDirectory>#project.build.sourceDirectory</sourceDirectory>
<outputDirectory>#maven.build.dest</outputDirectory>
<classpathElements>#project.classpathElements</classpathElements>
<compiler>javac</compiler>
</configuration>
</goal>
<goal>
<name>test:compile</name>
<prereqs>
<prereq>compile</prereq>
</prereqs>
<configuration>
<sourceDirectory>#project.build.unitTestSourceDirectory</sourceDirectory>
<outputDirectory>#maven.test.dest</outputDirectory>
<classpathElements>#project.classpathElements</classpathElements>
<compiler>javac</compiler>
</configuration>
</goal>
</goals>
</plugin>

View File

@ -0,0 +1,5 @@
*~
*.log
target
*.ipr
*.iws

View File

@ -0,0 +1,93 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<project>
<pomVersion>3</pomVersion>
<id>maven-jar-plugin</id>
<groupId>maven</groupId>
<artifactId>maven-jar-plugin</artifactId>
<name>Maven</name>
<currentVersion>1.0-SNAPSHOT</currentVersion>
<organization>
<name>Apache Software Foundation</name>
<url>http://www.apache.org/</url>
<logo>/images/apache-maven-project.png</logo>
</organization>
<inceptionYear>2001</inceptionYear>
<package>org.apache.maven</package>
<logo>/images/maven.gif</logo>
<repository>
<connection>scm:cvs:pserver:anoncvs@cvs.apache.org:/home/cvspublic:maven-components/maven-plugins/maven-jar-plugin</connection>
<developerConnection>scm:cvs:ext:${maven.username}@cvs.apache.org:/home/cvs:maven-components/maven-plugins/maven-jar-plugin</developerConnection>
<url>http://cvs.apache.org/viewcvs.cgi/maven/</url>
</repository>
<dependencies>
<dependency>
<groupId>maven</groupId>
<artifactId>maven-core</artifactId>
<version>2.0-SNAPSHOT</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>xpp3</groupId>
<artifactId>xpp3</artifactId>
<version>1.1.3.3</version>
</dependency>
<dependency>
<groupId>plexus</groupId>
<artifactId>plexus</artifactId>
<version>0.14-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>classworlds</groupId>
<artifactId>classworlds</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>xstream</groupId>
<artifactId>xstream</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>plexus</groupId>
<artifactId>plexus-compiler</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>src/main/java</sourceDirectory>
<unitTestSourceDirectory>src/test/java</unitTestSourceDirectory>
<unitTest>
<includes>
<include>**/*Test.java</include>
</includes>
</unitTest>
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
</build>
<reports>
<report>maven-faq-plugin</report> will run by itself but won't register
<report>maven-file-activity-plugin</report> can't parse jelly script
<report>maven-developer-activity-plugin</report>
<report>maven-tasklist-plugin</report> not quite right the report comes out empty @tag problem?
<report>maven-jdepend-plugin</report> works itself but not with site, also it uses maven-classpath which is really just maven_home/lib
<report>maven-jellydoc-plugin</report> ${genDocs} not available in jelly.plugin
<report>maven-pmd-plugin</report> classpath is borked because of getDependencyPath("foo:foo")
</reports>
</project>

View File

@ -0,0 +1,163 @@
package org.apache.maven.plugin;
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Maven" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Maven", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* ====================================================================
*/
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.List;
import java.util.jar.JarEntry;
import java.util.jar.JarOutputStream;
import java.util.jar.Manifest;
/**
*
* @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
* @version $Id$
*
* maven.jar.manifest.extensions.add
* maven.jar.includes
* maven.jar.excludes
* maven.jar.index
* maven.jar.compress
* maven.remote.group
*/
public class JarPlugin
{
private String jarName;
private String outputDirectory;
private String basedir;
public void execute()
throws Exception
{
File basedir = new File( this.basedir );
File jarFile = new File( new File( outputDirectory ), jarName + ".jar" );
List files = FileUtils.getFileNames( basedir, "**/**", "**/package.html", false );
createJar( files, jarFile, basedir );
}
public void createJar( List files, File jarName, File basedir )
throws Exception
{
JarOutputStream jar = new JarOutputStream( new FileOutputStream( jarName ), createManifest() );
try
{
for ( int i = 0; i < files.size(); i++ )
{
String file = (String) files.get( i );
writeJarEntry( jar, new File( basedir, file ), file );
}
}
finally
{
jar.close();
}
}
private void writeJarEntry( JarOutputStream jar, File source, String entryName )
throws Exception
{
byte[] buffer = new byte[1024];
int bytesRead;
try
{
FileInputStream is = new FileInputStream( source );
try
{
JarEntry entry = new JarEntry( entryName );
jar.putNextEntry( entry );
while ( ( bytesRead = is.read( buffer ) ) != -1 )
{
jar.write( buffer, 0, bytesRead );
}
}
catch ( Exception ex )
{
}
finally
{
is.close();
}
}
catch ( IOException ex )
{
}
}
private Manifest createManifest()
{
Manifest manifest = new Manifest();
return manifest;
}
}

View File

@ -0,0 +1,18 @@
<plugin>
<id>jar</id>
<implementation>org.apache.maven.plugin.JarPlugin</implementation>
<goals>
<goal>
<name>jar</name>
<prereqs>
<prereq>test</prereq>
<prereq>resources</prereq>
</prereqs>
<configuration>
<jarName>#maven.final.name</jarName>
<outputDirectory>#maven.build.dir</outputDirectory>
<basedir>#maven.build.dest</basedir>
</configuration>
</goal>
</goals>
</plugin>

View File

@ -0,0 +1,5 @@
*~
*.log
target
*.ipr
*.iws

View File

@ -0,0 +1,131 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<project>
<pomVersion>3</pomVersion>
<id>maven-resources-plugin</id>
<groupId>maven</groupId>
<artifactId>maven-resources-plugin</artifactId>
<name>Maven</name>
<currentVersion>1.0-SNAPSHOT</currentVersion>
<organization>
<name>Apache Software Foundation</name>
<url>http://www.apache.org/</url>
<logo>/images/apache-maven-project.png</logo>
</organization>
<inceptionYear>2001</inceptionYear>
<package>org.apache.maven</package>
<logo>/images/maven.gif</logo>
<versions/>
<branches/>
<mailingLists/>
<developers/>
<contributors/>
<licenses/>
<repository>
<connection>scm:cvs:pserver:anoncvs@cvs.apache.org:/home/cvspublic:maven-components/maven-plugins/maven-resources-plugin</connection>
<developerConnection>scm:cvs:ext:${maven.username}@cvs.apache.org:/home/cvs:maven-components/maven-plugins/maven-resources-plugin</developerConnection>
<url>http://cvs.apache.org/viewcvs.cgi/maven/</url>
</repository>
<!-- Need to mark these as compile-time/run-time -->
<dependencies>
<dependency>
<groupId>maven</groupId>
<artifactId>maven-core</artifactId>
<version>2.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>maven</groupId>
<artifactId>maven-model</artifactId>
<version>2.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>maven</groupId>
<artifactId>maven-model-xpp3</artifactId>
<version>2.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>maven</groupId>
<artifactId>maven-project</artifactId>
<version>2.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
<version>1.0-beta-2</version>
</dependency>
<!-- Plexus -->
<dependency>
<groupId>xpp3</groupId>
<artifactId>xpp3</artifactId>
<version>1.1.3.3</version>
</dependency>
<dependency>
<groupId>plexus</groupId>
<artifactId>plexus</artifactId>
<version>0.14-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>plexus</groupId>
<artifactId>plexus-i18n</artifactId>
<version>1.0-beta-2-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>classworlds</groupId>
<artifactId>classworlds</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>xstream</groupId>
<artifactId>xstream</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>plexus</groupId>
<artifactId>plexus-compiler</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>src/main/java</sourceDirectory>
<unitTestSourceDirectory>src/test/java</unitTestSourceDirectory>
<unitTest>
<includes>
<include>**/*Test.java</include>
</includes>
</unitTest>
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
</build>
<reports>
<report>maven-faq-plugin</report> will run by itself but won't register
<report>maven-file-activity-plugin</report> can't parse jelly script
<report>maven-developer-activity-plugin</report>
<report>maven-tasklist-plugin</report> not quite right the report comes out empty @tag problem?
<report>maven-jdepend-plugin</report> works itself but not with site, also it uses maven-classpath which is really just maven_home/lib
<report>maven-jellydoc-plugin</report> ${genDocs} not available in jelly.plugin
<report>maven-pmd-plugin</report> classpath is borked because of getDependencyPath("foo:foo")
</reports>
</project>

View File

@ -0,0 +1,226 @@
package org.apache.maven.plugin;
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Maven" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Maven", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* ====================================================================
*/
import org.apache.maven.model.Resource;
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;
/**
*
* @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
* @version $Id$
*
* maven.jar.manifest.extensions.add
* maven.jar.includes
* maven.jar.excludes
* maven.jar.index
* maven.jar.compress
* maven.remote.group
*
* @todo separate this into a resources plugin and jar plugin so that the resource
* copying can be used as part of testing, right now the resources are being copied
* directly into the JAR, need to make them available to testing.
*/
public class ResourcesPlugin
{
private String outputDirectory;
private List resources;
public void execute()
throws Exception
{
for ( Iterator i = getJarResources( resources ).iterator(); i.hasNext(); )
{
ResourceEntry resourceEntry = (ResourceEntry) i.next();
File destinationFile = new File( outputDirectory, resourceEntry.getDestination() );
if ( !destinationFile.getParentFile().exists() )
{
destinationFile.getParentFile().mkdirs();
}
fileCopy( resourceEntry.getSource(), destinationFile.getPath() );
}
}
private List getJarResources( List resources )
throws Exception
{
List resourceEntries = new ArrayList();
for ( Iterator i = resources.iterator(); i.hasNext(); )
{
Resource resource = (Resource) i.next();
String targetPath = resource.getTargetPath();
File resourceDirectory = new File( resource.getDirectory() );
if ( !resourceDirectory.exists() )
{
continue;
}
List files = FileUtils.getFileNames( resourceDirectory,
listToString( resource.getIncludes() ),
listToString( resource.getExcludes() ),
false );
for ( Iterator j = files.iterator(); j.hasNext(); )
{
String name = (String) j.next();
String entryName = name;
;
if ( targetPath != null )
{
entryName = targetPath + "/" + name;
}
ResourceEntry je = new ResourceEntry( new File( resource.getDirectory(), name ).getPath(), entryName );
resourceEntries.add( je );
}
}
return resourceEntries;
}
private String listToString( List list )
{
StringBuffer sb = new StringBuffer();
for ( int i = 0; i < list.size(); i++ )
{
sb.append( list.get( i ) );
if ( i != list.size() - 1 )
{
sb.append( "," );
}
}
return sb.toString();
}
public static String fileRead( String fileName ) throws IOException
{
StringBuffer buf = new StringBuffer();
FileInputStream in = new FileInputStream( fileName );
int count;
byte[] b = new byte[512];
while ( ( count = in.read( b ) ) > 0 ) // blocking read
{
buf.append( new String( b, 0, count ) );
}
in.close();
return buf.toString();
}
public static void fileWrite( String fileName, String data ) throws Exception
{
FileOutputStream out = new FileOutputStream( fileName );
out.write( data.getBytes() );
out.close();
}
public static void fileCopy( String inFileName, String outFileName ) throws
Exception
{
String content = fileRead( inFileName );
fileWrite( outFileName, content );
}
class ResourceEntry
{
private String source;
private String destination;
public ResourceEntry( String source, String entry )
{
this.source = source;
this.destination = entry;
}
public String getSource()
{
return source;
}
public String getDestination()
{
return destination;
}
}
}

View File

@ -0,0 +1,20 @@
<plugin>
<id>resource-copier</id>
<implementation>org.apache.maven.plugin.ResourcesPlugin</implementation>
<goals>
<goal>
<name>resources</name>
<configuration>
<outputDirectory>#maven.build.dest</outputDirectory>
<resources>#project.build.resources</resources>
</configuration>
</goal>
<goal>
<name>test:resources</name>
<configuration>
<outputDirectory>#maven.test.dest</outputDirectory>
<resources>#project.build.unitTest.resources</resources>
</configuration>
</goal>
</goals>
</plugin>

View File

@ -0,0 +1,7 @@
target
velocity.log
maven.log
.classpath
.project
*.ipr
*.iws

View File

@ -0,0 +1,99 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<project>
<pomVersion>3</pomVersion>
<id>maven-surefire-plugin</id>
<groupId>maven</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<name>Maven</name>
<currentVersion>1.0-SNAPSHOT</currentVersion>
<organization>
<name>Apache Software Foundation</name>
<url>http://www.apache.org/</url>
<logo>/images/apache-maven-project.png</logo>
</organization>
<inceptionYear>2001</inceptionYear>
<package>org.apache.maven</package>
<logo>/images/maven.gif</logo>
<versions/>
<branches/>
<mailingLists/>
<developers/>
<contributors/>
<licenses/>
<repository>
<connection>scm:cvs:pserver:anoncvs@cvs.apache.org:/home/cvspublic:maven-components/maven-plugins/maven-surefire-plugin</connection>
<developerConnection>scm:cvs:ext:${maven.username}@cvs.apache.org:/home/cvs:maven-components/maven-plugins/maven-surefire-plugin</developerConnection>
<url>http://cvs.apache.org/viewcvs.cgi/maven/</url>
</repository>
<!-- Need to mark these as compile-time/run-time -->
<dependencies>
<dependency>
<groupId>surefire</groupId>
<artifactId>surefire-booter</artifactId>
<version>1.0</version>
</dependency>
<!-- Plexus -->
<dependency>
<groupId>xpp3</groupId>
<artifactId>xpp3</artifactId>
<version>1.1.3.3</version>
</dependency>
<dependency>
<groupId>plexus</groupId>
<artifactId>plexus</artifactId>
<version>0.14-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>plexus</groupId>
<artifactId>plexus-i18n</artifactId>
<version>1.0-beta-2-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>classworlds</groupId>
<artifactId>classworlds</artifactId>
<version>1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>xstream</groupId>
<artifactId>xstream</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
<nagEmailAddress>dev@maven.apache.org</nagEmailAddress>
<sourceDirectory>src/main/java</sourceDirectory>
<unitTestSourceDirectory>src/test/java</unitTestSourceDirectory>
<unitTest>
<includes>
<include>**/*Test.java</include>
</includes>
</unitTest>
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
</build>
<reports>
<report>maven-jxr-plugin</report>
<report>maven-javadoc-plugin</report>
<report>maven-changes-plugin</report>
<report>maven-changelog-plugin</report>
</reports>
</project>

View File

@ -0,0 +1,53 @@
package org.apache.maven.test;
import org.codehaus.surefire.SurefireBooter;
import java.io.File;
import java.util.List;
/**
*
*
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
*
* @version $Id$
*/
public class SurefirePlugin
{
private String mavenRepoLocal;
private String basedir;
private List includes;
private List excludes;
private String[] classpathElements;
public void execute()
throws Exception
{
System.setProperty( "basedir", basedir );
SurefireBooter surefireBooter = new SurefireBooter();
surefireBooter.addBattery( "org.codehaus.surefire.battery.DirectoryBattery", new Object[]{basedir, includes, excludes} );
surefireBooter.addClassPathUrl( new File( mavenRepoLocal, "junit/jars/junit-3.8.1.jar" ).getPath() );
surefireBooter.addClassPathUrl( new File( mavenRepoLocal, "surefire/jars/surefire-1.0.jar" ).getPath() );
surefireBooter.addClassPathUrl( new File( basedir, "target/classes" ).getPath() );
surefireBooter.addClassPathUrl( new File( basedir, "target/test-classes" ).getPath() );
for ( int i = 0; i < classpathElements.length; i++ )
{
surefireBooter.addClassPathUrl( classpathElements[i] );
}
surefireBooter.addReport( "org.codehaus.surefire.report.ConsoleReport" );
surefireBooter.run();
}
}

View File

@ -0,0 +1,76 @@
<!--
This here is a clear example of some nastiness that has crept into Maven and here
is where it will be cleaned up. This plugin is specific to running tests with
surefire but it may well be a test runner for something else requiring a
different set of resources. The surefire plugin's concern is to run surefire
tests and to do that it must:
o compile the test sources
o copy over the test resources
o run sure fire
So currently below there are prereqs for the test:compile and test:resources
but it is entirely unclear what those things are doing without looking
at the other plugins which is not scalable. If surefire needed to add
foo.jar and bar.jar to the classpath for compiling there would be some
serious nastiness going on in order to modify the parameters of the compile.
So, the surefire plugin should use the other plugins to satisfy its requirements
and by using the plugins directly it can control their use for the specific
purpose of running surefire tests.
A goal is essentially a sequence of plugin executions that have been parameterized for
a specific task.
<plugin>
<id>compiler</id>
<configuration>
<sourceDirectory>#project.build.unitTestSourceDirectory</sourceDirectory>
<outputDirectory>#maven.test.dest</outputDirectory>
<classpathElements>#project.classpathElements</classpathElements>
<compiler>javac</compiler>
</configuration>
</plugin>
<plugin>
<id>resource-copier</id>
<configuration>
<outputDirectory>#maven.test.dest</outputDirectory>
<resources>#project.build.unitTest.resources</resources>
</configuration>
</plugin>
<plugin>
<id>surefire</id>
<configuration>
<mavenRepoLocal>#maven.repo.local</mavenRepoLocal>
<basedir>#basedir</basedir>
<includes>#project.build.unitTest.includes</includes>
<excludes>#project.build.unitTest.excludes</excludes>
<classpathElements>#project.classpathElements</classpathElements>
</configuration>
</plugin>
If say for example you used DbUnit or XMLUnit then the configurations for
each of the plugin executions would be different.
-->
<plugin>
<id>surefire</id>
<implementation>org.apache.maven.test.SurefirePlugin</implementation>
<goals>
<goal>
<name>test</name>
<prereqs>
<prereq>test:compile</prereq>
<prereq>test:resources</prereq>
</prereqs>
<configuration>
<mavenRepoLocal>#maven.repo.local</mavenRepoLocal>
<basedir>#basedir</basedir>
<includes>#project.build.unitTest.includes</includes>
<excludes>#project.build.unitTest.excludes</excludes>
<classpathElements>#project.classpathElements</classpathElements>
</configuration>
</goal>
</goals>
</plugin>