Search in sources :

Example 1 with Task

use of org.apache.tools.ant.Task in project flyway by flyway.

the class AntLog method error.

public void error(String message) {
    Project antProject = AntLogCreator.INSTANCE.getAntProject();
    Task task = antProject.getThreadTask(Thread.currentThread());
    antProject.log(task, message, Project.MSG_ERR);
}
Also used : Project(org.apache.tools.ant.Project) Task(org.apache.tools.ant.Task)

Example 2 with Task

use of org.apache.tools.ant.Task in project groovy-core by groovy.

the class SpoofTaskContainer method execute.

public void execute() throws BuildException {
    spoof("begin SpoofTaskContainer execute");
    for (Iterator iter = tasks.iterator(); iter.hasNext(); ) {
        Task task = (Task) iter.next();
        task.perform();
    }
    spoof("end SpoofTaskContainer execute");
}
Also used : Task(org.apache.tools.ant.Task) Iterator(java.util.Iterator)

Example 3 with Task

use of org.apache.tools.ant.Task in project poi by apache.

the class ExcelAntTest method execute.

@Override
public void execute() throws BuildException {
    Iterator<Task> taskIt = testTasks.iterator();
    int testCount = evaluators.size();
    int failureCount = 0;
    // ordering of the sub elements to be considered. 
    while (taskIt.hasNext()) {
        Task task = taskIt.next();
        if (task instanceof ExcelAntSet) {
            ExcelAntSet set = (ExcelAntSet) task;
            set.setWorkbookUtil(workbookUtil);
            set.execute();
        }
        if (task instanceof ExcelAntHandlerTask) {
            ExcelAntHandlerTask handler = (ExcelAntHandlerTask) task;
            handler.setEAWorkbookUtil(workbookUtil);
            handler.execute();
        }
        if (task instanceof ExcelAntEvaluateCell) {
            ExcelAntEvaluateCell eval = (ExcelAntEvaluateCell) task;
            eval.setWorkbookUtil(workbookUtil);
            if (globalPrecision > 0) {
                log("setting globalPrecision to " + globalPrecision + " in the evaluator", Project.MSG_VERBOSE);
                eval.setGlobalPrecision(globalPrecision);
            }
            try {
                eval.execute();
                ExcelAntEvaluationResult result = eval.getResult();
                if (result.didTestPass() && !result.evaluationCompleteWithError()) {
                    if (showSuccessDetails) {
                        log("Succeeded when evaluating " + result.getCellName() + ".  It evaluated to " + result.getReturnValue() + " when the value of " + eval.getExpectedValue() + " with precision of " + eval.getPrecision(), Project.MSG_INFO);
                    }
                } else {
                    if (showFailureDetail) {
                        failureMessages.add("\tFailed to evaluate cell " + result.getCellName() + ".  It evaluated to " + result.getReturnValue() + " when the value of " + eval.getExpectedValue() + " with precision of " + eval.getPrecision() + " was expected.");
                    }
                    passed = false;
                    failureCount++;
                    if (eval.requiredToPass()) {
                        throw new BuildException("\tFailed to evaluate cell " + result.getCellName() + ".  It evaluated to " + result.getReturnValue() + " when the value of " + eval.getExpectedValue() + " with precision of " + eval.getPrecision() + " was expected.");
                    }
                }
            } catch (NullPointerException npe) {
                // this means the cell reference in the test is bad.
                log("Cell assignment " + eval.getCell() + " in test " + getName() + " appears to point to an empy cell.  Please check the " + " reference in the ant script.", Project.MSG_ERR);
            }
        }
    }
    if (!passed) {
        log("Test named " + name + " failed because " + failureCount + " of " + testCount + " evaluations failed to " + "evaluate correctly.", Project.MSG_ERR);
        if (showFailureDetail && failureMessages.size() > 0) {
            for (String failureMessage : failureMessages) {
                log(failureMessage, Project.MSG_ERR);
            }
        }
    }
}
Also used : Task(org.apache.tools.ant.Task) BuildException(org.apache.tools.ant.BuildException) ExcelAntEvaluationResult(org.apache.poi.ss.excelant.util.ExcelAntEvaluationResult)

