Just click on the "Enable code coverage" button at the bottom of the Ant runner config. We've been getting coverage for our Ant-based builds for over a year, now.
Anyway, my build fails if coverage is enabled... with the message like this:
BUILD FAILED C:\TeamCity\buildAgent\work\project\ant-tasks.xml:31: taskdef A class needed by class MergeProperties cannot be found: com/vladium/emma/rt/RT Total time: 1 minute 0 seconds : Process exit code: 1 : Artifacts path coverage.ec not found : Artifacts path coverage.txt not found : Artifacts path coverage not found
The script compiles ant tasts with javac and then uses them with taskdef. It seems that 'javac' task is somehow tweaked so that compiled classes reference emma runtime... Does anyone have an idea how to fix that?
When coverage is enabled TeamCity patches javac task and performes code instrumentation. Then to run instrumented classess a special jar file is required. This jar file is passed transparently to Ant tasks starting tests, but currently it can't do this if you launch compiled custom tasks. I think you can try to add emma.jar in classpath of your taskdef. You can refer to it in Ant script as follows: ${agent.work.dir}/../plugins/coveragePlugin/lib/emma.jar
agent.work.dir property will be provided by TeamCity Ant runner.
-- Pavel Sher Software Developer JetBrains, Inc. http://www.jetbrains.com "Develop with pleasure!"
Anyway, my build fails if coverage is enabled... with the message like this:
>
BUILD FAILED C:\TeamCity\buildAgent\work\project\ant-tasks.xml:31: taskdef A class needed by class MergeProperties cannot be found: com/vladium/emma/rt/RT Total time: 1 minute 0 seconds : Process exit code: 1 : Artifacts path coverage.ec not found : Artifacts path coverage.txt not found : Artifacts path coverage not found
>
The script compiles ant tasts with javac and then uses them with taskdef. It seems that 'javac' task is somehow tweaked and references emma runtime... Does anyone have an idea how to fix that?
I cannot modify all parts of the build that contain ]]> task... I've tried adding emma.jar to global classpath. It passes futher but there is interference with custom Ant tasks:
Custom task creates a new Ant target, adds it to the project and tries to execute it with project.executeTarget()
java.lang.NullPointerException java.lang.NullPointerException at jetbrains.buildServer.agent.ant.patches.ElementPatch.createChild(ElementPatch.java:46) at jetbrains.buildServer.coverage.AntCoverageAdapter.addCoverageProperties(AntCoverageAdapter.java:58) at jetbrains.buildServer.coverage.AntCoverageAdapter.taskStarted(AntCoverageAdapter.java:145) at jetbrains.buildServer.agent.ant.AgentBuildListener$ExtensionsProcessor.taskStarted(AgentBuildListener.java:254) at jetbrains.buildServer.agent.ant.AgentBuildListener.taskStarted(AgentBuildListener.java:142) at org.apache.tools.ant.Project.fireTaskStarted(Project.java:2102) at org.apache.tools.ant.Task.perform(Task.java:344) at org.apache.tools.ant.Target.execute(Target.java:357) at org.apache.tools.ant.Target.performTasks(Target.java:385) at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1329) at org.apache.tools.ant.Project.executeTarget(Project.java:1298) at ToolkitExtensions.execute(ToolkitExtensions.java:108) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288) at sun.reflect.GeneratedMethodAccessor40.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:105) at org.apache.tools.ant.Task.perform(Task.java:348) at org.apache.tools.ant.Target.execute(Target.java:357) at org.apache.tools.ant.Target.performTasks(Target.java:385) at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1329) at org.apache.tools.ant.Project.executeTarget(Project.java:1298) at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41) at org.apache.tools.ant.Project.executeTargets(Project.java:1181) at org.apache.tools.ant.Main.runBuild(Main.java:698) at org.apache.tools.ant.Main.startAnt(Main.java:199) at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257) at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)
What version of the Ant do you use? Code coverage should work only with Ant 1.6.5+ . If you use one of these versions, please file a Jira issue regarding the problem.
Just click on the "Enable code coverage" button at the bottom of the Ant runner config. We've been getting coverage for our Ant-based builds for over a year, now.
--Dave Griffith
Thanks, I've overlooked it..
Anyway, my build fails if coverage is enabled... with the message like this:
BUILD FAILED C:\TeamCity\buildAgent\work\project\ant-tasks.xml:31: taskdef A class needed by class MergeProperties cannot be found: com/vladium/emma/rt/RT Total time: 1 minute 0 seconds
: Process exit code: 1
: Artifacts path coverage.ec not found
: Artifacts path coverage.txt not found
: Artifacts path coverage not found
The script compiles ant tasts with javac and then uses them with taskdef. It seems that 'javac' task is somehow tweaked so that compiled classes reference emma runtime... Does anyone have an idea how to fix that?
Message was edited by:
Igor Karpov
Hello,
When coverage is enabled TeamCity patches javac task and performes code
instrumentation. Then to run instrumented classess a special jar file is
required. This jar file is passed transparently to Ant tasks starting tests,
but currently it can't do this if you launch compiled custom tasks. I think
you can try to add emma.jar in classpath of your taskdef. You can refer to
it in Ant script as follows:
${agent.work.dir}/../plugins/coveragePlugin/lib/emma.jar
agent.work.dir property will be provided by TeamCity Ant runner.
--
Pavel Sher
Software Developer
JetBrains, Inc.
http://www.jetbrains.com
"Develop with pleasure!"
"Igor Karpov" <no_reply@jetbrains.com> wrote in message
news:10883151.1197635672974.JavaMail.itn@is.intellij.net...
>
>
>
I cannot modify all parts of the build that contain ]]> task...
I've tried adding emma.jar to global classpath.
It passes futher but there is interference with custom Ant tasks:
Custom task creates a new Ant target, adds it to the project and tries to execute it with project.executeTarget()
java.lang.NullPointerException
java.lang.NullPointerException
at jetbrains.buildServer.agent.ant.patches.ElementPatch.createChild(ElementPatch.java:46)
at jetbrains.buildServer.coverage.AntCoverageAdapter.addCoverageProperties(AntCoverageAdapter.java:58)
at jetbrains.buildServer.coverage.AntCoverageAdapter.taskStarted(AntCoverageAdapter.java:145)
at jetbrains.buildServer.agent.ant.AgentBuildListener$ExtensionsProcessor.taskStarted(AgentBuildListener.java:254)
at jetbrains.buildServer.agent.ant.AgentBuildListener.taskStarted(AgentBuildListener.java:142)
at org.apache.tools.ant.Project.fireTaskStarted(Project.java:2102)
at org.apache.tools.ant.Task.perform(Task.java:344)
at org.apache.tools.ant.Target.execute(Target.java:357)
at org.apache.tools.ant.Target.performTasks(Target.java:385)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1329)
at org.apache.tools.ant.Project.executeTarget(Project.java:1298)
at ToolkitExtensions.execute(ToolkitExtensions.java:108)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
at sun.reflect.GeneratedMethodAccessor40.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:105)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:357)
at org.apache.tools.ant.Target.performTasks(Target.java:385)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1329)
at org.apache.tools.ant.Project.executeTarget(Project.java:1298)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1181)
at org.apache.tools.ant.Main.runBuild(Main.java:698)
at org.apache.tools.ant.Main.startAnt(Main.java:199)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)
and the build terminates...
Igor,
What version of the Ant do you use? Code coverage should work only with Ant 1.6.5+ . If you use one of these versions, please file a Jira issue regarding the problem.
thanks,
KIR
It is definitely Ant 1.6.5+, coverage works for other configurations of the same project.
Igor,
I've fixed this particular NPE and the fix will be available in the next EAP build for TeamCity 3.1.
Hope it will fix your problem,
Regards,
KIR