ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wheleph <whel...@gmail.com>
Subject Making listener visible to Ant
Date Thu, 10 Jul 2008 11:01:48 GMT

Hello everyone.
I've created my own listener CustomXmlLogger that is a child of XmlLogger
and packed it in VCS.jar. I don't want to copy it to ANT_HOME/lib so I tried
to include a reference to the archive in my Ant call.
But I've got a problem. When I launch a build Ant indicates on LinkageError:

"C:\Program files\Java\jdk1.5.0_08\bin\java.exe" -classpath
 c:\bin\apache-ant-1.7.0\lib\ant-launcher.jar;VCS.jar
-DXmlLogger.file=build_tes
t_log.xml -DXmlLogger.level=WARN -Dant.home=c:\bin\apache-ant-1.7.0
org.apache.t
ools.ant.launch.Launcher -listener
com.kvazarmicro.umc.vcs.utils.CustomXmlLogger

Buildfile: build.xml

BUILD FAILED
Class com.kvazarmicro.umc.vcs.utils.CustomXmlLogger could not be loaded
because
of an invalid dependency.

When I added ant.jar the error was different:
D:\home\UMC\.garbage>"C:\Program files\Java\jdk1.5.0_08\bin\java.exe"
-classpath

c:\bin\apache-ant-1.7.0\lib\ant-launcher.jar;c:\bin\apache-ant-1.7.0\lib\ant.jar;VCS.jar
-DXmlLogger.file=build_test_log.xml -DXmlLogger.level=WARN -Dant.home=
c:\bin\apache-ant-1.7.0 org.apache.tools.ant.launch.Launcher -listener
com.kvazarmicro.umc.vcs.utils.CustomXmlLogger
Buildfile: build.xml

test:
   [delete] Deleting directory D:\home\UMC\.garbage\build
    [mkdir] Created dir: D:\home\UMC\.garbage\build
    [javac] Compiling 1 source file to D:\home\UMC\.garbage\build

BUILD FAILED
D:\home\UMC\.garbage\build.xml:14: Unable to find a javac compiler;
com.sun.tools.javac.Main is not on the classpath.
Perhaps JAVA_HOME does not point to the JDK.
It is currently set to "C:\Program files\Java\jdk1.5.0_08\jre"

My JAVA_HOME is set to "C:\Program files\Java\jdk1.5.0_08" and Ant finds
compiler perfectly if I don't use my listener.

So I have a question: how can I use a custom listener not copying it in
ANT_HOME/lib?

Source of the listener:
import org.apache.tools.ant.BuildEvent;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.XmlLogger;

public class CustomXmlLogger extends XmlLogger {
	@Override
	public void buildStarted(BuildEvent event) {
		super.buildStarted(event);
		String levelStr = System.getProperty("XmlLogger.level");
		if (levelStr != null) {
			int level;
			if (levelStr.equalsIgnoreCase("ERR")) {
				level = Project.MSG_ERR;
			} else if (levelStr.equalsIgnoreCase("WARN")) {
				level = Project.MSG_WARN;
			} else if (levelStr.equalsIgnoreCase("INFO")) {
				level = Project.MSG_INFO;
			} else if (levelStr.equalsIgnoreCase("VERBOSE")) {
				level = Project.MSG_VERBOSE;
			} else {
				level = Project.MSG_DEBUG;
			}
			setMessageOutputLevel(level);
		}
	}
}
-- 
View this message in context: http://www.nabble.com/Making-listener-visible-to-Ant-tp18380479p18380479.html
Sent from the Ant - Dev mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message