PDE/Build supports a number of options to control the compiler for individual plug-ins. For settings related to
source and target levels and bootclasspath, see "Setting the Compilation Environment".
Warnings and Errors
PDE/Build allows specifying custom compile warnings and errors in the build.properties file. These can be set on a per library basis (a single plug-in can
contain multiple jar libraries) with the javacWarnings.<library> and javacErrors.<library> options. The values for these properties
are given in the "-warn:..." section on the using the batch compiler page (from the Java development user guide).
javacErrors.. = forbidden,discouraged,
javacWarnings.library.jar = deprecation,nullDereference
Warnings and Errors from Project preferences
The JDT project preferences can now also be used during PDE/Build. PDE/Build itself is not able to read the preference files, but it is able to pass them
to the JDT compiler which does understand them.
To use this, a plug-in should specify the javacProjectSettings property in its build.properties file. The value should be:
Some projects may wish to use different warning and error settings in the workspace as compared to a releng build. This allows a more convenient method
of specifying these settings compared to the "javacWarnings.<library>" property.
- javacProjectSettings=true : Use the project setting specified in the default .settings/org.eclipse.jdt.core.prefs preferences file.
- javacProjectSettings=path/to/jdt.prefs : Use the specified preference file.
PDE/Build can accept custom file encodings on a per library, folder or file basis.
- sets default encoding to use when compiling the given library.
- a comma separated list of
paths and encodings to use when compiling the given library. When specifying a folder, the encoding is used for everything contained in that folder. When
specifying a file, the encoding is used for just that file.
javacCustomEncodings.library.jar = src/org/foo[US-ASCII], src/org/foo/bar.java[ISO-8859-1]
Custom Compiler Arguments
Custom compiler arguments can now be specified per bundle using the compilerArg property in the bundle's build.properties file. This property is similar
to the compilerArg property in the builder configuration except that it affects only the single plug-in instead
of all plug-ins. The specific arguments here depend on the compiler being used. The JDT compiler arguments are listed here.
Compiler Option Precedence
There are a number of difference ways to specify different compiler options. As a general rule, option precedence is as follows:
- javacDefaultEncoding.<library> has precedence over a custom -encoding command line option.
- For general options, an option appearing later on the compiler command line overrides options specified earlier. The options are provided to the JDT in the following order:
- The compilerArg property from the builder configuration. (Affects all bundles).
- The compilerArg property from this plug-in's build.properties.
- The compiler preferences file specified with javacProjectSettings.
- The generated compiler arguments file (javaCompiler.<library>.args) containing file encodings, javacWarnings, javacErrors and access rules.
Using a Custom Compiler
A bundle can now use a custom compiler by setting the compilerAdapter property. The specified compiler adapter must be available in the ant environment. The JDT compiler
adapter used by default is org.eclipse.jdt.core.JDTCompilerAdapter. One particular reason for specifying an alternate compiler is for Aspect J or Groovy bundles. Bundles specifying
a custom compiler adapter may need to also specify some of the following properties:
- sourceFileExtensions : A list of extensions that should be considered source. (eg *.java, *.aj, *.groovy).
- compilerAdapter.useLog : whether or not to pass "-log" argument to the compiler
- compilerAdapter.useArgFile : whether or not to pass the generated javaCompiler.<library>.args argument file. (Contains access rules, file encodings and warning/error levels).