protoj.core
Class ProjectLayout

java.lang.Object
  extended by protoj.core.ProjectLayout

public final class ProjectLayout
extends java.lang.Object

Contains the locations of the various project directories. A typical project looks something like this:

 ˜/dev/myproj/
          |
          |____bin/                       shell scripts should go here
          |
          |____classes/                   java source files get compiled into here (auto-created)
          |
          |____conf/                      configuration files should go here
          |      |
          |      |____profile/            configuration profiles should go here
          |
          |____docs/                      documentation files should go here
          |
          |____lib/                       third party libs should go here
          |
          |____log/                       log files should go here
          |
          |____src/
          |      |
          |      |____java/               .java and .aj source files should go here
          |      |
          |      |____manifest/           manifest.mf files should go here, one per jar file
          |      |
          |      |____resources/          additional content for the classes directory and/or jar files should go here 
          |
          |____target/                    all-purpose project temp directory (auto-created)
                 |
                 |____archive/            java archives get generated here (auto-created)
                 |
                 |____junit-reports/      junit test reports get generated here (auto-created)
 

Here is some insight into the directory structure:

This is an immutable value object that is usually aggregated within a StandardProject parent, but can also be created in its own right - especially for tests that need to check details about directory structures.

Author:
Ashley Williams

Field Summary
 java.lang.String sourcePostfix
          See getSourcePostfix().
 java.lang.String srcPostfix
          See getSrcPostfix().
 
Constructor Summary
ProjectLayout(java.io.File rootDir, java.lang.String scriptName)
          Calculates all project paths under the given rootDir.
 
Method Summary
 void clean()
          Deletes the classes and target directories.
 void createPhysicalLayout()
          Creates the project layout on the filing system.
 java.io.File getArchiveDir()
          The directory where archives are generated.
 java.io.File getBinDir()
          The directory containing the files such as shell scripts.
 java.io.File getClassesDir()
          The directory containing .class compilation units, e.g.
 ArgRunnable<org.apache.tools.ant.types.Path> getClasspathConfig()
          The object used to configure classpaths.
 java.io.File getConfDir()
          The directory containing configuration files, e.g.
 java.io.File getDocsDir()
          The directory containing documentation
 java.io.File getJar(java.lang.String jarName)
          Convenience method that returns the fully qualified jar file given just its name.
 java.io.File getJavaDir()
          The directory containing compilation sources, e.g.
 java.lang.String getJavadocPostfix()
          Forms part of the name of each javadocArchive archive.
 java.io.File getJunitReportsDir()
          The directory containing junit reports, e.g.
 java.io.File getLibDir()
          The directory containing java libraries, e.g.
 java.io.File getLogDir()
          The directory containing log files, e.g.
 java.io.File getLogFile()
          The file used for logging, e.g.
 java.io.File getManifest(java.lang.String name)
          Convenience method that returns the fully qualified manifest file given just its name.
 java.io.File getManifestDir()
          The directory containing manifest files, e.g.
 java.io.File getProfileDir()
          The directory that contains profile subdirectories as defined by the user.
 java.io.File getPropertiesFile()
          The file that contains all the application properties when the config command is used with interpolation.
 java.lang.String getRelativePath(java.io.File child)
          Calculates the relative path string of the child to the layout root dir.
 java.io.File getResourcesDir()
          The directory containing resources, e.g.
 java.io.File getRootDir()
          The directory where all the project files are located, e.g.
 java.lang.String getRootName()
          Convenience method that returns the name of the root project directory.
 java.lang.String getRootPath()
           
 java.lang.String getScriptName()
          Convenience method that returns the name of the shell script.
 java.io.File getShellScript()
          The script responsible for executing the project.
 java.lang.String getSourcePostfix()
          Forms part of the name of each sourceArchive archive.
 java.io.File getSrcDir()
          The directory containing the source files.
 java.lang.String getSrcPostfix()
          Some archives contain the string "src" to indicate they are jar files that contain source.
 java.io.File getTargetDir()
          The directory used for temporary files, e.g.
 java.lang.String loadLog()
          Loads the log from disk and reads its content into a string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

sourcePostfix

public java.lang.String sourcePostfix
See getSourcePostfix().


srcPostfix

public java.lang.String srcPostfix
See getSrcPostfix().

Constructor Detail

ProjectLayout

public ProjectLayout(java.io.File rootDir,
                     java.lang.String scriptName)
