public final class BuildPropertiesSupport extends Object
This API provides access to certain such values, which are safe to extract and transport to the IDE process. Not all
properties are computed and ready to be read, and not all properties are supported by the Gradle Projects infrastructure,
but many of them are. Only String values are supported; other values are converted to String using Object.toString()
.
To access an extension or a task property, obtain an instance of BuildPropertiesSupport
by caling BuildPropertiesSupport.get(org.netbeans.api.project.Project)
,
then use
BuildPropertiesSupport.findExtensionProperty(java.lang.String, java.lang.String)
, or
BuildPropertiesSupport.findTaskProperty(java.lang.String, java.lang.String)
There's a limited support for maps and lists. If a BuildPropertiesSupport.Property
indicates a BuildPropertiesSupport.PropertyKind.MAP
type, it is
possible to use BuildPropertiesSupport.keys(org.netbeans.modules.gradle.api.BuildPropertiesSupport.Property)
to enumerate keys of the map. For BuildPropertiesSupport.PropertyKind.LIST
s, BuildPropertiesSupport.items(org.netbeans.modules.gradle.api.BuildPropertiesSupport.Property, java.lang.String)
enumerate items of the list.
Modifier and Type | Class and Description |
---|---|
static class |
BuildPropertiesSupport.Property
Describes a property and its value.
|
static class |
BuildPropertiesSupport.PropertyKind
Describes type / kind of the property.
|
Modifier and Type | Field and Description |
---|---|
static String |
EXTENSION
Scope for extension properties
|
static String |
TASK
Scope for task properties
|
Modifier and Type | Method and Description |
---|---|
BuildPropertiesSupport.Property |
findExtensionProperty(String extensionName,
String propertyPath)
Attempts to find / locate a property value in the Gradle script.
|
BuildPropertiesSupport.Property |
findTaskProperty(String taskName,
String propertyPath)
Attempts to find property value of a named task.
|
BuildPropertiesSupport.Property |
get(BuildPropertiesSupport.Property base,
String key,
String path)
Returns a named item, or a property of a named item from map-style property.
|
static BuildPropertiesSupport |
get(Project p)
Obtain an instance for the project.
|
Iterable<BuildPropertiesSupport.Property> |
items(BuildPropertiesSupport.Property owner,
String path)
Enumerates items of a list-style property.
|
Collection<String> |
keys(BuildPropertiesSupport.Property owner)
Returns keys of map-style properties.
|
public static final String EXTENSION
public static final String TASK
public static BuildPropertiesSupport get(Project p)
null
, if the project does not support
BuildProperties access.p
- the projectBuildPropertiesSupport
for the project, or null
.public BuildPropertiesSupport.Property findExtensionProperty(String extensionName, String propertyPath)
null
.
In some cases, it's known that the property exists, but its value could not
be computed or obtained - in that case, the return will indicate BuildPropertiesSupport.PropertyKind.EXISTS
.
The propertyPath
is a dot-separated fully qualified property name.
If a property is an item of a list or a map, the owning List or Map must be obtained first as a Property. Then individual items may be accessed using index or key.
propertyPath
- path to the propertynull
public BuildPropertiesSupport.Property findTaskProperty(String taskName, String propertyPath)
BuildPropertiesSupport.findExtensionProperty(java.lang.String, java.lang.String)
but works for
task properties.taskName
- task name.propertyPath
- path to the property.null
BuildPropertiesSupport.findExtensionProperty(java.lang.String, java.lang.String)
public Iterable<BuildPropertiesSupport.Property> items(BuildPropertiesSupport.Property owner, String path)
BuildPropertiesSupport.PropertyKind.LIST
. If path
is null,
the contained items are enumerated. If path
is not null, it identifies a property within items - the method enumerates
those properties. If an item does not contain the specified path, null
is returned in the enumeration.
sowner
- the list propertypath
- path into individual items.@NonNull public Collection<String> keys(BuildPropertiesSupport.Property owner)
BuildPropertiesSupport.PropertyKind.MAP
or
BuildPropertiesSupport.PropertyKind.STRUCTURE
. May return an empty list, if keys cannot be enumerated or represented as Strings.owner
- the property@CheckForNull public BuildPropertiesSupport.Property get(BuildPropertiesSupport.Property base, String key, String path)
base
- the map propertykey
- map item's keypath
- optional path within an item to the property.