public class AptConfig extends Object
Modifier and Type | Method and Description |
---|---|
static void |
addProcessorOption(IJavaProject jproj,
String key,
String val)
Add the equivalent of -Akey=val to the list of processor options.
|
static void |
dispose()
Flush unsaved preferences and perform any other config-related shutdown.
|
static IFactoryPath |
getDefaultFactoryPath(IJavaProject jproj)
Get a factory path corresponding to the default values: if jproj is
non-null, return the current workspace factory path (workspace prefs
are the default for a project); if jproj is null, return the default
list of plugin factories (which is the "factory default").
|
static IFactoryPath |
getFactoryPath(IJavaProject jproj)
Get the factory path for a given project or for the workspace.
|
static String |
getGenSrcDir(IJavaProject jproject) |
static Map<String,String> |
getProcessorOptions(IJavaProject jproj)
Get the options that are presented to annotation processors by the
AnnotationProcessorEnvironment.
|
static Map<String,String> |
getRawProcessorOptions(IJavaProject jproj)
Get the options that are presented to annotation processors by the
AnnotationProcessorEnvironment.
|
static String |
getString(IJavaProject jproj,
String optionName)
Helper method to get a single preference setting, e.g., APT_GENSRCDIR.
|
static boolean |
hasProjectSpecificFactoryPath(IJavaProject jproj)
Does this project have a factory path that is different from the
workspace default?
|
static void |
initialize()
Initialize preferences lookups, and register change listeners.
|
static boolean |
isAutomaticProcessorOption(String key)
Is the named option automatically generated in getProcessorOptions(),
or did it come from somewhere else, such as a -A processor option?
|
static boolean |
isEnabled(IJavaProject jproject)
Is annotation processing turned on for this project?
|
static void |
removeProcessorOption(IJavaProject jproj,
String key)
Remove an option from the list of processor options.
|
static void |
setEnabled(IJavaProject jproject,
boolean enabled)
Turn annotation processing on or off for this project.
|
static void |
setFactoryPath(IJavaProject jproj,
IFactoryPath path)
Set the factory path for a given project or for the workspace.
|
static void |
setGenSrcDir(IJavaProject jproject,
String dirString) |
static void |
setProcessDuringReconcile(IJavaProject jproject,
boolean enabled)
Turn processing during reconcile on or off.
|
static void |
setProcessorOptions(Map<String,String> options,
IJavaProject jproj)
Set all the processor options in one call.
|
static boolean |
shouldProcessDuringReconcile(IJavaProject jproject)
Is annotation processing turned on during reconcile, or only during build?
|
static boolean |
validateGenSrcDir(IJavaProject jproject,
String dirName) |
public static void addProcessorOption(IJavaProject jproj, String key, String val)
key
- must be a nonempty string. It should only include the key;
that is, it should not start with "-A".jproj
- a project, or null to set the option workspace-wide.val
- can be null (equivalent to -Akey). This does not mean
remove the key; for that functionality, @see #removeProcessorOption(IJavaProject, String).public static void removeProcessorOption(IJavaProject jproj, String key)
jproj
- a project, or null to remove the option workspace-wide.key
- must be a nonempty string. It should only include the key;
that is, it should not start with "-A".public static Map<String,String> getProcessorOptions(IJavaProject jproj)
%ROOT%
, which is replaced by the absolute pathname
of the workspace root directory, and %PROJECT.DIR%
, which
will be replaced by the absolute pathname of the project root directory.
For example, a value of %ECLIPSE_HOME%/configuration/config.ini
might be resolved to d:/eclipse/configuration/config.ini
.
This method returns some options which are set programmatically but
are not directly editable, are not displayed in the configuration GUI,
and are not persisted to the preference store. This is meant to
emulate the behavior of Sun's apt command-line tool, which passes
most of its command line options to the processor environment. The
programmatically set options are:
-classpath
[set to Java build path]
-sourcepath
[set to Java source path]
-s
[set to generated src dir]
-d
[set to binary output dir]
-target
[set to compiler target version]
-source
[set to compiler source version]
There are some slight differences between the options returned by this
method and the options returned from this implementation of @see
AnnotationProcessorEnvironment#getOptions(). First, that method returns
additional options which are only meaningful during a build, such as
phase
. Second, that method also adds alternate encodings
of each option, to be compatible with a bug in Sun's apt implementation:
specifically, for each option key="k", value="v", an additional option
is created with key="-Ak=v", value=null. This includes the user-created
options, but does not include the programmatically defined options listed
above.jproj
- a project, or null to query the workspace-wide setting.public static void setProcessorOptions(Map<String,String> options, IJavaProject jproj)
options
- a map of keys to values. The keys should not include
any automatic options (@see #isAutomaticProcessorOption(String)),
and the "-A" should not be included. That is, to perform the
equivalent of the apt command line "-Afoo=bar", use the key "foo"
and the value "bar". Keys cannot contain spaces; values can
contain anything at all. Keys cannot be null, but values can be.public static boolean isAutomaticProcessorOption(String key)
key
- the name of an AnnotationProcessorEnvironment optionpublic static Map<String,String> getRawProcessorOptions(IJavaProject jproj)
jproj
- a project, or null to query the workspace-wide setting.
If jproj is not null, but the project has no per-project settings,
this method will fall back to the workspace-wide settings.public static void dispose()
public static void initialize()
public static boolean isEnabled(IJavaProject jproject)
Prior to Eclipse 3.3, this read the org.eclipse.jdt.apt.aptEnabled setting. In Eclipse 3.3, it reads the org.eclipse.jdt.core.compiler.processingEnabled setting; the result is logically or-ed with value of the older setting in order to preserve backward compatibility.
jproject
- an IJavaProject, or null to request workspace preferences.public static void setEnabled(IJavaProject jproject, boolean enabled)
Prior to Eclipse 3.3, this affected the org.eclipse.jdt.apt.aptEnabled setting. In Eclipse 3.3, it affects the org.eclipse.jdt.core.compiler.processingEnabled setting; the older setting is still set (and read) in order to preserve backward compatibility.
jproject
- an IJavaProject, or null to set workspace preferences.enabled
- public static boolean shouldProcessDuringReconcile(IJavaProject jproject)
jproject
- an IJavaProject to query, or null to get the default value.public static void setProcessDuringReconcile(IJavaProject jproject, boolean enabled)
jproject
- the IJavaProject to modify. This setting is only valid
on individual projects.public static IFactoryPath getDefaultFactoryPath(IJavaProject jproj)
public static IFactoryPath getFactoryPath(IJavaProject jproj)
jproj
- the project, or null to get the factory path for the workspace.public static void setFactoryPath(IJavaProject jproj, IFactoryPath path) throws CoreException
jproj
- the project, or null to set the factory path for the workspace.path
- a factory path, or null to reset the factory path to the default.CoreException
public static boolean hasProjectSpecificFactoryPath(IJavaProject jproj)
public static String getString(IJavaProject jproj, String optionName)
jproj
- the project, or null for workspace.optionName
- a preference constant from @see AptPreferenceConstants.public static String getGenSrcDir(IJavaProject jproject)
public static void setGenSrcDir(IJavaProject jproject, String dirString)
public static boolean validateGenSrcDir(IJavaProject jproject, String dirName)
Copyright (c) 2000, 2015 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.