Package org.apache.tools.ant

Examples of org.apache.tools.ant.RuntimeConfigurable$EnableAttributeConsumer


                Path classpath = getClasspath() != null ? getClasspath() : new Path(getProject());
                // extract joint options, some get pushed up...
                List<String> jointOptions = new ArrayList<String>();
                if (jointCompilation) {
                    RuntimeConfigurable rc = javac.getRuntimeConfigurableWrapper();
                    for (Iterator i = rc.getAttributeMap().entrySet().iterator(); i.hasNext();) {
                        final Map.Entry e = (Map.Entry) i.next();
                        final String key = e.getKey().toString();
                        final String value = getProject().replaceProperties(e.getValue().toString());
                        if (key.contains("debug")) {
                            String level = "";
                            if (javac.getDebugLevel() != null) {
                                level = ":" + javac.getDebugLevel();
                            }
                            jointOptions.add("-Fg" + level);
                        } else if (key.contains("debugLevel")) {
                            // ignore, taken care of in debug
                        } else if ((key.contains("nowarn"))
                                || (key.contains("verbose"))
                                || (key.contains("deprecation"))) {
                            // false is default, so something to do only in true case
                            if ("on".equalsIgnoreCase(value) || "true".equalsIgnoreCase(value) || "yes".equalsIgnoreCase("value"))
                                jointOptions.add("-F" + key);
                        } else if (key.contains("classpath")) {
                            classpath.add(javac.getClasspath());
                        } else if ((key.contains("depend"))
                                || (key.contains("extdirs"))
                                || (key.contains("encoding"))
                                || (key.contains("source"))
                                || (key.contains("target"))
                                || (key.contains("verbose"))) { // TODO remove extra verbose?
                            jointOptions.add("-J" + key + "=" + value);
                        } else {
                            log("The option " + key + " cannot be set on the contained <javac> element. The option will be ignored", Project.MSG_WARN);
                        }
                        // includes? excludes?
                    }
                    // ant's <javac> supports nested <compilerarg value=""> elements (there can be multiple of them)
                    // for additional options to be passed to javac.
                    Enumeration children = rc.getChildren();
                    while (children.hasMoreElements()) {
                        RuntimeConfigurable childrc = (RuntimeConfigurable) children.nextElement();
                        if (childrc.getElementTag().equals("compilerarg")) {
                            for (Iterator i = childrc.getAttributeMap().entrySet().iterator(); i.hasNext();) {
                                final Map.Entry e = (Map.Entry) i.next();
                                final String key = e.getKey().toString();
                                if (key.equals("value")) {
                                    final String value = getProject().replaceProperties(e.getValue().toString());
                                    StringTokenizer st = new StringTokenizer(value, " ");
View Full Code Here


         * @exception SAXParseException in case of error (not thrown in
         *                              this implementation)
         */
        public void onStartElement(String uri, String tag, String qname, Attributes attrs,
                                   AntXMLContext context) throws SAXParseException {
            RuntimeConfigurable parentWrapper = context.currentWrapper();
            Object parent = null;

            if (parentWrapper != null) {
                parent = parentWrapper.getProxy();
            }

            /* UnknownElement is used for tasks and data types - with
               delayed eval */
            UnknownElement task = new UnknownElement(tag);
            task.setProject(context.getProject());
            task.setNamespace(uri);
            task.setQName(qname);
            task.setTaskType(ProjectHelper.genComponentName(task.getNamespace(), tag));
            task.setTaskName(qname);

            Location location = new Location(context.getLocator().getSystemId(), context
                                             .getLocator().getLineNumber(), context.getLocator().getColumnNumber());
            task.setLocation(location);
            task.setOwningTarget(context.getCurrentTarget());

            if (parent != null) {
                // Nested element
                ((UnknownElement) parent).addChild(task);
            else {
                // Task included in a target ( including the default one ).
                context.getCurrentTarget().addTask(task);
            }

            context.configureId(task, attrs);

            // container.addTask(task);
            // This is a nop in UE: task.init();

            RuntimeConfigurable wrapper = new RuntimeConfigurable(task, task.getTaskName());

            for (int i = 0; i < attrs.getLength(); i++) {
                String name = attrs.getLocalName(i);
                String attrUri = attrs.getURI(i);
                if (attrUri != null && !attrUri.equals("") && !attrUri.equals(uri)) {
                    name = attrUri + ":" + attrs.getQName(i);
                }
                String value = attrs.getValue(i);
                // PR: Hack for ant-type value
                //  an ant-type is a component name which can
                // be namespaced, need to extract the name
                // and convert from qualified name to uri/name
                if (ANT_TYPE.equals(name)
                    || (ANT_CORE_URI.equals(attrUri)
                        && ANT_TYPE.equals(attrs.getLocalName(i)))) {
                    name = ANT_TYPE;
                    int index = value.indexOf(":");
                    if (index >= 0) {
                        String prefix = value.substring(0, index);
                        String mappedUri = context.getPrefixMapping(prefix);
                        if (mappedUri == null) {
                            throw new BuildException("Unable to find XML NS prefix \"" + prefix
                                                     + "\"");
                        }
                        value = ProjectHelper.genComponentName(mappedUri, value
                                                               .substring(index + 1));
                    }
                }
                wrapper.setAttribute(name, value);
            }
            if (parentWrapper != null) {
                parentWrapper.addChild(wrapper);
            }
            context.pushWrapper(wrapper);
View Full Code Here

         *
         * @see ProjectHelper#addText(Project,java.lang.Object,char[],int,int)
         */
        public void characters(char[] buf, int start, int count,
                               AntXMLContext context) throws SAXParseException {
            RuntimeConfigurable wrapper = context.currentWrapper();
            wrapper.addText(buf, start, count);
        }
View Full Code Here

            t.setProject(getProject());
            ret.setOwningTarget(t);
        } else {
            ret.setOwningTarget(getOwningTarget());
        }
        RuntimeConfigurable rc = new RuntimeConfigurable(
            ret, ue.getTaskName());
        rc.setPolyType(ue.getWrapper().getPolyType());
        Map m = ue.getWrapper().getAttributeMap();
        for (Iterator i = m.entrySet().iterator(); i.hasNext();) {
            Map.Entry entry = (Map.Entry) i.next();
            rc.setAttribute(
                (String) entry.getKey(),
                macroSubs((String) entry.getValue(), localAttributes));
        }
        rc.addText(macroSubs(ue.getWrapper().getText().toString(),
                             localAttributes));

        Enumeration e = ue.getWrapper().getChildren();
        while (e.hasMoreElements()) {
            RuntimeConfigurable r = (RuntimeConfigurable) e.nextElement();
            UnknownElement unknownElement = (UnknownElement) r.getProxy();
            String tag = unknownElement.getTaskType();
            if (tag != null) {
                tag = tag.toLowerCase(Locale.US);
            }
            MacroDef.TemplateElement templateElement =
View Full Code Here

     * @param el the element this attribute is in.
     * @return a map of attributes.
     */
    protected Map getParams(UnknownElement el) {
        Map ret = new HashMap();
        RuntimeConfigurable rc = el.getWrapper();
        Map attributes = rc.getAttributeMap(); // This does a copy!
        for (Iterator i = attributes.entrySet().iterator(); i.hasNext();) {
            Map.Entry entry = (Map.Entry) i.next();
            String key = (String) entry.getKey();
            String value = (String) entry.getValue();
            if (key.startsWith("ant-attribute:param")) {
View Full Code Here

                }

                helperImpl.configureId(child, attrs);

                if (parentWrapper != null) {
                    childWrapper = new RuntimeConfigurable(child, propType);
                    childWrapper.setAttributes(attrs);
                    parentWrapper.addChild(childWrapper);
                } else {
                    configure(child, attrs, helperImpl.project);
                    ih.storeElement(helperImpl.project, parent, child, elementName);
View Full Code Here

                if (element == null) {
                    throw new BuildException("Unknown data type " + propType);
                }

                if (target != null) {
                    wrapper = new RuntimeConfigurable(element, propType);
                    wrapper.setAttributes(attrs);
                    target.addDataType(wrapper);
                } else {
                    configure(element, attrs, helperImpl.project);
                    helperImpl.configureId(element, attrs);
View Full Code Here

            t.setProject(getProject());
            ret.setOwningTarget(t);
        } else {
            ret.setOwningTarget(getOwningTarget());
        }
        RuntimeConfigurable rc = new RuntimeConfigurable(
            ret, ue.getTaskName());
        rc.setPolyType(ue.getWrapper().getPolyType());
        Map map = ue.getWrapper().getAttributeMap();
        for (Iterator i = map.entrySet().iterator(); i.hasNext();) {
            Map.Entry entry = (Map.Entry) i.next();
            rc.setAttribute(
                (String) entry.getKey(),
                macroSubs((String) entry.getValue(), localProperties));
        }
        rc.addText(macroSubs(ue.getWrapper().getText().toString(),
                             localProperties));

        Enumeration e = ue.getWrapper().getChildren();
        while (e.hasMoreElements()) {
            RuntimeConfigurable r = (RuntimeConfigurable) e.nextElement();
            UnknownElement unknownElement = (UnknownElement) r.getProxy();
            String tag = unknownElement.getTaskType();
            if (tag != null) {
                tag = tag.toLowerCase(Locale.US);
            }
            MacroDef.TemplateElement templateElement =
View Full Code Here

                    child = ih.createElement(helperImpl.project, parent, elementName);
                }

                helperImpl.configureId(child, attrs);

                childWrapper = new RuntimeConfigurable(child, propType);
                childWrapper.setAttributes(attrs);
                parentWrapper.addChild(childWrapper);
            } catch (BuildException exc) {
                throw new SAXParseException(exc.getMessage(), helperImpl.locator, exc);
            }
View Full Code Here

                element = helperImpl.project.createDataType(propType);
                if (element == null) {
                    throw new BuildException("Unknown data type " + propType);
                }

                wrapper = new RuntimeConfigurable(element, propType);
                wrapper.setAttributes(attrs);
                target.addDataType(wrapper);
            } catch (BuildException exc) {
                throw new SAXParseException(exc.getMessage(), helperImpl.locator, exc);
            }
View Full Code Here

TOP

Related Classes of org.apache.tools.ant.RuntimeConfigurable$EnableAttributeConsumer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.