Format of the build specification file for Java projects

The Klocwork build specification for Java projects, called kwinject.out by default, is a semicolon-separated text file containing the following information about the Java source files in your Klocwork project:

  • the classpath and Java version for the javac invocation, identified in jconfig lines
  • the source Java files that were compiled, identified in jcompile lines
  • the jar files and their input files, identified in the jar lines

The first field of each line is a tag to identify the type of line. The possible tags are as follows:

Tag Description
version build specification format version
jconfig used to define Java compiler options, such as Java version and classpath
jcompile used to specify compiled source files
jar used to specify jar files and their input files

version line

The version line is used to define the build specification format version. It must be the first line in the build specification. Only one version line may appear in a build specification.

Example version line:
version;108

Version 1.4 or later indicates that the build specification was generated using a source encoding of UTF-8, allowing multibyte characters (for example, Japanese). To ensure that kwbuildproject processes the build specification with UTF-8 encoding, the version must be version;104 or later.

jconfig line

The jconfig line is used to identify Java compiler options — the Java version and default classpath.

Example jconfig line:

On Unix
jconfig;/space/testing/java/jdk1.7.0_25/bin/javac;-classpath;/space/testing/java/jdk1.7.0_25/jre/lib/resources.jar:/space/testing/java/jdk1.7.0_25/jre/lib/rt.jar;-source;1.7
On Windows
jconfig;c:\program files\java\jdk1.7.0_67\bin\javac.exe;-classpath;c:\program files\java\jdk1.7.0_67\jre\lib\resources.jar%3Bc:\program files\java\jdk1.7.0_67\jre\lib\rt.jar;-source;1.7

There are three fields:

Field Description
jconfig tag tag for jconfig lines
compiler path to javac compiler (for example, /opt/sun1.7/bin/javac)
options a list of separated compiler options listing the source version and classpath,-classpath;/space/testing/java/jdk1.7.0_25/jre/lib/resources.jar:/space/testing/java/jdk1.7.0_25/jre/lib/rt.jar;-source;1.7) The classpath entries are separated by ":" on Unix machines, or "%3B" for Windows.

jcompile line

Each jcompile line is used to track Java source file compilation.

Example jcompile line:
jcompile;/space/testing/java/jdk1.7.0_25/bin/javac;/space/testing/run/scripts/kwinject/javac/basic/A;a.java

The fields are:

Field Description
jcompile tag tag for jcompile lines
compiler full path to the javac executable
target directory with the resulting .class file or full path to the target .jar file
source file full path name of the source file

jar line

Each jar line is used to track jar execution, in other words, how .jar files are created.

Example jar line:
jar;/space/testing/run/scripts/kwinject/javac/basic/A.jar;/space/testing/run/scripts/kwinject/javac/basic/A/A.class

The fields are:

Field Description
jar tag tag for jar lines
output file full path to the output .jar file
input files semi-colon-separated list of .class files and/or directories and/or .jar files.