[4.3.1] Ant javac task is unable to find CloverCompilerAdapter class

Issue #75 resolved
Marek Parfianowicz
created an issue

Affects OpenClover version 4.3.0. Stack trace:

BUILD FAILED

Class not found: com.atlassian.clover.ant.taskdefs.CloverCompilerAdapter at org.apache.tools.ant.util.ClasspathUtils.newInstance(ClasspathUtils.java:257) at org.apache.tools.ant.taskdefs.compilers.CompilerAdapterFactory.resolveClassName(CompilerAdapterFactory.java:196) at org.apache.tools.ant.taskdefs.compilers.CompilerAdapterFactory.getCompiler(CompilerAdapterFactory.java:157) at org.apache.tools.ant.taskdefs.Javac.findSupportedFileExtensions(Javac.java:984) at org.apache.tools.ant.taskdefs.Javac.scanDir(Javac.java:961) at org.apache.tools.ant.taskdefs.Javac.execute(Javac.java:932) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292) at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106) at org.apache.tools.ant.Task.perform(Task.java:348) at org.apache.tools.ant.Target.execute(Target.java:435) at org.apache.tools.ant.Target.performTasks(Target.java:456) at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1393) at org.apache.tools.ant.Project.executeTarget(Project.java:1364) at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41) at org.apache.tools.ant.Project.executeTargets(Project.java:1248) at org.apache.tools.ant.Main.runBuild(Main.java:851) at org.apache.tools.ant.Main.startAnt(Main.java:235) at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280) at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109) Caused by: java.lang.ClassNotFoundException: com.atlassian.clover.ant.taskdefs.CloverCompilerAdapter at org.apache.tools.ant.AntClassLoader.findClassInComponents(AntClassLoader.java:1374) at org.apache.tools.ant.AntClassLoader.findClass(AntClassLoader.java:1323) at org.apache.tools.ant.AntClassLoader.loadClass(AntClassLoader.java:1076) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:348) at org.apache.tools.ant.util.ClasspathUtils.newInstance(ClasspathUtils.java:249) ... 21 more

Cause:

In 4.3.0 we have removed CloverEnvTask which was adding clover.jar to bootclasspath (as in JDK9 such hack is no longer allowed). This clover.jar was used to load high-level targets (like "with.clover"), which can be easily declared in Ant build.xml.

Side effect is that the Ant <javac>task is unable to find the CloverCompilerAdapter specified in the build.compiler property - the classloader sees Ant JARs only...

Workaround:

Copy clover.jar to ANT_HOME\lib directory.

Comments (4)

  1. Marek Parfianowicz reporter

    The workaround is not bad actually. I will update installation instructions and upgrade guides accordingly. I also updated in-product help (e.g. in Jenkins, Hudson plugin) pointing to proper installation instruction.

  2. Marek Parfianowicz reporter

    Additional fix implemented is restoration of the <clover-env> task - however, without the bootclass loader hack. It means that it will be again possible to call <clover-env> to add high-level targets, like "with.clover".

  3. Log in to comment