Settings Operations APIs
Some of the tools that are available on ConfigurationPhaseOperations are also available in the settings.gradle(.kts) files.
They are:
When writing a settings plugin you can get access to them by
Usage as a plugin (recommended)
import org.ysb33r.grolifant.api.core.plugins.GrolifantSettingsPlugin (1)
import org.ysb33r.grolifant.api.core.settings.SettingsOperations
class MyPlugin implements Plugin<Settings> {
void apply(Settings settings) {
settings.plugins.apply(GrolifantSettingsPlugin) (2)
final cpo = SettingsOperations.from(settings) (3)
}
}
| 1 | Required import |
| 2 | Install the core plugin. |
| 3 | How to get operations that can be used by settings. |
Information about host operating system
You can get hold of this from settings
final os = SettingsOperations.from(settings).currentOS() (1)
| 1 | See OperatingSystem for more details. |
Manipulating the plugin classpath
-
To get access to the plugin classpath for each project from a settings plugin use
pluginClasspath().configure. -
To set access to the attribute schema for each project from a settings plugin use
pluginClasspath().configureAttributesSchema -
TO sett all native attributes along with selection rules in one simple go use
pluginClasspath().applyNativeAttributes
final grolifantOps = SettingsOperations.from(settings) (1)
final osa = grolifantOps.providerTools().named(OperatingSystemFamily, grolifantOps.currentOs().operatingSystemAttributeValue) (2)
grolifantOps.pluginClasspath().configure { (3)
attributes.attribute( OperatingSystemFamily.OPERATING_SYSTEM_ATTRIBUTE, osa) (4)
}
grolifantOps.pluginClasspath().configureAttributeSchema { (5)
}
grolifantOps.pluginClasspath().applyNativeAttributes() (6)
| 1 | Obtain an instance of ref:project-artifacts:attachment$-grolifant5-core/groovydoc/org/ysb33r/grolifant5/api/core/settings/SettingsOperations.html[SettingsOperations]. |
| 2 | Create needed objects outside, because isolate projects might prevent them from being created inside the closure. |
| 3 | Obtain the configuration for buildscript.configurations.named('classpath') via pluginClasspath() and then pass a configurating Action or Closure.
This applies it to every Project before evaluation starts. |
| 4 | Example of adding an attribute. |
| 5 | Configure each attribute schema as need be. |
| 6 | Set operating system and machine architecture attributes, including selection rules for each project. |