Kwgradle

The kwgradle command creates a Java or Kotlin build specification based on the information in your Gradle build file.

You can also create a build specification using your Gradle wrapper. For more information, see Kwgradlew.

As of Klocwork 2022.4, we now support Gradle’s Kotlin DSL format. This provides an alternative syntax to the traditional Groovy DSL with an enhanced editing experience in supported IDEs.

Prerequisites

Before you can create a build specification, you need to
  • install the Server package. See Installing Klocwork.
  • install Gradle. See Supported Java build tools to see what versions are supported.
  • have the path to the Gradle and JVM executables set in the PATH environment variable, as follows:
    • Unix:
      PATH=<path_to_gradle>/bin:<path_to_JDK>/bin:<klocwork_install>/bin:$PATH
    • Windows:
      PATH=<path_to_gradle>\bin;<path_to_JDK>\bin;<klocwork_install>\bin;%PATH%
  • ensure that the build.gradle build file is in a location that can be written to.

For more information, see Creating a Java build specification.

Usage

kwgradle <gradle_options>

where <gradle_options> are any arguments required for your gradle build.

Note: When running the command for the first time, the Build Cache feature should be disabled. This feature should only be enabled for incremental builds (when the '--update' option is used).

Options

Name (and short name) Description
--help (-h) display help
--version display kwgradle version
--output (-o) <file> write the build specification to <file>. By default, the build specification is written to kwinject.out in the current working directory.
--update (-u) when specified, the existing build specification is updated with the results of the new incremental build instead of overwriting it.
--build-file <string> path to the Gradle build file. Absolute or relative paths are supported. Default is build.gradle in the current directory.
--project-dir (-p) <string> the project directory. Default is the current directory, or <install_dir>/bin.
--debug-level <integer> print debug information to the console. Default is 0 (no debug output).
--classpath <string> Paths to user class files and dependent JAR files. Used for type resolution.
--excludes <string> Globbing patterns describing paths to exclude from the analysis.
--includes <string> Globbing patterns describing paths to include in the analysis. Useful in combination with "excludes" patterns.
--plugins <string> Extra paths to plugin jars, separated by ",".
--src-lang <string> Specify this option to generate the build specification for either Java or Kotlin. Valid values are: javaor kotlin. By default, kwgradle will generate a combined buildspec for both Java and Kotlin.

The kwgradle command supports Gradle arguments that configure the build execution. Examples of supported build arguments are --info, -u, and -p. Command line instructions that are separate Gradle commands, such as -? and -v are not supported. These arguments are modeled in the Gradle API and therefore, because the tooling API always runs with the daemon, instructions such as --daemon and --no-daemon are also not supported.