net.dpml.tools.impl
Class DefaultContext

java.lang.Object
  extended by net.dpml.tools.impl.DefaultContext
All Implemented Interfaces:
Context

public final class DefaultContext
extends Object
implements Context

Default implementation of a project context.

Version:
1.2.0
Author:
Digital Product Meta Library

Constructor Summary
DefaultContext(Project project)
          Creation of a new project build context.
DefaultContext(Resource resource, Project project)
          Creation of a new project build context.
 
Method Summary
 File createFile(String path)
          Create a file relative to the resource basedir.
 Path createPath(Resource[] resources)
          Utility operation to construct a new path using a supplied array of resources.
 Path createPath(Resource[] resources, boolean resolve, boolean filter)
          Utility operation to construct a new path using a supplied array of resources.
 Path createPath(Scope scope)
          Utility operation to construct a new classpath path instance.
 File getEtcDataDirectory()
          Return the project etc/resources directory.
 File getEtcDirectory()
          Return the project etc directory.
 File getEtcMainDirectory()
          Return the project etc/main directory.
 File getEtcTestDirectory()
          Return the project etc/test directory.
 String getLayoutBase(String id)
          Return the directory path representing the module structure and type using the layout strategy employed by the cache.
 String getLayoutFilename(String id)
          Return a filename using the layout strategy employed by the cache.
 String getLayoutPath(String id)
          Return the full path to an artifact using the layout employed by the cache.
 Library getLibrary()
          Return the resource library.
 Path getPath(Scope scope)
          Return an Ant path suitable for comile or runtime usage.
 Project getProject()
          Return the associated project.
 String getProperty(String key)
          Return the value of a property.
 String getProperty(String key, String value)
          Return the value of a property.
 Resource getResource()
          Return the active resource.
 File getSrcDirectory()
          Return the project source directory.
 File getSrcDocsDirectory()
          Return the project source docs directory.
 File getSrcMainDirectory()
          Return the project source main directory.
 File getSrcTestDirectory()
          Return the project source test directory.
 File getTargetBuildDirectory()
          Return the project target build directory.
 File getTargetBuildDocsDirectory()
          Return the project target build docs directory.
 File getTargetBuildMainDirectory()
          Return the project target build main directory.
 File getTargetBuildTestDirectory()
          Return the project target build test directory.
 File getTargetClassesDirectory()
          Return the project target root classes directory.
 File getTargetClassesMainDirectory()
          Return the project target main classes directory.
 File getTargetClassesTestDirectory()
          Return the project target test classes directory.
 File getTargetDeliverable(String type)
          Return the project target deliverables directory.
 File getTargetDeliverablesDirectory()
          Return the project target deliverables directory.
 File getTargetDirectory()
          Return the project target directory.
 File getTargetDirectory(String path)
          Return a directory within the target directory.
 File getTargetDocsDirectory()
          Return the project target reports docs directory.
 File getTargetReportsDirectory()
          Return the project target reports directory.
 File getTargetReportsJavadocDirectory()
          Return the project target javadoc reports directory.
 File getTargetReportsMainDirectory()
          Return the project target main reports directory.
 File getTargetReportsTestDirectory()
          Return the project target test reports directory.
 File getTargetTempDirectory()
          Return the project target temp directory.
 File getTargetTestDirectory()
          Return the project target test directory.
 void init()
          Initialize the context during which runtime and test path objects are established as project references.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultContext

public DefaultContext(Project project)
               throws Exception
Creation of a new project build context.

Parameters:
project - the unconfigured Ant project
Throws:
Exception - if an error occurs during context extablishment

DefaultContext

public DefaultContext(Resource resource,
                      Project project)
               throws Exception
Creation of a new project build context.

Parameters:
resource - the resource definition
project - the Ant project
Throws:
Exception - if an error occurs during context extablishment
Method Detail

init

public void init()
Initialize the context during which runtime and test path objects are established as project references.

Specified by:
init in interface Context

getProject

public Project getProject()
Return the associated project.

Specified by:
getProject in interface Context
Returns:
the ant project

getProperty

public String getProperty(String key)
Return the value of a property.

Specified by:
getProperty in interface Context
Parameters:
key - the property key
Returns:
the property value or null if undefined

getProperty

public String getProperty(String key,
                          String value)
Return the value of a property. If the project contains a declaration for the property then that value will be returned, otherwise the property will be resolved relative to the current resource.

Specified by:
getProperty in interface Context
Parameters:
key - the property key
value - the default value
Returns:
the property value or null if undefined

getPath

public Path getPath(Scope scope)
Return an Ant path suitable for comile or runtime usage. If the supplied scope is less than Scope.RUNTIME a runtime path is returned otherwise the test path is returned.

Specified by:
getPath in interface Context
Parameters:
scope - the build scope
Returns:
the path object

getResource

public Resource getResource()
Return the active resource.

Specified by:
getResource in interface Context
Returns:
the resource definition

getLibrary

public Library getLibrary()
Return the resource library.

Specified by:
getLibrary in interface Context
Returns:
the library

getSrcDirectory

public File getSrcDirectory()
Return the project source directory.

Specified by:
getSrcDirectory in interface Context
Returns:
the directory

getSrcMainDirectory

public File getSrcMainDirectory()
Return the project source main directory.

Specified by:
getSrcMainDirectory in interface Context
Returns:
the directory

getSrcTestDirectory

public File getSrcTestDirectory()
Return the project source test directory.

Specified by:
getSrcTestDirectory in interface Context
Returns:
the directory

getSrcDocsDirectory

public File getSrcDocsDirectory()
Return the project source docs directory.

Specified by:
getSrcDocsDirectory in interface Context
Returns:
the directory

