Class AntProject

  • All Implemented Interfaces:
    GraphProducer

    public class AntProject
    extends 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 weak 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 Detail

      • AntProject

        public AntProject​(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​(File source,
                          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 final org.apache.tools.ant.Project getAntProject()
        Returns the underlying Ant project.
        Returns:
        underlying Ant project.
      • getGraph

        public final 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()