net.ggtools.grand.ant
Class AntProject

java.lang.Object
  extended by net.ggtools.grand.ant.AntProject
All Implemented Interfaces:
GraphProducer

public class AntProject
extends java.lang.Object
implements GraphProducer

A graph producer from ant build files or Project objects. The nodes will be the project's target and the links will be the dependencies between targets. Beside hard dependencies, this producer is also able to create weaks links from dependencies introduced by the use of the antcall or foreach tasks.

Author:
Christophe Labouisse
See Also:
Ant contrib tasks for the foreach task.

Constructor Summary
AntProject(java.io.File source)
          Creates a new project from an ant build file.
AntProject(java.io.File source, java.util.Properties properties)
          Creates a new project from an ant build file.
AntProject(org.apache.tools.ant.Project project)
          Creates a new project from an existing ant project.
 
Method Summary
 org.apache.tools.ant.Project getAntProject()
          Returns the underlying ant project.
 Graph getGraph()
          Convert an Ant project to a Grand Graph.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AntProject

public AntProject(java.io.File source)
           throws GrandException
Creates a new project from an ant build file. The source object can be anything supported by ProjectHelper which is at least a File.

Parameters:
source - The source for XML configuration.
Throws:
GrandException - if the project cannot be loaded.
See Also:
ProjectHelper.parse(org.apache.tools.ant.Project, java.lang.Object)

AntProject

public AntProject(java.io.File source,
                  java.util.Properties properties)
           throws GrandException
Creates a new project from an ant build file. The source object can be anything supported by ProjectHelper which is at least a File.

Parameters:
source - The source for XML configuration.
properties - a set of properties to be preset when opening the graph or null if no properties should be preset.
Throws:
GrandException - if the project cannot be loaded.
See Also:
ProjectHelper.parse(org.apache.tools.ant.Project, java.lang.Object)

AntProject

public AntProject(org.apache.tools.ant.Project project)
Creates a new project from an existing ant project.

Parameters:
project - project to create the graph from.
Method Detail

getAntProject

public org.apache.tools.ant.Project getAntProject()
Returns the underlying ant project.

Returns:
underlying ant project.

getGraph

public Graph getGraph()
               throws GrandException
Convert an Ant project to a Grand Graph. The conversion is done in several steps:
  1. Each ant target will be converted to a Grand Node using both the target's name and description the the node's ones. Targets with a non empty description will be converted to Nodes with the Node.ATTR_MAIN_NODEattribute set. If the project element has a valid default target, the corresponding node will be the graph start target.
  2. depends attributes on targets will be translated into links. antcall s or the contributed foreach task will be translated in links with the Link.ATTR_WEAK_LINKset.

Specified by:
getGraph in interface GraphProducer
Returns:
a graph representing the dependency of the ant project.
Throws:
GrandException - if the project cannot be converted to a graph.
See Also:
GraphProducer.getGraph()


Copyright © 2004-2005 ggTools. All Rights Reserved.