jvanzyl     2004/02/16 09:27:12

  Modified:    maven-plugins/maven-jar-plugin/src/java/org/apache/maven/plugin
                        JarPlugin.java
               maven-plugins/maven-jar-plugin/src/resources/META-INF/maven
                        plugin.xml
  Log:
  o move resource handling to a separate plugin to keep concerns separated as
    the resources copying is required for testing and the project proper.
  
  Revision  Changes    Path
  1.8       +3 -103    
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.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- JarPlugin.java    15 Feb 2004 21:42:50 -0000      1.7
  +++ JarPlugin.java    16 Feb 2004 17:27:12 -0000      1.8
  @@ -56,18 +56,13 @@
    * ====================================================================
    */
   
  -import org.apache.maven.model.Resource;
  -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.Map;
   import java.util.jar.JarEntry;
   import java.util.jar.JarOutputStream;
   import java.util.jar.Manifest;
  @@ -96,8 +91,6 @@
   
       private String basedir;
   
  -    private MavenProject project;
  -
       public void execute()
           throws Exception
       {
  @@ -107,12 +100,10 @@
   
           List files = FileUtils.getFileNames( basedir, "**/**", "**/package.html", 
false );
   
  -        List resources = getJarResources( project );
  -
  -        createJar( files, resources, jarFile, basedir );
  +        createJar( files, jarFile, basedir );
       }
   
  -    public void createJar( List files, List resources, File jarName, File basedir )
  +    public void createJar( List files, File jarName, File basedir )
           throws Exception
       {
           JarOutputStream jar = new JarOutputStream( new FileOutputStream( jarName ), 
createManifest() );
  @@ -125,13 +116,6 @@
   
                   writeJarEntry( jar, new File( basedir, file ), file );
               }
  -
  -            for ( int i = 0; i < resources.size(); i++ )
  -            {
  -                JarResourceEntry jarResourceEntry = (JarResourceEntry) 
resources.get( i );
  -
  -                writeJarEntry( jar, jarResourceEntry.getSource(), 
jarResourceEntry.getEntry() );
  -            }
           }
           finally
           {
  @@ -174,94 +158,10 @@
           }
       }
   
  -    private List getJarResources( MavenProject project )
  -        throws Exception
  -    {
  -        List resources = new ArrayList();
  -
  -        for ( Iterator i = project.getBuild().getResources().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;
  -                }
  -
  -                JarResourceEntry je = new JarResourceEntry( new File( 
resource.getDirectory(), name ), entryName );
  -
  -                resources.add( je );
  -            }
  -        }
  -
  -        return resources;
  -    }
  -
  -    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();
  -    }
  -
       private Manifest createManifest()
       {
           Manifest manifest = new Manifest();
   
           return manifest;
  -    }
  -
  -    public class JarResourceEntry
  -    {
  -        private File source;
  -
  -        private String entry;
  -
  -        public JarResourceEntry( File source, String entry )
  -        {
  -            this.source = source;
  -
  -            this.entry = entry;
  -        }
  -
  -        public File getSource()
  -        {
  -            return source;
  -        }
  -
  -        public String getEntry()
  -        {
  -            return entry;
  -        }
       }
   }
  
  
  
  1.3       +1 -1      
maven-components/maven-plugins/maven-jar-plugin/src/resources/META-INF/maven/plugin.xml
  
  Index: plugin.xml
  ===================================================================
  RCS file: 
/home/cvs/maven-components/maven-plugins/maven-jar-plugin/src/resources/META-INF/maven/plugin.xml,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- plugin.xml        15 Feb 2004 21:42:50 -0000      1.2
  +++ plugin.xml        16 Feb 2004 17:27:12 -0000      1.3
  @@ -5,12 +5,12 @@
         <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>
  -        <project>project</project>
         </configuration>
       </goal>
     </goals>
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to