Using Klocwork with Gradle

Hello, I’m trying to use Klocwork to analyze my gradle (java) build. It looks like klocwork will work fine with Ant but it’s not obvious how to set it up with Gradle.

There are a couple of potential avenues I’ve looked at but so far no luck.

  1. Maven has an ant plugin that will create an ant build.xml file from the pom. Gradle can run Ant files, but I can’t seem to find any way to export the gradle build files as a build.xml.

  2. klocwork has a ‘kwwrap’ tool, that might be helpful if I can prefix my javac calls with the kwwrap parameters. Is it possible within the gradle java plugin to modify how the compile is called?

  3. My least desirable option is to create a corresponding ant build that mimics my gradle build, and analyze that. However then I’d have two builds that I’d need to keep in sync, which is not a direction I’d like to go in.

I’m hoping Klocwork will start supporting gradle in the future. But not sure if that will happen, or if so how soon.

Thanks,

John

The natural solution would be to use the Klocwork Ant task(s) from Gradle. For details, see the Ant chapter in the Gradle User Guide.

Thanks, I looked at that before submitting the question. At first glance it didn’t look promising because Gradle is calling Ant. And I thought what I wanted was Klocwork analyzing the Ant build, which is the default setup.

However, after looking into this again it seems you can set up an ant task that can be called from Gradle (like you suggested).

For anyone who might be interested See: “Manual integration – editing the Ant build file” at…

http://www.klocwork.com/products/documentation/current/Creating_a_Java_build_specification