JClass DesktopViews 6.3.0 API
Documentation

com.klg.jclass.jarmaster
Class JarMasterAntTask

java.lang.Object
  |
  +--org.apache.tools.ant.ProjectComponent
        |
        +--org.apache.tools.ant.Task
              |
              +--com.klg.jclass.jarmaster.JarMasterAntTask

public class JarMasterAntTask
extends org.apache.tools.ant.Task

This class is the glue that allows us to plug JarMaster into the Ant build system. The general format of the XML is:

 <taskdef name="jarmaster"
     classname="com.klg.jclass.jarmaster.JarMasterAntTask"/>
 <jarmaster clearDefaults="yes"
     compressionLevel="${jar.compression}"
     output="${jar.location}/myJar.jar">
     <classpath>
       <fileset dir="${destination.dir}/../jars">
         <include name="collections.jar"/>
         <include name="JClass.jar"/>
       </fileset>
       <pathelement path="${destination.dir}"/>
       <pathelement path="${destination.dir}/.."/>
     </classpath>
     <!-- Package excludes can be either class names or package names -->
     <excludepackage name="com/quest/deploy/GenerateSignature.class"/>
     <excludepackage name="com/klg/jclass/beans"/>
     <manifest file="${source.dir}/${package}/manifest1.txt"/>
     <manifest file="${source.dir}/${package}/manifest2.txt"/>
     <fileset dir="${destination.dir}">
       <include name="com/quest/deploy/servlet/deploydirector.gif"/>
       <include name="com/quest/deploy/servlet/deploydirector_ss.gif"/>
       <include name="com/quest/deploy/AbstractMessageQueue.class"/>
      </fileset>
 </jarmaster>
 
The classpath elements and fileset/include elements follow the same rules as the standard Ant built in tasks. Make sure to consult the Ant documentation for more details.


Nested Class Summary
static class JarMasterAntTask.Manifest
           
 
Field Summary
protected  String class_dir
           
protected  boolean clear_defaults
           
protected  int compression_level
           
protected  org.apache.tools.ant.types.PatternSet excludedPackages
           
protected  Vector filesets
           
protected  boolean is_jar
           
protected  org.apache.tools.ant.types.Path jarClasspath
           
protected  com.klg.jclass.jarmaster.JarMasterLocaleManager lm
           
protected  String main_class
           
protected  File manifest_file
           
protected  Vector manifests
           
protected  File output_file
           
 
Fields inherited from class org.apache.tools.ant.Task
description, location, target, taskName, taskType, wrapper
 
Fields inherited from class org.apache.tools.ant.ProjectComponent
project
 
Constructor Summary
JarMasterAntTask()
           
 
Method Summary
 void addFileset(org.apache.tools.ant.types.FileSet set)
          Adds a set of files (nested fileset attribute).
 String[] addToStringList(String[] stringList, String[] newList)
           
 org.apache.tools.ant.types.Path createClasspath()
          Creates a nested classpath element.
 org.apache.tools.ant.types.PatternSet.NameEntry createExcludePackage()
          Add a name entry to the list of packages to exclude.
 JarMasterAntTask.Manifest createManifest()
          Add a manifest file to the list of manifest files
 void execute()
          Called by Ant to excute this task.
 void setClasspath(org.apache.tools.ant.types.Path classpath)
          Set the searchpath to be used for building the jar.
 void setClasspathRef(org.apache.tools.ant.types.Reference r)
          Adds a reference to a classpath defined elsewhere.
 void setClearDefaults(String on_off)
          Determines whether or not to use the default (project wide) exclude list.
 void setCompressionLevel(String value)
          Sets the compression level for the created jar file.
 void setExcludepackageref(org.apache.tools.ant.types.Reference r)
          Defines the exclude package pattern set from a reference.
 void setIsJar(String on_off)
          Determines whether or not to create a jar or a zip file.
 void setMainClass(String name)
          Sets the name of the main class for an executable jar
 void setManifest(File man)
          Sets the file that is to be used as the manifest for the created jar.
 void setOutput(File name)
          Sets the name of the created jar file.
 
Methods inherited from class org.apache.tools.ant.Task
getDescription, getLocation, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, handleErrorFlush, handleErrorOutput, handleFlush, handleOutput, init, isInvalid, log, log, maybeConfigure, perform, setDescription, setLocation, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName
 
