You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by bu...@apache.org on 2005/05/10 18:04:08 UTC

DO NOT REPLY [Bug 34845] New: - RFE: new task

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=34845>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=34845

           Summary: RFE: new <delegate> task
           Product: Ant
           Version: 1.6.3
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: Core tasks
        AssignedTo: dev@ant.apache.org
        ReportedBy: michael.cepek@spanlink.com


Summary:  a new task is needed to allow a set of Ant scripts to merely configure
some settings and then delegate the actual execution of targets to one central,
common Ant script for the project.

The Problem:  Consider creating one "Master" Ant script for a project which
encapsulates the features, dependencies, and functionality for the most common
targets (such as compile, build, javadoc, clean, and their project-wide
equivalents like build-all, clean-all, etc).  For example, one target in this
Master script might be:

    <target name="compile-pkg">
        <pathconvert refid="dependencies" property="has_deps"
                dirsep="${file.separator}" setOnEmpty="false"/>
        <antcall target="compile-dependencies" inheritRefs="true"/>
        <mkdir dir="${CLASS_DIR}"/>
        <property name="excludes" value=""/> <!-- no-op if already set -->
        <javac srcdir="${SRC_JAVA_DIR}"
                includes="${PKG_PATH}/**/*.java"
                classpathref="compile_classpath"
                destdir="${CLASS_DIR}"
                excludes="${excludes}"
                deprecation="on" debug="on"/>
    </target>

It is wonderful to encapsulate all the logic for this target in one place. 
However, to make use of it, every (subordinate) script which calls this target
in this Master script has to use code like:

    <target name="compile" depends="init"
                description="compiles sources in this package">
        <ant antfile="${MASTER}" target="compile-pkg" inheritrefs="true">
                <reference refid="my_dependencies" toRefid="dependencies"/>
        </ant>
    </target>

Further, every subordinate script must be edited to accomodate most changes made
to improve the master script, or to add or change functionality.  This
copy-n-paste replication is brittle and difficult to maintain.

The Solution:  A new <delegate> task which specifies an Ant script which should
"take over" the completion of the current script, including all (unfinished?)
targets.

The current <ant>, <antcall> and <subant> tasks are specific to a single target.
 This new <delegate> task would transfer control for ALL remaining targets.

Property and reference inheritance is particularly important.  The example above
illustrates how the master script "compile-pkg" target uses its
"compile-dependencies" target to compile all dependent items.  Those
dependencies are passed in from the subordinate script to the Master script
using the <reference toRefId="..."> task.  Note that the Master will likely call
other subordinate scripts for those dependent compiles.

The following three lines could replace ALL the subordinate script tasks like
compile, compile-all, build, build-all, javadoc, javadoc-all, javadoc-pub, etc:

    <delegate antfile="${MASTER}" inheritrefs="true">
        <reference refid="my_dependencies" toRefid="dependencies"/>
    </delegate>

In otherwords, these three lines would replace scores of replicated lines in
every subordinate script.

The Ant command-line argument -find doesn't quite cut it either, since each
subordinate script will have customized elements (like defining the
"my_dependencies" path reference in the examples here).

As far as the subordinate script is concerned, all the targets in the Master
script are available.  Thus, -projecthelp and IDE integration should list the
targets in delegates as well as any in the subordinate task itself.  Note that
adding a target to the Master would then automatically "include" that as a new
target in every subordinate script.

Many simplifying assumptions could be made to reduce the scope of a task like
this and make implementation more feasible, including:
 - <delegate> is only allowed outside of a <target>
 - any <target>s after a <delegate> are ignored
 - arguments to <delegate> match those in <ant> (except that target="" is not
allowed)

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org