You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by wheleph <wh...@gmail.com> on 2008/07/10 13:01:48 UTC
Making listener visible to Ant
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
Re: Making listener visible to Ant
Posted by wheleph <wh...@gmail.com>.
Thanks, Stefan.
-lib option works like a charm.
--
View this message in context: http://www.nabble.com/Making-listener-visible-to-Ant-tp18380479p18397932.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
Re: Making listener visible to Ant
Posted by Stefan Bodewig <bo...@apache.org>.
On Thu, 10 Jul 2008, <wh...@gmail.com> wrote:
> 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:
This is because your class references classes from ant.jar that will
not be on the system classloader when you start ant via
>
> "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
while your class is on the system classloader.
Alternatives to ANT_HOME/lib are $HOME/.ant/lib and the -lib command
line argument.
I don't see any other option ATM.
Stefan
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org