Calculates all project paths under the given rootDir. An exception is thrown if any of the physical mandatory directories are missing.

Parameters:
rootDir - the project root directory
scriptName - the name of the launch script with optional extension - see createScriptName(String).
Method Detail

createPhysicalLayout

public void createPhysicalLayout()
Creates the project layout on the filing system.


getRootPath

public java.lang.String getRootPath()

getRootDir

public java.io.File getRootDir()
The directory where all the project files are located, e.g. ~/dev/myproj

Returns:

getRootName

public java.lang.String getRootName()
Convenience method that returns the name of the root project directory.

Returns:

getBinDir

public java.io.File getBinDir()
The directory containing the files such as shell scripts.

Returns:

getShellScript

public java.io.File getShellScript()
The script responsible for executing the project.

Returns:

getScriptName

public java.lang.String getScriptName()
Convenience method that returns the name of the shell script.

Returns:

getDocsDir

public java.io.File getDocsDir()
The directory containing documentation

Returns:

getArchiveDir

public java.io.File getArchiveDir()
The directory where archives are generated.

Returns:

getSrcDir

public java.io.File getSrcDir()
The directory containing the source files.

Returns:

getLogDir

public java.io.File getLogDir()
The directory containing log files, e.g. ~/dev/myproj/log.

Returns:

getLogFile

public java.io.File getLogFile()
The file used for logging, e.g. ~/dev/myproj/log/protoj.log

Returns:

getPropertiesFile

public java.io.File getPropertiesFile()
The file that contains all the application properties when the config command is used with interpolation. That is all the properties files in a profile are combined into a single file (this one) and all ${} tokens are fully resolved.

Returns:

getConfDir

public java.io.File getConfDir()
The directory containing configuration files, e.g. ~/dev/myproj/conf

Returns:

getProfileDir

public java.io.File getProfileDir()
The directory that contains profile subdirectories as defined by the user. Each profile subdirectory usually contains a directory structure similar to the project itself and during the configuration process they will be used to copy over the top. Special handling for property files ensures contained properties get merged.

Returns:

getJavaDir

public java.io.File getJavaDir()
The directory containing compilation sources, e.g. ~/dev/myproj/src/java

Returns:

getResourcesDir

public java.io.File getResourcesDir()
The directory containing resources, e.g. ~/dev/myproj/src/resources

Returns:

getManifestDir

public java.io.File getManifestDir()
The directory containing manifest files, e.g. ~/dev/myproj/src/manifest

Returns:

getLibDir

public java.io.File getLibDir()
The directory containing java libraries, e.g. ~/dev/myproj/lib

Returns:

getTargetDir

public java.io.File getTargetDir()
The directory used for temporary files, e.g. ~/dev/myproj/target

Returns:

getClassesDir

public java.io.File getClassesDir()
The directory containing .class compilation units, e.g. ~/dev/myproj/classes

Returns:

getJunitReportsDir

public java.io.File getJunitReportsDir()
The directory containing junit reports, e.g. ~/dev/myproj/target/junit-reports.

Returns:

getJar

public java.io.File getJar(java.lang.String jarName)
Convenience method that returns the fully qualified jar file given just its name.

Parameters:
jarName -
Returns:

getManifest

public java.io.File getManifest(java.lang.String name)
Convenience method that returns the fully qualified manifest file given just its name.

Parameters:
name -
Returns:

getClasspathConfig

public ArgRunnable<org.apache.tools.ant.types.Path> getClasspathConfig()
The object used to configure classpaths. Adds the classes and lib directories.

Returns:

getSourcePostfix

public java.lang.String getSourcePostfix()
Forms part of the name of each sourceArchive archive.

Returns:

getSrcPostfix

public java.lang.String getSrcPostfix()
Some archives contain the string "src" to indicate they are jar files that contain source.

Returns:

getJavadocPostfix

public java.lang.String getJavadocPostfix()
Forms part of the name of each javadocArchive archive.

Returns:

getRelativePath

public java.lang.String getRelativePath(java.io.File child)
Calculates the relative path string of the child to the layout root dir. As an example for a root path of /usr/dev/project and a child path of /usr/dev/project/foo/bar, the relative path is foo/bar.

Parameters:
child -
Returns:

loadLog

public java.lang.String loadLog()
Loads the log from disk and reads its content into a string. Useful for examining small log files since entire content is pulled into memory.

Returns:

clean

public void clean()
Deletes the classes and target directories.