You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by bu...@apache.org on 2008/11/12 09:50:40 UTC

DO NOT REPLY [Bug 4752] Make Ant report an error when an undefined property is referenced.

https://issues.apache.org/bugzilla/show_bug.cgi?id=4752





--- Comment #6 from Ville Oikarinen <vi...@oikarinen.org>  2008-11-12 00:50:39 PST ---
Ok, fair enough.

I tried extending PropertyHelper, but I don't know how to make ant use it. Or
at least, it doesn't work so undefined properties don't fail the build.

Here is my class:

package org.oikarinen.ant.strictpropertyhelper;

import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.PropertyHelper;

public class StrictPropertyHelper extends PropertyHelper {

        @Override
        public synchronized Object getUserProperty(String ns, String name) {
                Object property = super.getUserProperty(ns, name);
                if (property == null) { throw new BuildException("Undefined
property: ns=" + ns + ", name="
                                + name); }
                return property;
        }
}

I put the class in ant's own lib directory and added the following to ANT_OPTS:
-Dant.PropertyHelper=org.oikarinen.ant.strictpropertyhelper.StrictPropertyHelper

But this didn't change anything.

The documentation for ant.PropertyHelper says the value is a
ant-reference-name, but I have no idea what this means. What exactly is a
reference and how can I use it to point to my class?

Why isn't the type of the property a fully qualified class name like that of
the org.apache.tools.ant.ProjectHelper property's?

I even tried
-Dorg.apache.tools.ant.ProjectHelper=org.oikarinen.ant.strictpropertyhelper.StrictPropertyHelper

which resulted in ant complaining that my class isn't an instance of
ProjectHelper, which proved at least that my class can be loaded by ant.


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