Example 4 with Task

use of org.apache.tools.ant.Task in project intellij-community by JetBrains.

the class AntDomExtender method registerExtensions.

public void registerExtensions(@NotNull final AntDomElement antDomElement, @NotNull DomExtensionsRegistrar registrar) {
    final XmlElement xmlElement = antDomElement.getXmlElement();
    if (xmlElement instanceof XmlTag) {
        final XmlTag xmlTag = (XmlTag) xmlElement;
        final String tagName = xmlTag.getName();
        final AntDomProject antProject = antDomElement.getAntProject();
        if (antProject == null) {
            return;
        }
        final ReflectedProject reflected = ReflectedProject.getProject(antProject.getClassLoader());
        if (reflected.getProject() == null) {
            return;
        }
        final DomGenericInfo genericInfo = antDomElement.getGenericInfo();
        AntIntrospector classBasedIntrospector = null;
        final Hashtable<String, Class> coreTaskDefs = reflected.getTaskDefinitions();
        final Hashtable<String, Class> coreTypeDefs = reflected.getDataTypeDefinitions();
        final boolean isCustom = antDomElement instanceof AntDomCustomElement;
        if ("project".equals(tagName)) {
            classBasedIntrospector = getIntrospector(reflected.getProject().getClass());
        } else if ("target".equals(tagName)) {
            classBasedIntrospector = getIntrospector(reflected.getTargetClass());
        } else {
            if (isCustom) {
                final AntDomCustomElement custom = (AntDomCustomElement) antDomElement;
                final Class definitionClass = custom.getDefinitionClass();
                if (definitionClass != null) {
                    classBasedIntrospector = getIntrospector(definitionClass);
                }
            } else {
                Class elemType = antDomElement.getChildDescription().getUserData(ELEMENT_IMPL_CLASS_KEY);
                if (elemType == null) {
                    if (coreTaskDefs != null) {
                        elemType = coreTaskDefs.get(tagName);
                    }
                }
                if (elemType == null) {
                    if (coreTypeDefs != null) {
                        elemType = coreTypeDefs.get(tagName);
                    }
                }
                if (elemType != null) {
                    classBasedIntrospector = getIntrospector(elemType);
                }
            }
        }
        AbstractIntrospector parentIntrospector = null;
        if (classBasedIntrospector != null) {
            parentIntrospector = new ClassIntrospectorAdapter(classBasedIntrospector, coreTaskDefs, coreTypeDefs);
        } else {
            if (isCustom) {
                final AntDomNamedElement declaringElement = ((AntDomCustomElement) antDomElement).getDeclaringElement();
                if (declaringElement instanceof AntDomMacroDef) {
                    parentIntrospector = new MacrodefIntrospectorAdapter((AntDomMacroDef) declaringElement);
                } else if (declaringElement instanceof AntDomMacrodefElement) {
                    parentIntrospector = new MacrodefElementOccurrenceIntrospectorAdapter((AntDomMacrodefElement) declaringElement);
                } else if (declaringElement instanceof AntDomScriptDef) {
                    parentIntrospector = new ScriptdefIntrospectorAdapter((AntDomScriptDef) declaringElement);
                }
            }
        }
        if (parentIntrospector != null) {
            defineAttributes(xmlTag, registrar, genericInfo, parentIntrospector);
            if ("project".equals(tagName) || parentIntrospector.isContainer()) {
                // can contain any task or/and type definition
                if (coreTaskDefs != null) {
                    for (Map.Entry<String, Class> entry : coreTaskDefs.entrySet()) {
                        final DomExtension extension = registerChild(registrar, genericInfo, entry.getKey());
                        if (extension != null) {
                            final Class type = entry.getValue();
                            if (type != null) {
                                extension.putUserData(ELEMENT_IMPL_CLASS_KEY, type);
                            }
                            extension.putUserData(AntDomElement.ROLE, AntDomElement.Role.TASK);
                        }
                    }
                }
                if (coreTypeDefs != null) {
                    for (Map.Entry<String, Class> entry : coreTypeDefs.entrySet()) {
                        final DomExtension extension = registerChild(registrar, genericInfo, entry.getKey());
                        if (extension != null) {
                            final Class type = entry.getValue();
                            if (type != null) {
                                extension.putUserData(ELEMENT_IMPL_CLASS_KEY, type);
                            }
                            extension.putUserData(AntDomElement.ROLE, AntDomElement.Role.DATA_TYPE);
                        }
                    }
                }
                registrar.registerCustomChildrenExtension(AntDomCustomElement.class, new AntCustomTagNameDescriptor());
            } else {
                final Iterator<String> nested = parentIntrospector.getNestedElementsIterator();
                while (nested.hasNext()) {
                    final String nestedElementName = nested.next();
                    final DomExtension extension = registerChild(registrar, genericInfo, nestedElementName);
                    if (extension != null) {
                        Class type = parentIntrospector.getNestedElementType(nestedElementName);
                        if (type != null && CommonClassNames.JAVA_LANG_OBJECT.equals(type.getName())) {
                            // hack to support badly written tasks 
                            type = null;
                        }
                        if (type == null) {
                            if (coreTypeDefs != null) {
                                type = coreTypeDefs.get(nestedElementName);
                            }
                        }
                        if (type != null) {
                            extension.putUserData(ELEMENT_IMPL_CLASS_KEY, type);
                        }
                        AntDomElement.Role role = AntDomElement.Role.DATA_TYPE;
                        if (coreTaskDefs != null && coreTaskDefs.containsKey(nestedElementName)) {
                            role = AntDomElement.Role.TASK;
                        } else if (type != null && isAssignableFrom(Task.class.getName(), type)) {
                            role = AntDomElement.Role.TASK;
                        }
                        if (role != null) {
                            extension.putUserData(AntDomElement.ROLE, role);
                        }
                    }
                }
                registrar.registerCustomChildrenExtension(AntDomCustomElement.class, new AntCustomTagNameDescriptor());
            }
        }
    }
}
Also used : Task(org.apache.tools.ant.Task) ReflectedProject(com.intellij.lang.ant.ReflectedProject) AntIntrospector(com.intellij.lang.ant.AntIntrospector) XmlElement(com.intellij.psi.xml.XmlElement) XmlTag(com.intellij.psi.xml.XmlTag)

Example 5 with Task

use of org.apache.tools.ant.Task in project che by eclipse.

the class AntBuildListener method messageLogged.

@Override
public void messageLogged(BuildEvent event) {
    final Target target = event.getTarget();
    final Task task = event.getTask();
    final String text = event.getMessage();
    send(new AntMessage(AntMessage.BUILD_LOG, target == null ? null : target.getName(), task == null ? null : task.getTaskName(), text));
}
Also used : Target(org.apache.tools.ant.Target) Task(org.apache.tools.ant.Task)

Aggregations

Task (org.apache.tools.ant.Task)12 Project (org.apache.tools.ant.Project)5 Iterator (java.util.Iterator)2 AntIntrospector (com.intellij.lang.ant.AntIntrospector)1 ReflectedProject (com.intellij.lang.ant.ReflectedProject)1 XmlElement (com.intellij.psi.xml.XmlElement)1 XmlTag (com.intellij.psi.xml.XmlTag)1 Field (java.lang.reflect.Field)1 ExcelAntEvaluationResult (org.apache.poi.ss.excelant.util.ExcelAntEvaluationResult)1 BuildException (org.apache.tools.ant.BuildException)1 Target (org.apache.tools.ant.Target)1