org.freecompany.imp
Class Index

java.lang.Object
  extended by org.apache.tools.ant.ProjectComponent
      extended by org.apache.tools.ant.Task
          extended by org.freecompany.imp.Index
All Implemented Interfaces:
java.lang.Cloneable

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

Models the index structure for an individual project.


Field Summary
protected  java.util.List<Dependency> dependencies
           
protected  java.lang.String format
           
protected  java.lang.String group
           
protected  java.lang.String name
           
protected  java.util.List<Repository> repositories
           
protected  java.io.File src
           
protected  java.util.List<AntOverride> subprojects
           
protected  java.util.List<java.lang.String> types
           
protected  java.lang.String version
           
 
Fields inherited from class org.apache.tools.ant.Task
target, taskName, taskType, wrapper
 
Fields inherited from class org.apache.tools.ant.ProjectComponent
description, location, project
 
Constructor Summary
Index()
           
 
Method Summary
 void addAnt(AntOverride ant)
           
 void addDependency(Dependency dependency)
           
 void addRepository(Repository repository)
           
protected  void buildFileset(java.lang.String name, java.util.Collection<Dependency> list)
          This is an inoptimal solution to building filesets for use in the build system.
protected  void buildPath(java.lang.String name, java.util.Collection<Dependency> list)
          For the given list of dependencies ths method builds a corresponding Ant path element which is inserted by reference into the project.
 void execute()
          Configures this index structure using the values and objects set on this index during the build initialization.
protected  java.lang.String getAllowedIndexTypes()
          Generates a comma separated list of possible index types.
 java.lang.String getGroup()
           
 java.lang.String getName()
           
 java.util.List<AntOverride> getSubprojects()
           
 java.util.List<java.lang.String> getTypes()
           
protected  void include(java.lang.String name)
           
 void setFormat(java.lang.String format)
           
 void setGroup(java.lang.String group)
           
 void setProject(org.apache.tools.ant.Project project)
           
 void setSrc(java.io.File src)
           
 void setTypes(java.lang.String types)
           
protected  void setupDependencies()
           
protected  void setupIndexFile()
          If this index specifies a source document with the src attribute it will be parsed according to the format specified.
protected  void setupReferences()
          Takes the local object sets that have been built up by defining dependencies, resolution tasks and index file parsing and publishes them to the build project context.
protected  void setupRepositories()
          Sets up any locally defined repositories in the index element.
 
Methods inherited from class org.apache.tools.ant.Task
bindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType
 
Methods inherited from class org.apache.tools.ant.ProjectComponent
clone, getDescription, getLocation, getProject, setDescription, setLocation
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

version

protected java.lang.String version

dependencies

protected java.util.List<Dependency> dependencies

repositories

protected java.util.List<Repository> repositories

subprojects

protected java.util.List<AntOverride> subprojects

name

protected java.lang.String name

group

protected java.lang.String group

types

protected java.util.List<java.lang.String> types

format

protected java.lang.String format

src

protected java.io.File src
Constructor Detail

Index

public Index()
Method Detail

setProject

public void setProject(org.apache.tools.ant.Project project)
Overrides:
setProject in class org.apache.tools.ant.ProjectComponent

include

protected void include(java.lang.String name)

execute

public void execute()
             throws org.apache.tools.ant.BuildException
Configures this index structure using the values and objects set on this index during the build initialization. If the 'src' attribute is set the file is parsed and processed using the interpreter specified in the 'type' attribute. Next any subprojects of this index, whether they were directly nested in the build file or specified in the external index, are executed. Finally, the required properties for this build are set so that the local target is ready to execute.

Type targets are handled as a special case. For each type listed in the index element's type attribute, a check is made to see if a target for that type is already regsitered in the project. If not, then the index code will automatically attempt to resolve a template corresponding to the type against the base module. For example, providing the index type war will cause the index to search for any locally definined target named war or one in any imports in the build file. If none is found the index will attempt to import the uri #war.template. This fragment is resolved against the core module which, if the template is provided with Imp, will maintain an alias mapping that common name to the specific template version and URI.

After setting up the complete environment for building, this method will finally iterate through the Imp specific property types to execute them.

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

setupRepositories

protected void setupRepositories()
Sets up any locally defined repositories in the index element.


setupIndexFile

protected void setupIndexFile()
If this index specifies a source document with the src attribute it will be parsed according to the format specified. The information gathered from parsing the index file is added to that which is specified directly in the index element, except where it is contradictory, in which case the index file takes presidence.


setupDependencies

protected void setupDependencies()

setupReferences

protected void setupReferences()
Takes the local object sets that have been built up by defining dependencies, resolution tasks and index file parsing and publishes them to the build project context. These references will be available to both internal Ant classes as well as targets in the build script.


buildPath

protected void buildPath(java.lang.String name,
                         java.util.Collection<Dependency> list)
                  throws java.lang.Exception
For the given list of dependencies ths method builds a corresponding Ant path element which is inserted by reference into the project. This allows targets and tasks in the scripts to reference them without requiring Java code.

Throws:
java.lang.Exception

buildFileset

protected void buildFileset(java.lang.String name,
                            java.util.Collection<Dependency> list)
                     throws java.lang.Exception
This is an inoptimal solution to building filesets for use in the build system. Because this method assumes that all dependencies share a common filesystem root it would certainly break if this were not the case. This is not an issue on any Unix system as they have only one root, nor on Windows systems with the current URI handlers we have available. But be warned...

Throws:
java.lang.Exception

getAllowedIndexTypes

protected java.lang.String getAllowedIndexTypes()
Generates a comma separated list of possible index types. This is generated by examining all registered types for compatibility. This list is only really useful for debugging purposes, though it could also potentially be used for finding a default parser implementation to use instead of the hardcoded default we currently use.


setGroup

public void setGroup(java.lang.String group)

setTypes

public void setTypes(java.lang.String types)

setFormat

public void setFormat(java.lang.String format)

setSrc

public void setSrc(java.io.File src)

addAnt

public void addAnt(AntOverride ant)

addRepository

public void addRepository(Repository repository)

addDependency

public void addDependency(Dependency dependency)

getName

public java.lang.String getName()

getGroup

public java.lang.String getGroup()

getTypes

public java.util.List<java.lang.String> getTypes()

getSubprojects

public java.util.List<AntOverride> getSubprojects()