ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 34458] - <macrodef> with an embedded reference and <*ant*> conflict
Date Tue, 19 Jul 2005 14:22:52 GMT
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=34458>.
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=34458





------- Additional Comments From ddevienne@lgc.com  2005-07-19 16:22 -------
The class is indeed not compilable as is, but is easy to fix to not use the 
code you are missing. The custom Sequential is just the regular Ant Sequential 
with conditional added, including the isActive() method. Simple extend Ant's 
Sequential, is remove the test on isActive().

As for TaskUtils, here are the relevant methods. --DD

    /**
     * Asserts a given object is not <code>null</code>.
     *
     * @param  o the object reference that should not be <code>null</code>.
     * @param  name the object's name, for error reporting.
     * @throws IllegalArgumentException with message "Null 'name'", where
     *         name is replaced by the provided <code>name</code>, if the
     *         reference is <code>null</code>.
     */
    public static void assertNotNull(Object o, String name)
                       throws IllegalArgumentException {
        if (o == null) {
            throw new IllegalArgumentException("Null '" + name +"'");
        }
    }

    /**
     * Asserts a given string is neither <code>null</code>, nor empty.
     * <p>
     * <em>Note that the string is {@link String#trim trimmed} before being
     * tested, so string made up of spaces only will fail this assertion!</em>
     *
     * @param  s the string that should be neither <code>null</code> nor empty.
     * @param  name the object's name, for error reporting.
     * @param  trim whether to trim the string before testing for emptyness.
     * @return the input string, or a new trimmed string if <code>trim</code>
     *         was <code>true</code> and spaces were effectively removed.
     * @throws IllegalArgumentException if (1) s is <code>null</code>,
     *         with message "Null 'name'", where name is replaced by the
     *         provided <code>name</code>, (2) s is empty, with message
     *         "Empty 'name'".
     */
    public static String assertNotEmpty(String s, String name, boolean trim)
                         throws IllegalArgumentException {
        assertNotNull(s, name);
        if (trim) {
            s = s.trim();
        }
        if (s.length() < 1) {
            throw new IllegalArgumentException("Empty '" + name +"'");
        }
        return s;
    }

    /**
     * Asserts a given Ant task/type attribute was set.
     * <p>
     * Typically used at the beginning of a task's execute() method
     * to check all its required attributes have been set.
     *
     * @param  attr the attribute's object reference.
     * @param  name the attribute's name, for error reporting.
     * @throws BuildException with message "Missing 'name' attribute!",
     *         where name is replaced by the provided <code>name</code>.
     *
     * @see #assertAttributeNotSet
     */
    public static void assertAttributeSet(Object attr, String name)
                  throws BuildException {
        if (attr == null) {
            throw new BuildException("Missing '" + name +"' attribute!");
        }
    }

    /**
     * Asserts a given Ant task/type attribute was not set,
     * usually because another attribute or nested element is set/present.
     *
     * @param  attr the attribute's object reference.
     * @param  name the attribute's name, for error reporting.
     * @param  incompatibleWith the thing (another attribute, or a nested
     *         element) the attribute tested is incompatible with.
     * @throws BuildException with message "Attribute 'name' incompatibleWith
     *         ...", where name is replaced by the provided <code>name</code>,
     *         and ... replaced with <code>incompatibleWith</code>.
     *
     * @see #assertAttributeSet
     */
    public static void assertAttributeNotSet(Object attr, String name,
                                             String incompatibleWith)
                       throws BuildException {
        if (attr != null) {
            throw new BuildException("Attribute '" + name +
                                     "' incompatible with " + incompatibleWith);
        }
    }

    /**
     * Asserts a given Ant task/type nested element was set.
     * <p>
     * Typically used at the beginning of a task's execute() method
     * to check all its required nested elements have been set.
     *
     * @param  elem the element's object reference.
     * @param  name the element's name, for error reporting.
     * @throws BuildException with message "Missing 'name' nested element!",
     *         where name is replaced by the provided <code>name</code>.
     *
     * @see #assertAttributeNotSet
     */
    public static void assertElementSet(Object elem, String name)
                  throws BuildException {
        if (elem == null) {
            throw new BuildException("Missing <" + name +"> nested element!");
        }
    }

    /**
     * Asserts a given reference doesn't already exist in this Ant project.
     *
     * @param  component the component from which to extract the Ant project
     * @param  refName the reference name/id that should not be found.
     * @throws BuildException with message "Reference 'refName' already set!".
     */
    public static void assertReferenceNotSet(ProjectComponent component,
                                             String refName) {
        if (component.getProject().getReference(refName) != null) {
            throw new BuildException("Reference '" + refName +
                                     "' already set!");
        }
    }

    /**
     * Asserts a given property doesn't already exist in this project.
     *
     * @param  component the component from which to extract the Ant project
     * @param  propName the property name that should not be found.
     * @throws BuildException with message "Property 'propName' already set!".
     */
    public static void assertPropertyNotSet(ProjectComponent component,
                                            String propName) {
        if (component.getProject().getProperty(propName) != null) {
            throw new BuildException("Property '" + propName +
                                     "' already set!");
        }
    }


-- 
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


Mime
View raw message