getEtcDirectory

public File getEtcDirectory()
Return the project etc directory.

Specified by:
getEtcDirectory in interface Context
Returns:
the directory

getEtcMainDirectory

public File getEtcMainDirectory()
Return the project etc/main directory.

Specified by:
getEtcMainDirectory in interface Context
Returns:
the directory

getEtcTestDirectory

public File getEtcTestDirectory()
Return the project etc/test directory.

Specified by:
getEtcTestDirectory in interface Context
Returns:
the directory

getEtcDataDirectory

public File getEtcDataDirectory()
Return the project etc/resources directory.

Specified by:
getEtcDataDirectory in interface Context
Returns:
the directory

getTargetDirectory

public File getTargetDirectory()
Return the project target directory.

Specified by:
getTargetDirectory in interface Context
Returns:
the directory

getTargetDirectory

public File getTargetDirectory(String path)
Return a directory within the target directory.

Specified by:
getTargetDirectory in interface Context
Parameters:
path - the path
Returns:
the directory

getTargetTempDirectory

public File getTargetTempDirectory()
Return the project target temp directory.

Specified by:
getTargetTempDirectory in interface Context
Returns:
the directory

getTargetBuildDirectory

public File getTargetBuildDirectory()
Return the project target build directory.

Specified by:
getTargetBuildDirectory in interface Context
Returns:
the directory

getTargetBuildMainDirectory

public File getTargetBuildMainDirectory()
Return the project target build main directory.

Specified by:
getTargetBuildMainDirectory in interface Context
Returns:
the directory

getTargetBuildTestDirectory

public File getTargetBuildTestDirectory()
Return the project target build test directory.

Specified by:
getTargetBuildTestDirectory in interface Context
Returns:
the directory

getTargetBuildDocsDirectory

public File getTargetBuildDocsDirectory()
Return the project target build docs directory.

Specified by:
getTargetBuildDocsDirectory in interface Context
Returns:
the directory

getTargetClassesDirectory

public File getTargetClassesDirectory()
Return the project target root classes directory.

Specified by:
getTargetClassesDirectory in interface Context
Returns:
the directory

getTargetClassesMainDirectory

public File getTargetClassesMainDirectory()
Return the project target main classes directory.

Specified by:
getTargetClassesMainDirectory in interface Context
Returns:
the directory

getTargetClassesTestDirectory

public File getTargetClassesTestDirectory()
Return the project target test classes directory.

Specified by:
getTargetClassesTestDirectory in interface Context
Returns:
the directory

getTargetReportsDirectory

public File getTargetReportsDirectory()
Return the project target reports directory.

Specified by:
getTargetReportsDirectory in interface Context
Returns:
the directory

getTargetReportsTestDirectory

public File getTargetReportsTestDirectory()
Return the project target test reports directory.

Specified by:
getTargetReportsTestDirectory in interface Context
Returns:
the directory

getTargetReportsMainDirectory

public File getTargetReportsMainDirectory()
Return the project target main reports directory.

Specified by:
getTargetReportsMainDirectory in interface Context
Returns:
the directory

getTargetReportsJavadocDirectory

public File getTargetReportsJavadocDirectory()
Return the project target javadoc reports directory.

Specified by:
getTargetReportsJavadocDirectory in interface Context
Returns:
the directory

getTargetDocsDirectory

public File getTargetDocsDirectory()
Return the project target reports docs directory.

Specified by:
getTargetDocsDirectory in interface Context
Returns:
the directory

getTargetTestDirectory

public File getTargetTestDirectory()
Return the project target test directory.

Specified by:
getTargetTestDirectory in interface Context
Returns:
the directory

getTargetDeliverablesDirectory

public File getTargetDeliverablesDirectory()
Return the project target deliverables directory.

Specified by:
getTargetDeliverablesDirectory in interface Context
Returns:
the directory

getTargetDeliverable

public File getTargetDeliverable(String type)
Return the project target deliverables directory.

Specified by:
getTargetDeliverable in interface Context
Parameters:
type - the deliverable type
Returns:
the directory

createFile

public File createFile(String path)
Create a file relative to the resource basedir.

Specified by:
createFile in interface Context
Parameters:
path - the relative path
Returns:
the directory

getLayoutFilename

public String getLayoutFilename(String id)
Return a filename using the layout strategy employed by the cache.

Specified by:
getLayoutFilename in interface Context
Parameters:
id - the artifact type
Returns:
the filename

getLayoutBase

public String getLayoutBase(String id)
Return the directory path representing the module structure and type using the layout strategy employed by the cache.

Specified by:
getLayoutBase in interface Context
Parameters:
id - the artifact type
Returns:
the path from the root of the cache to the directory containing the artifact

getLayoutPath

public String getLayoutPath(String id)
Return the full path to an artifact using the layout employed by the cache.

Specified by:
getLayoutPath in interface Context
Parameters:
id - the artifact type
Returns:
the full path including base path and filename

createPath

public Path createPath(Scope scope)
Utility operation to construct a new classpath path instance.

Specified by:
createPath in interface Context
Parameters:
scope - the build scope
Returns:
the path

createPath

public Path createPath(Resource[] resources)
Utility operation to construct a new path using a supplied array of resources.

Specified by:
createPath in interface Context
Parameters:
resources - the resource to use in path construction
Returns:
the path

createPath

public Path createPath(Resource[] resources,
                       boolean resolve,
                       boolean filter)
Utility operation to construct a new path using a supplied array of resources.

Specified by:
createPath in interface Context
Parameters:
resources - the resources to use in path construction
resolve - if true force local caching of the artifact
filter - if true restrict path entries to resources that produce jars
Returns:
the path