Start here

Home
About Klocwork
What's new
Fixed issues
Release notes
Installation

Reference

C/C++ checkers
Java checkers
C# checkers
MISRA C 2004 checkers
MISRA C++ 2008 checkers
MISRA C 2012 checkers
MISRA C 2012 checkers with Amendment 1
Commands
Metrics
Troubleshooting
Reference

Product components

C/C++ Integration build analysis
Java Integration build analysis
Desktop analysis
Refactoring
Klocwork Static Code Analysis
Klocwork Code Review
Structure101
Tuning
Custom checkers

Coding environments

Visual Studio
Eclipse for C/C++
Eclipse for Java
IntelliJ IDEA
Other

Administration

Project configuration
Build configuration
Administration
Analysis performance
Server performance
Security/permissions
Licensing
Klocwork Static Code Analysis Web API
Klocwork Code Review Web API

Community

View help online
Visit RogueWave.com
Klocwork Support
Rogue Wave Videos

Legal

Legal information

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>
Note: 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