Methods inherited from class org.apache.tools.ant.ProjectComponent
getProject, setProject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

manifest_file

protected File manifest_file

class_dir

protected String class_dir

main_class

protected String main_class

output_file

protected File output_file

clear_defaults

protected boolean clear_defaults

is_jar

protected boolean is_jar

compression_level

protected int compression_level

jarClasspath

protected org.apache.tools.ant.types.Path jarClasspath

filesets

protected Vector filesets

manifests

protected Vector manifests

lm

protected com.klg.jclass.jarmaster.JarMasterLocaleManager lm

excludedPackages

protected org.apache.tools.ant.types.PatternSet excludedPackages
Constructor Detail

JarMasterAntTask

public JarMasterAntTask()
Method Detail

setExcludepackageref

public void setExcludepackageref(org.apache.tools.ant.types.Reference r)
Defines the exclude package pattern set from a reference.

Parameters:
r - A pattern set reference.

createExcludePackage

public org.apache.tools.ant.types.PatternSet.NameEntry createExcludePackage()
Add a name entry to the list of packages to exclude. This correspondes to the JarMaster -x <package name> command line option. the corresponding XML looks like:
   <excludepackage name="com/klg/jclass/beans"/>
   <excludepackage name="com/quest/deploy/tools/Build.class"/>
 
and you can specify specific files or general package names. Make sure you understand how JarMaster expects these to be formatted (not full path) and how it processes the entries.

Returns:
A PatternSet.NameEntry object (internal object used by Ant)

addFileset

public void addFileset(org.apache.tools.ant.types.FileSet set)
Adds a set of files (nested fileset attribute). See the Ant documentation on filesets for a more detailed description. Entries will be converted to full (absolute) paths before being passed to JarMaster.


setClearDefaults

public void setClearDefaults(String on_off)
Determines whether or not to use the default (project wide) exclude list. This corresponds to the JarMaster -clear option. The default is false.

Parameters:
on_off - True if the project wide exclude list is to be used and false if it is not.

setIsJar

public void setIsJar(String on_off)
Determines whether or not to create a jar or a zip file.

Parameters:
on_off - True, if a jar is to be created (default). False, if a zip file is to be created.

setCompressionLevel

public void setCompressionLevel(String value)
                         throws org.apache.tools.ant.BuildException
Sets the compression level for the created jar file. The default value is 9. The range is 0 (no compression) to 9 (maximum compression). This corresponds to the Jarmaster -level commandline option.

Parameters:
value - Compression level for the created jar file. Valid values are 0 (no compression) to 9 (max compression)
Throws:
org.apache.tools.ant.BuildException - If the provided value is not convertable to an interger or is out of the range 0-9

setManifest

public void setManifest(File man)
Sets the file that is to be used as the manifest for the created jar. This is optional. This corresponds to the JarMaster -m <manifest file> command line option. Note if you need to use more than one manifest file, use the nested manifest attribute

Parameters:
man - Name of the manifest file to use. This can be either relative to the current directoy or an absolute path.

createManifest

public JarMasterAntTask.Manifest createManifest()
Add a manifest file to the list of manifest files

Returns:
A Manifest object which stores the file

setClasspath

public void setClasspath(org.apache.tools.ant.types.Path classpath)
Set the searchpath to be used for building the jar. By default the current system classpath is used. See the Ant docs on <lclasspath> entries for exact details.


createClasspath

public org.apache.tools.ant.types.Path createClasspath()
Creates a nested classpath element. See the Ant docs on <lclasspath> entries for exact details.


setClasspathRef

public void setClasspathRef(org.apache.tools.ant.types.Reference r)
Adds a reference to a classpath defined elsewhere. See the Ant docs on <lclasspath> entries for exact details.


setOutput

public void setOutput(File name)
Sets the name of the created jar file.


setMainClass

public void setMainClass(String name)
Sets the name of the main class for an executable jar


addToStringList

public String[] addToStringList(String[] stringList,
                                String[] newList)

execute

public void execute()
             throws org.apache.tools.ant.BuildException
Called by Ant to excute this task.

Overrides:
execute in class org.apache.tools.ant.Task
org.apache.tools.ant.BuildException

Copyright © 2004 Quest Software Inc..
All rights reserved.