org.codehaus.mojo.runtime.util
Class JarMaker

java.lang.Object
  extended by org.codehaus.mojo.runtime.util.JarMaker

public class JarMaker
extends Object

adapted from the JarMojo from maven-jar-plugin

Version:
$Id: JarMaker.java 2166 2006-07-18 21:32:16Z carlos $
Author:
jesse

Constructor Summary
JarMaker(File directory, String name)
           
JarMaker(String fullFileName)
           
 
Method Summary
protected  void addDirectory(File baseDir)
          Add all files in the specified directory to the archive.
 void addDirectory(String prefix, File baseDir)
          Add all files in the specified directory to the archive.
 void addDirectory(String includesPattern, String excludesPattern, String prefix, File baseDir)
          Add all files in the specified directory to the archive.
protected  void addEntries(JarOutputStream jos, Map includes)
          Add all entries in the supplied Map to the jar
protected  void addEntry(JarOutputStream jos, String name, File source)
          Add a single entry to the jar
 void addManifestEntries(Map entries)
           
 void addManifestEntry(String key, String value)
           
 void create()
          Create the jar file specified and include the listed files.
protected  JarOutputStream createJar(File jarFile, Manifest mf)
          Create the specified jar file and return a JarOutputStream to it
protected  Manifest createManifest()
          Create a manifest for the jar file
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JarMaker

public JarMaker(String fullFileName)

JarMaker

public JarMaker(File directory,
                String name)
Method Detail

addManifestEntries

public void addManifestEntries(Map entries)

addManifestEntry

public void addManifestEntry(String key,
                             String value)

addDirectory

protected void addDirectory(File baseDir)
                     throws IOException
Add all files in the specified directory to the archive.

Parameters:
baseDir - the directory to add
Throws:
IOException

addDirectory

public void addDirectory(String prefix,
                         File baseDir)
                  throws IOException
Add all files in the specified directory to the archive.

Parameters:
prefix - value to be added to the front of jar entry names
baseDir - the directory to add
Throws:
IOException

addDirectory

public void addDirectory(String includesPattern,
                         String excludesPattern,
                         String prefix,
                         File baseDir)
                  throws IOException
Add all files in the specified directory to the archive.

Parameters:
includesPattern - Sets the list of include patterns to use
excludesPattern - Sets the list of exclude patterns to use
prefix - value to be added to the front of jar entry names
baseDir - the directory to add
Throws:
IOException

create

public void create()
            throws IOException
Create the jar file specified and include the listed files.

Throws:
IOException - if there is a problem writing the archive or reading the sources

createJar

protected JarOutputStream createJar(File jarFile,
                                    Manifest mf)
                             throws IOException
Create the specified jar file and return a JarOutputStream to it

Parameters:
jarFile - the jar file to create
mf - the manifest to use
Returns:
a JarOutputStream that can be used to write to that file
Throws:
IOException - if there was a problem opening the file

createManifest

protected Manifest createManifest()
Create a manifest for the jar file

Returns:
a default manifest; the Manifest-Version and Created-By attributes are initialized

addEntries

protected void addEntries(JarOutputStream jos,
                          Map includes)
                   throws IOException
Add all entries in the supplied Map to the jar

Parameters:
jos - a JarOutputStream that can be used to write to the jar
includes - a Map of entries to add
Throws:
IOException - if there is a problem writing the archive or reading the sources

addEntry

protected void addEntry(JarOutputStream jos,
                        String name,
                        File source)
                 throws IOException
Add a single entry to the jar

Parameters:
jos - a JarOutputStream that can be used to write to the jar
name - the entry name to use; must be '/' delimited
source - the file to add
Throws:
IOException - if there is a problem writing the archive or reading the sources


Copyright © 2011 Codehaus. All Rights Reserved.