use of org.apache.tools.ant.BuildEvent in project ant by apache.
the class JUnitLauncherTaskTest method setUp.
/**
* The JUnit setup method.
*/
@Before
public void setUp() {
File antFile = new File(System.getProperty("root"), "src/etc/testcases/taskdefs/optional/junitlauncher.xml");
this.project = new Project();
this.project.init();
ProjectHelper.configureProject(project, antFile);
project.addBuildListener(new BuildListener() {
@Override
public void buildStarted(final BuildEvent event) {
}
@Override
public void buildFinished(final BuildEvent event) {
}
@Override
public void targetStarted(final BuildEvent event) {
}
@Override
public void targetFinished(final BuildEvent event) {
}
@Override
public void taskStarted(final BuildEvent event) {
}
@Override
public void taskFinished(final BuildEvent event) {
}
@Override
public void messageLogged(final BuildEvent event) {
if (event.getPriority() <= Project.MSG_INFO) {
System.out.println(event.getMessage());
}
}
});
}
use of org.apache.tools.ant.BuildEvent in project ceylon by eclipse.
the class Util method getCeylonClassLoaderCachedInProject.
public static CeylonClassLoader getCeylonClassLoaderCachedInProject(final Project project) throws ClassLoaderSetupException {
Object classLoader = project.getReference(CEYLON_CLASSLOADER_REFERENCE);
if (classLoader != null) {
CeylonClassLoader oldLoader = (CeylonClassLoader) classLoader;
// make sure it's still valid
try {
List<File> classPath = CeylonClassLoader.getClassPath();
if (oldLoader.hasSignature(CeylonClassLoader.getClassPathSignature(classPath))) {
// compatible
return oldLoader;
} else {
project.log("Needs a new class loader: cp changed!", Project.MSG_VERBOSE);
CeylonClassLoader loader = CeylonClassLoader.newInstance(classPath);
project.addReference(CEYLON_CLASSLOADER_REFERENCE, loader);
return loader;
}
} catch (FileNotFoundException x) {
throw new ClassLoaderSetupException(x);
} catch (URISyntaxException x) {
throw new ClassLoaderSetupException(x);
} catch (MalformedURLException x) {
throw new ClassLoaderSetupException(x);
}
}
CeylonClassLoader loader = Launcher.getClassLoader();
project.addReference(CEYLON_CLASSLOADER_REFERENCE, loader);
// only add the build listed once, even if we change the class loader later
project.addBuildListener(new BuildListener() {
@Override
public void buildFinished(BuildEvent arg0) {
project.log("Build done, cleaning up Ceylon class loader", Project.MSG_VERBOSE);
// make sure we get the latest one
Object reference = project.getReference(CEYLON_CLASSLOADER_REFERENCE);
project.getReferences().remove(CEYLON_CLASSLOADER_REFERENCE);
if (reference instanceof CeylonClassLoader) {
try {
((CeylonClassLoader) reference).close();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}
@Override
public void buildStarted(BuildEvent arg0) {
}
@Override
public void messageLogged(BuildEvent arg0) {
}
@Override
public void targetFinished(BuildEvent arg0) {
}
@Override
public void targetStarted(BuildEvent arg0) {
}
@Override
public void taskFinished(BuildEvent arg0) {
}
@Override
public void taskStarted(BuildEvent arg0) {
}
});
return loader;
}
use of org.apache.tools.ant.BuildEvent in project ant-ivy by apache.
the class AntMessageLogger method register.
/**
* Creates and register an {@link AntMessageLogger} for the given {@link Task}, with the given
* {@link Ivy} instance.
* <p>
* The created instance will automatically be unregistered from the Ivy instance when the task
* finishes.
* </p>
*
* @param task
* the task the logger should use for logging
* @param ivy
* the ivy instance on which the logger should be registered
*/
public static void register(ProjectComponent task, final Ivy ivy) {
MessageLogger current = ivy.getLoggerEngine().peekLogger();
if (current instanceof AntMessageLogger && task instanceof Task && ((AntMessageLogger) current).task instanceof Task) {
Task currentTask = (Task) ((AntMessageLogger) current).task;
if (currentTask.getTaskName() != null && currentTask.getTaskName().equals(((Task) task).getTaskName())) {
// prefix as the given task. So we shouldn't do anything...
return;
}
}
AntMessageLogger logger = new AntMessageLogger(task);
ivy.getLoggerEngine().pushLogger(logger);
task.getProject().addBuildListener(new BuildListener() {
private int stackDepth = 0;
public void buildFinished(BuildEvent event) {
}
public void buildStarted(BuildEvent event) {
}
public void targetStarted(BuildEvent event) {
}
public void targetFinished(BuildEvent event) {
}
public void taskStarted(BuildEvent event) {
stackDepth++;
}
public void taskFinished(BuildEvent event) {
// NB: There is sometimes task created by an other task
// in that case, we should not uninit Message. The log should stay associated
// with the initial task, except if it was an antcall, ant or subant target
// NB2 : Testing the identity of the task is not enough, event.getTask() return
// an instance of UnknownElement is wrapping the concrete instance
stackDepth--;
if (stackDepth == -1) {
ivy.getLoggerEngine().popLogger();
event.getProject().removeBuildListener(this);
}
}
public void messageLogged(BuildEvent event) {
}
});
}
use of org.apache.tools.ant.BuildEvent in project mdw-designer by CenturyLinkCloud.
the class AntBuilder method fireBuildStarted.
/*
* We only have to do this because Project.fireBuildStarted is protected. If
* it becomes public we should remove this and call the appropriate method.
*/
@SuppressWarnings("rawtypes")
private void fireBuildStarted(Project project) {
BuildEvent event = new BuildEvent(project);
for (Iterator i = project.getBuildListeners().iterator(); i.hasNext(); ) {
BuildListener listener = (BuildListener) i.next();
listener.buildStarted(event);
}
}
use of org.apache.tools.ant.BuildEvent in project ceylon-compiler by ceylon.
the class Util method getCeylonClassLoaderCachedInProject.
public static CeylonClassLoader getCeylonClassLoaderCachedInProject(final Project project) throws ClassLoaderSetupException {
Object classLoader = project.getReference(CEYLON_CLASSLOADER_REFERENCE);
if (classLoader != null) {
CeylonClassLoader oldLoader = (CeylonClassLoader) classLoader;
// make sure it's still valid
try {
List<File> classPath = CeylonClassLoader.getClassPath();
if (oldLoader.hasSignature(CeylonClassLoader.getClassPathSignature(classPath))) {
// compatible
return oldLoader;
} else {
project.log("Needs a new class loader: cp changed!", Project.MSG_VERBOSE);
CeylonClassLoader loader = CeylonClassLoader.newInstance(classPath);
project.addReference(CEYLON_CLASSLOADER_REFERENCE, loader);
return loader;
}
} catch (FileNotFoundException x) {
throw new ClassLoaderSetupException(x);
} catch (URISyntaxException x) {
throw new ClassLoaderSetupException(x);
} catch (MalformedURLException x) {
throw new ClassLoaderSetupException(x);
}
}
CeylonClassLoader loader = Launcher.getClassLoader();
project.addReference(CEYLON_CLASSLOADER_REFERENCE, loader);
// only add the build listed once, even if we change the class loader later
project.addBuildListener(new BuildListener() {
@Override
public void buildFinished(BuildEvent arg0) {
project.log("Build done, cleaning up Ceylon class loader", Project.MSG_VERBOSE);
// make sure we get the latest one
Object reference = project.getReference(CEYLON_CLASSLOADER_REFERENCE);
project.getReferences().remove(CEYLON_CLASSLOADER_REFERENCE);
if (reference instanceof CeylonClassLoader) {
((CeylonClassLoader) reference).clearCache();
}
}
@Override
public void buildStarted(BuildEvent arg0) {
}
@Override
public void messageLogged(BuildEvent arg0) {
}
@Override
public void targetFinished(BuildEvent arg0) {
}
@Override
public void targetStarted(BuildEvent arg0) {
}
@Override
public void taskFinished(BuildEvent arg0) {
}
@Override
public void taskStarted(BuildEvent arg0) {
}
});
return loader;
}
Aggregations