use of org.apache.tools.ant.UnknownElement in project ant by apache.
the class CommonsLoggingListener method taskStarted.
/**
* @see BuildListener#taskStarted
* {@inheritDoc}.
*/
@Override
public void taskStarted(final BuildEvent event) {
if (initialized) {
final Task task = event.getTask();
Object real = task;
if (task instanceof UnknownElement) {
final Object realObj = ((UnknownElement) task).getTask();
if (realObj != null) {
real = realObj;
}
}
final Log log = getLog(real.getClass().getName(), null);
if (log.isTraceEnabled()) {
realLog(log, "Task \"" + task.getTaskName() + "\" started ", Project.MSG_VERBOSE, null);
}
}
}
use of org.apache.tools.ant.UnknownElement in project groovy by apache.
the class AntBuilderLocator method performTask.
// Copied from org.apache.tools.ant.Task, since we need to get a real thing before it gets nulled in DispatchUtils.execute
private Object performTask(Task task) {
Throwable reason = null;
try {
// Have to call fireTestStared/fireTestFinished via reflection as they unfortunately have protected access in Project
final Method fireTaskStarted = Project.class.getDeclaredMethod("fireTaskStarted", Task.class);
ReflectionUtils.trySetAccessible(fireTaskStarted);
fireTaskStarted.invoke(project, task);
Object realThing;
realThing = task;
task.maybeConfigure();
if (task instanceof UnknownElement) {
realThing = ((UnknownElement) task).getRealThing();
}
DispatchUtils.execute(task);
return realThing != null ? realThing : task;
} catch (BuildException ex) {
if (ex.getLocation() == Location.UNKNOWN_LOCATION) {
ex.setLocation(task.getLocation());
}
reason = ex;
throw ex;
} catch (Exception ex) {
reason = ex;
BuildException be = new BuildException(ex);
be.setLocation(task.getLocation());
throw be;
} catch (Error ex) {
reason = ex;
throw ex;
} finally {
try {
final Method fireTaskFinished = Project.class.getDeclaredMethod("fireTaskFinished", Task.class, Throwable.class);
ReflectionUtils.trySetAccessible(fireTaskFinished);
fireTaskFinished.invoke(project, task, reason);
} catch (Exception e) {
BuildException be = new BuildException(e);
be.setLocation(task.getLocation());
throw be;
}
}
}
use of org.apache.tools.ant.UnknownElement in project cayenne by apache.
the class DbImporterTaskTest method getCdbImport.
private DbImporterTask getCdbImport(String buildFile) {
Project project = new Project();
File map = distDir(buildFile);
ResourceUtil.copyResourceToFile(getPackagePath() + "/" + buildFile, map);
ProjectHelper.configureProject(project, map);
UnknownElement task = (UnknownElement) project.getTargets().get("dist").getTasks()[0];
task.maybeConfigure();
return (DbImporterTask) task.getRealThing();
}
use of org.apache.tools.ant.UnknownElement in project ant by apache.
the class MacroDef method getNestedTask.
/**
* Convert the nested sequential to an unknown element
* @return the nested sequential as an unknown element.
*/
public UnknownElement getNestedTask() {
UnknownElement ret = new UnknownElement("sequential");
ret.setTaskName("sequential");
ret.setNamespace("");
ret.setQName("sequential");
// stores RuntimeConfigurable as "RuntimeConfigurableWrapper"
// in ret as side effect
// NOSONAR
new RuntimeConfigurable(ret, "sequential");
final int size = nestedSequential.getNested().size();
for (int i = 0; i < size; ++i) {
UnknownElement e = (UnknownElement) nestedSequential.getNested().get(i);
ret.addChild(e);
ret.getWrapper().addChild(e.getWrapper());
}
return ret;
}
use of org.apache.tools.ant.UnknownElement in project ant by apache.
the class MacroInstance method processTasks.
private void processTasks() {
if (implicitTag != null) {
return;
}
for (Task task : unknownElements) {
UnknownElement ue = (UnknownElement) task;
String name = ProjectHelper.extractNameFromComponentName(ue.getTag()).toLowerCase(Locale.ENGLISH);
if (getNsElements().get(name) == null) {
throw new BuildException("unsupported element %s", name);
}
if (presentElements.get(name) != null) {
throw new BuildException("Element %s already present", name);
}
presentElements.put(name, ue);
}
}
Aggregations