Kwmaven

The kwmaven command creates a Java build specification based on the information in your maven build file.

Prerequisites

Before you can create a build specification, you need to:

  • install the Server package. See Installing Klocwork.
  • install Maven. See Supported Java build tools to see what versions are supported.
  • you must use a javac from the Java Development Kit (JDK)
  • you must have the path to the Maven and JVM executables set in the PATH environment variable:
    • Unix:
    PATH=<path_to_mvn>/bin:<path_to_JDK>/bin:<klocwork_install>/bin:$PATH
    
    • Windows:
    PATH=<path_to_mvn>\bin;<path_to_JDK>\bin;<klocwork_install>\bin;%PATH%
    

For how-to information, see Creating a Java build specification.

Usage

kwmaven <maven_options>

where <maven_options> are any arguments required for your maven build

Options

Name (and short name) Description
--global-settings (-gs) <file> specify an alternate path for the global settings file at <file>. By default, global settings are defined in ${M2_HOME}/conf/settings.xml.
--help (-h) display help
--manual-integration enable manual integration
--output <file> write the build specification to <file>. By default, the build specification is written to kwinject.out in the current working directory.
--settings (-s) <file> specify an alternate path for the user settings file at <file>. By default, kwmaven uses the file at ${user.home}/.m2/settings.xml.
--update (-u) when specified, the existing build specification is updated with the results of the new incremental build instead of overwriting it.
--version display kwmaven version

File exclusion with kwmaven

If you wish to make use of file exclusion or inclusion with kwmaven, it can be run with the --manual-integration option. In every Project Object Model (POM), there must be a plugin section for the maven-compiler-plugin and, in this section, dependency on the kwmaven plugin has to be specified. For example:
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-compiler-plugin</artifactId>
  <version>3.1</version>
  <configuration>
    <useIncrementalCompilation>false</useIncrementalCompilation>
    <excludes>
      <exclude>**/Ignore.java</exclude>
    </excludes>
  </configuration>
</plugin>
becomes this:
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-compiler-plugin</artifactId>
  <version>3.1</version>
  <configuration>
    <useIncrementalCompilation>false</useIncrementalCompilation>
    <excludes>
      <exclude>**/Ignore.java</exclude>
    </excludes>
  </configuration>
  <dependencies>
    <dependency>
      <groupId>com.klocwork</groupId>
      <artifactId>kwmaven</artifactId>
      <version>10.4.0.1577</version>
    </dependency>
  </dependencies>
</plugin>

The dependency does not interfere with the native build.

If you are getting memory errors while running kwmaven with file exclusion, there are two possible workarounds to resolve this issue:
  • Specify 'clean' target along with your build target. For example, if you are building with 'compile', your command will look as follows:
    kwmaven --manual-integration clean compile
  • Use kwmaven's --force-install option that disables version checking. For example:
    kwmaven --manual-integration compile --force-install