protoj.lang
Class ProjectArchive

java.lang.Object
  extended by protoj.lang.ProjectArchive

public final class ProjectArchive
extends java.lang.Object

Provides support for creating a compressed tar of the entire project. If further configuration is required, such as adding or excluding directories, then supply an appropriate config argument to the constructor below. In the following example, an extra directory called "exampledir" gets included in the mytar tar.gz file:

 config = new ArgRunnable<ProjectArchive>() {
        public void configure(ProjectArchive feature) {
                feature.addFileSet("777", "777", "exampledir/**", null);
        }
 };
 tarFeature = new ProjectArchive(this, name, userName, group, config);
 

Ant tasks can only be used once and cannot be reconfigured for a second time. And so the solution is to place the configuration (the api calls) in a runnable as in the above example so that it can be stored. The createArchive(boolean, boolean) method then creates a brand new ant tar task every time, but passes it through the runnable that was supplied to the constructor so that it can be configured correctly.

Author:
Ashley Williams

Constructor Summary
ProjectArchive(ArchiveFeature parent, java.lang.String name, java.lang.String prefix, java.lang.String userName, java.lang.String group, ArgRunnable<ProjectArchive> config)
          The individual property getter methods describe the parameters of the same name.
 
Method Summary
 void addFileSet(java.lang.String fileMode, java.lang.String dirMode, java.lang.String includes, java.lang.String excludes)
          Adds the given fileset definition to the underlying tar ant task.
 void createArchive(boolean noSrc, boolean isGlobalRwx)
          Creates a tar of the parent in the target directory.
 org.apache.tools.ant.taskdefs.Tar getAntTar()
          The underlying ant object, which can be used for further customization.
 java.io.File getArchiveFile()
           
 java.lang.String getArchivePath()
          Returns the full path name of the compressed tar file, eg /a/b/c/foo.tar.gz.
 java.lang.String getConfExcludesPattern()
          The pattern used to filter out properties files from directly under the conf directory.
 java.lang.String getGroup()
          The groupname for the tar entries.
 java.lang.String getLibExcludesPattern()
          The pattern used to filter out source and javadoc jar files from directly under the lib directory.
 java.lang.String getLogExcludesPattern(java.io.File logFile)
          The pattern used to filter out the protoj log file from the log directory.
 java.lang.String getName()
          The name to be used in the tar file before any prefix or suffix decoration or file extensions have been applied.
 ArchiveFeature getParent()
          The parent of this feature.
 java.lang.String getPrefix()
          Often an application installation directory has additional business requirements such as the inclusion of a version number, customer product identifier and so on.
 java.lang.String getUncompressedPath()
          Returns the full path name of the uncompressed tar file, eg /a/b/c/foo.tar.
 java.lang.String getUserName()
          The username for the tar entries.
 boolean isGlobalRwx()
          If this is true then permissions are set to rwx on all files and directories in the tar, overriding any original configuration.
 boolean isNoSrc()
          Whether or not to include the source directory in the tar.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ProjectArchive

public ProjectArchive(ArchiveFeature parent,
                      java.lang.String name,
                      java.lang.String prefix,
                      java.lang.String userName,
                      java.lang.String group,
                      ArgRunnable<ProjectArchive> config)
The individual property getter methods describe the parameters of the same name. See ProjectArchive for more explanation of the ArgRunnable parameter.

Parameters:
parent -
name -
prefix -
userName -
group -
config -
Method Detail

getParent

public ArchiveFeature getParent()
The parent of this feature.

Returns:

getUserName

public java.lang.String getUserName()
The username for the tar entries.

Returns:

getGroup

public java.lang.String getGroup()
The groupname for the tar entries.

Returns:

getName

public java.lang.String getName()
The name to be used in the tar file before any prefix or suffix decoration or file extensions have been applied.

Returns:

getPrefix

public java.lang.String getPrefix()
Often an application installation directory has additional business requirements such as the inclusion of a version number, customer product identifier and so on. The prefix enforces this since it is used as the prefix for every entry in the tar file.

Returns:

isNoSrc

public boolean isNoSrc()
Whether or not to include the source directory in the tar.

Returns:

isGlobalRwx

public boolean isGlobalRwx()
If this is true then permissions are set to rwx on all files and directories in the tar, overriding any original configuration.

Returns:

getAntTar

public org.apache.tools.ant.taskdefs.Tar getAntTar()
The underlying ant object, which can be used for further customization.

Returns:

getUncompressedPath

public java.lang.String getUncompressedPath()
Returns the full path name of the uncompressed tar file, eg /a/b/c/foo.tar.

Returns:

getArchivePath

public java.lang.String getArchivePath()
Returns the full path name of the compressed tar file, eg /a/b/c/foo.tar.gz.

Returns:

getArchiveFile

public java.io.File getArchiveFile()

addFileSet

public void addFileSet(java.lang.String fileMode,
                       java.lang.String dirMode,
                       java.lang.String includes,
                       java.lang.String excludes)
Adds the given fileset definition to the underlying tar ant task. The pattern entries should be specified relative to the parent root directory. Reminder: read=4, write=2, execute=1. Note that if isGlobalRwx() is set to true then the fileMode and dirMode parameters are ignored in favor of the most relaxed rwx permissions.

Parameters:
fileMode -
dirMode -
includes -
excludes -

createArchive

public void createArchive(boolean noSrc,
                          boolean isGlobalRwx)
Creates a tar of the parent in the target directory. First a brand new ant tar task is created. Then it is configured with the defaults - see initTarTask(). Finally it is configured by applying the config strategy and then executed.

Parameters:
noSrc - true in order to exclude the src directory, false otherwise.
isGlobalRwx - true to override preconfigured permissions with rwx, false to leave alone

getLogExcludesPattern

public java.lang.String getLogExcludesPattern(java.io.File logFile)
The pattern used to filter out the protoj log file from the log directory.

Returns:

getConfExcludesPattern

public java.lang.String getConfExcludesPattern()
The pattern used to filter out properties files from directly under the conf directory.

Returns:

getLibExcludesPattern

public java.lang.String getLibExcludesPattern()
The pattern used to filter out source and javadoc jar files from directly under the lib directory.

Returns: