protoj.lang
Class ClassesArchive

java.lang.Object
  extended by protoj.lang.ClassesArchive

public final class ClassesArchive
extends java.lang.Object

Responsible for creating one or more archives from the project classes directory. Call addArchive(String, String, String, String, ArgRunnable) to configure each additional archive with the specified name and createArchive(String) to create one of the added archive. During creation, the config argument specified in the constructor will be called back to give the caller a chance to provide further archive configuration. Also call initIncludeArchives(String, String...) to cause any additional archives from the ProjectLayout.getLibDir() to be merged with the added archive.

Author:
Ashley Williams

Nested Class Summary
static class ClassesArchive.ClassesEntry
          Adds classes specific information to a wrapped ArchiveEntry instance.
 
Constructor Summary
ClassesArchive(ArchiveFeature parent)
          Creates with the parent feature.
 
Method Summary
 void addArchive(java.lang.String name, java.lang.String manifest, java.lang.String includes, java.lang.String excludes, ArgRunnable<ClassesArchive> config)
          Use to enable creation of an additional archive.
 void createArchive(java.lang.String name)
          Creates the jar for the given name under ProjectLayout.getArchiveDir().
 void createArchives()
          Delegates to createArchive(String) for each archive that was added through a call to addArchive(String, String, String, String, ArgRunnable).
 AssembleTask getCurrentAssembleTask()
          The ant task responsible for creating the jar during the call to createArchive(String).
 ArchiveEntry<ClassesArchive> getCurrentEntry()
          The instance used to hold information about the the archive being created during the call to createArchive(String).
 ClassesArchive.ClassesEntry getEntry(java.lang.String name)
          Accessor for the entry corresponding to the given name.
 void initExcludeArchives(java.lang.String name, java.lang.String... archives)
          Specifies that all the classes archives except for the excluded list in the ProjectLayout.getLibDir() should get merged during creation of the named archive.
 void initExecutableJar()
          Convenience method that delegates to initExecutableJar(String), but using the current thread main class by default.
 void initExecutableJar(java.lang.String mainClass)
          Marks the archive as an executable jar with the specified mainClass.
 void initIncludeArchives(java.lang.String name, java.lang.String... archives)
          Pass-thru method that ensures the specified archives are merged to the named archive.
 void initPublish(java.lang.String name, java.lang.String pomName, java.lang.String gpgOptions)
          Call this method if publishing to a maven repository is required.
 void visit(ArgRunnable<ClassesArchive.ClassesEntry> visitor)
          Convenient method that visits each entry in this archive.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClassesArchive

public ClassesArchive(ArchiveFeature parent)
Creates with the parent feature.

Parameters:
parent -
Method Detail

addArchive

public void addArchive(java.lang.String name,
                       java.lang.String manifest,
                       java.lang.String includes,
                       java.lang.String excludes,
                       ArgRunnable<ClassesArchive> config)
Use to enable creation of an additional archive.

Parameters:
name - the name of the jar file to be created, without the extension.
manifest - the name of the manifest to be used from the manifest directory, without the extension. Can be null if a default manifest is required.
includes - the resources that should be included in the archive, can be null to include all resources
excludes - the resources that should be excluded in the archive, can be null to exclude no resources
config - this will be called back during the invocation of createArchive(String) if the caller wishes to provide further configuration. Can be null if the defaults are ok.

initPublish

public void initPublish(java.lang.String name,
                        java.lang.String pomName,
                        java.lang.String gpgOptions)
Call this method if publishing to a maven repository is required. Pass-thru method to ClassesArchive.ClassesEntry.initPublish(String, String).

Parameters:
name -
pomName -
gpgOptions -

initIncludeArchives

public void initIncludeArchives(java.lang.String name,
                                java.lang.String... archives)
Pass-thru method that ensures the specified archives are merged to the named archive. See ArchiveEntry.initMergeArchives(String...).

Parameters:
name -
archives -

initExcludeArchives

public void initExcludeArchives(java.lang.String name,
                                java.lang.String... archives)
Specifies that all the classes archives except for the excluded list in the ProjectLayout.getLibDir() should get merged during creation of the named archive.

Parameters:
name -

createArchives

public void createArchives()
Delegates to createArchive(String) for each archive that was added through a call to addArchive(String, String, String, String, ArgRunnable).


createArchive

public void createArchive(java.lang.String name)
Creates the jar for the given name under ProjectLayout.getArchiveDir(). The jar file will have a name of [name].jar.

Parameters:
name - the name as specified in the call to addArchive(String, String, String, String, ArgRunnable) .

getEntry

public ClassesArchive.ClassesEntry getEntry(java.lang.String name)
Accessor for the entry corresponding to the given name.

Parameters:
name -
Returns:

initExecutableJar

public void initExecutableJar()
Convenience method that delegates to initExecutableJar(String), but using the current thread main class by default.


initExecutableJar

public void initExecutableJar(java.lang.String mainClass)
Marks the archive as an executable jar with the specified mainClass. Works in conjunction with the initIncludeArchives(String, String...) method, since any archive that is to be merged won't appear in the Class-Path attribute value.

This should be invoked on the callback to the config parameter specified in the call to addArchive(String, String, String, String, ArgRunnable). Ensures the given ant assemble task is configured to create an executable jar. The jar files in the lib directory are used to form the Class-Path string in the manifest file.

Parameters:
mainClass -

visit

public void visit(ArgRunnable<ClassesArchive.ClassesEntry> visitor)
Convenient method that visits each entry in this archive.

Parameters:
visitor -

getCurrentAssembleTask

public AssembleTask getCurrentAssembleTask()
The ant task responsible for creating the jar during the call to createArchive(String).

Returns:

getCurrentEntry

public ArchiveEntry<ClassesArchive> getCurrentEntry()
The instance used to hold information about the the archive being created during the call to createArchive(String).

Returns: