You are viewing a plain text version of this content. The canonical link for it is here.
Posted to m2-dev@maven.apache.org by Jerome Lacoste <je...@coffeebreaks.org> on 2004/06/17 18:39:02 UTC
Re: cvs commit:
maven-components/maven-plugins/maven-surefire-plugin/src/main/java/org/apache/maven/test
SurefirePlugin.java
On Fri, 2004-06-11 at 18:14, jvanzyl@apache.org wrote:
> jvanzyl 2004/06/11 09:14:40
>
> Modified: maven-plugins/maven-clean-plugin/src/main/java/org/apache/maven/plugin
> CleanPlugin.java
> maven-plugins/maven-jar-plugin/src/main/java/org/apache/maven/plugin/jar
> JarInstallMojo.java JarMojo.java
> maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin
> DescriptorGenerator.java
> maven-plugins/maven-surefire-plugin/src/main/java/org/apache/maven/test
> SurefirePlugin.java
> Added: maven-plugins/maven-resources-plugin/src/main/java/org/apache/maven/plugin
> ResourcesMojo.java TestResourcesMojo.java
> Removed: maven-plugins/maven-compiler-plugin/src/main/java/org/apache/maven/plugin
> CompilerPlugin.java
> maven-plugins/maven-resources-plugin/src/main/java/org/apache/maven/plugin
> ResourcesPlugin.java
> Log:
> o cleaning up the @tags which are now a lot more simple
>
> Revision Changes Path
> 1.5 +9 -6 maven-components/maven-plugins/maven-clean-plugin/src/main/java/org/apache/maven/plugin/CleanPlugin.java
>
> Index: CleanPlugin.java
> ===================================================================
> RCS file: /home/cvs/maven-components/maven-plugins/maven-clean-plugin/src/main/java/org/apache/maven/plugin/CleanPlugin.java,v
> retrieving revision 1.4
> retrieving revision 1.5
> diff -u -r1.4 -r1.5
> --- CleanPlugin.java 9 Jun 2004 03:10:50 -0000 1.4
> +++ CleanPlugin.java 11 Jun 2004 16:14:40 -0000 1.5
> @@ -19,16 +19,19 @@
> import java.io.File;
>
> /**
> - * @author <a href="mailto:evenisse@maven.org">Emmanuel Venisse</a>
> - * @version $Id$
> * @maven.plugin.id clean
> * @maven.plugin.description A maven2 plugin which cleans the build
> + *
> * @parameter failedOnError String true validator description
> * @parameter outputDirectory String true validator description
> - * @goal.name clean
> - * @goal.clean.description Goal which cleans the build
> - * @goal.clean.parameter failedOnError false
> - * @goal.clean.parameter outputDirectory #maven.build.dir
> + *
> + * @goal clean
> + * @goal.description Goal which cleans the build
> + * @goal.parameter failedOnError false
> + * @goal.parameter outputDirectory #project.build.directory
> + *
> + * @author <a href="mailto:evenisse@maven.org">Emmanuel Venisse</a>
> + * @version $Id$
> */
> public class CleanPlugin
> extends AbstractPlugin
>
>
>
> 1.2 +12 -12 maven-components/maven-plugins/maven-jar-plugin/src/main/java/org/apache/maven/plugin/jar/JarInstallMojo.java
>
> Index: JarInstallMojo.java
> ===================================================================
> RCS file: /home/cvs/maven-components/maven-plugins/maven-jar-plugin/src/main/java/org/apache/maven/plugin/jar/JarInstallMojo.java,v
> retrieving revision 1.1
> retrieving revision 1.2
> diff -u -r1.1 -r1.2
> --- JarInstallMojo.java 10 Jun 2004 18:58:38 -0000 1.1
> +++ JarInstallMojo.java 11 Jun 2004 16:14:40 -0000 1.2
> @@ -39,18 +39,18 @@
> * @parameter localRepository String true validator description
> * @parameter pomFile java.io.File true validator description
> * *
> - * @goal.name jar:install
> - * @goal.jar:install.description install a jar in local repository
> + * @goal jar:install
> + * @goal.description install a jar in local repository
> *
> - * @goal.jar:install.prereq jar
> - * @goal.jar:install.parameter jarName #maven.final.name
> - * @goal.jar:install.parameter outputDirectory #maven.build.dir
> - * @goal.jar:install.parameter basedir #maven.build.dest
> - * @goal.jar:install.parameter pomFile #project.file
> - * @goal.jar:install.parameter groupId #project.groupId
> - * @goal.jar:install.parameter artifactId #project.artifactId
> - * @goal.jar:install.parameter version #project.version
> - * @goal.jar:install.parameter localRepository #project.localRepository
> + * @goal.prereq jar
> + * @goal.parameter jarName #maven.final.name
> + * @goal.parameter outputDirectory #project.build.directory
> + * @goal.parameter basedir #project.build.directory/classes
> + * @goal.parameter pomFile #project.file
> + * @goal.parameter groupId #project.groupId
> + * @goal.parameter artifactId #project.artifactId
> + * @goal.parameter version #project.version
> + * @goal.parameter localRepository #project.localRepository
> */
> public class JarInstallMojo
> extends AbstractPlugin
>
>
>
> 1.3 +8 -8 maven-components/maven-plugins/maven-jar-plugin/src/main/java/org/apache/maven/plugin/jar/JarMojo.java
>
> Index: JarMojo.java
> ===================================================================
> RCS file: /home/cvs/maven-components/maven-plugins/maven-jar-plugin/src/main/java/org/apache/maven/plugin/jar/JarMojo.java,v
> retrieving revision 1.2
> retrieving revision 1.3
> diff -u -r1.2 -r1.3
> --- JarMojo.java 10 Jun 2004 20:27:50 -0000 1.2
> +++ JarMojo.java 11 Jun 2004 16:14:40 -0000 1.3
> @@ -38,13 +38,13 @@
> * @parameter outputDirectory String true validator description
> * @parameter basedir String true validator description
> *
> - * @goal.name jar
> - * @goal.jar.description build a jar
> - * @goal.jar.prereq test
> - * @goal.jar.prereq resources
> - * @goal.jar.parameter jarName #maven.final.name
> - * @goal.jar.parameter outputDirectory #maven.build.dir
> - * @goal.jar.parameter basedir #maven.build.dest
> + * @goal jar
> + * @goal.description build a jar
> + * @goal.prereq test
> + * @goal.prereq resources
> + * @goal.parameter jarName #maven.final.name
> + * @goal.parameter outputDirectory #project.build.directory
> + * @goal.parameter basedir #project.build.directory/classes
> *
> * @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
> * @version $Id$
>
>
>
> 1.2 +6 -6 maven-components/maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/DescriptorGenerator.java
>
> Index: DescriptorGenerator.java
> ===================================================================
> RCS file: /home/cvs/maven-components/maven-plugins/maven-plugin-plugin/src/main/java/org/apache/maven/plugin/plugin/DescriptorGenerator.java,v
> retrieving revision 1.1
> retrieving revision 1.2
> diff -u -r1.1 -r1.2
> --- DescriptorGenerator.java 29 May 2004 03:21:29 -0000 1.1
> +++ DescriptorGenerator.java 11 Jun 2004 16:14:40 -0000 1.2
> @@ -10,11 +10,11 @@
> * @parameter outputDirectory String true validator description
> * @parameter pom String true validator description
> *
> - * @goal.name descriptor
> - * @goal.descriptor.description Goal for generating a plugin descriptor.
> - * @goal.descriptor.parameter sourceDirectory #project.build.sourceDirectory
> - * @goal.descriptor.parameter outputDirectory #maven.build.dest/META-INF/maven
> - * @goal.descriptor.parameter pom #project.getFile().getPath()
> + * @goal descriptor
> + * @goal.description Goal for generating a plugin descriptor.
> + * @goal.parameter sourceDirectory #project.build.sourceDirectory
> + * @goal.parameter outputDirectory #project.build.directory/classes/META-INF/maven
> + * @goal.parameter pom #project.getFile().getPath()
>
> * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
> * @version $Id$
>
>
>
> 1.1 maven-components/maven-plugins/maven-resources-plugin/src/main/java/org/apache/maven/plugin/ResourcesMojo.java
>
> Index: ResourcesMojo.java
> ===================================================================
> 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;
>
> /**
> * @maven.plugin.id resources
> * @maven.plugin.description Maven plugin to build jars
> *
> * @parameter outputDirectory String true validator description
> * @parameter resources List true validator description
> *
> * @goal resources
> * @goal.description copy application resources
> * @goal.parameter outputDirectory #project.build.directory/classes
> * @goal.parameter resources #project.build.resources
> *
> * @author <a href="michal.maczka@dimatics.com">Michal Maczka</a>
> * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
> *
> * @version $Id: ResourcesMojo.java,v 1.1 2004/06/11 16:14:40 jvanzyl Exp $
> *
> */
> public class ResourcesMojo
> extends AbstractPlugin
> {
> public void execute( PluginExecutionRequest request, PluginExecutionResponse response )
> throws Exception
> {
> // ----------------------------------------------------------------------
> //
> // ----------------------------------------------------------------------
>
> String outputDirectory = (String) request.getParameter( "outputDirectory" );
>
> List resources = (List) request.getParameter( "resources" );
>
> // ----------------------------------------------------------------------
> //
> // ----------------------------------------------------------------------
>
> 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;
> }
>
> // If we only have a directory then we want to include
> // everything we can find within that path.
>
> String includes;
>
> if ( resource.getIncludes().size() > 0 )
> {
> includes = listToString( resource.getIncludes() );
> }
> else
> {
> includes = "**/**";
> }
>
> List files = FileUtils.getFileNames( resourceDirectory,
> includes,
> 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;
> }
for consistency with the code above, you might want to use
String entryName;
if ( targetPath != null )
{
entryName = targetPath + "/" + name;
}
else
{
entryName = 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( "," );
> }
> }
and here you might want to move the sb.append( "," ); before the append
of the list element, providing that you test for i != 0 (which might be
better than testing for equality with list.size() -1.
>
> 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();
finally ?
And why 512? Why not more?
> return buf.toString();
> }
>
> public static void fileWrite( String fileName, String data ) throws Exception
> {
> FileOutputStream out = new FileOutputStream( fileName );
> out.write( data.getBytes() );
> out.close();
finally
> }
>
> public static void fileCopy( String inFileName, String outFileName ) throws
> Exception
> {
> String content = fileRead( inFileName );
> fileWrite( outFileName, content );
> }
>
> class ResourceEntry
static class ?
> {
> 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;
> }
> }
> }
Re: cvs commit: maven-components/maven-plugins/maven-surefire-plugin/src/main/java/org/apache/maven/test SurefirePlugin.java
Posted by Brett Porter <br...@apache.org>.
Jerome,
If you are going to do this, please trim the quoted text.
- Brett
Quoting Jerome Lacoste <je...@coffeebreaks.org>:
> On Fri, 2004-06-11 at 18:14, jvanzyl@apache.org wrote:
> > jvanzyl 2004/06/11 09:14:40
> >
> > Modified: