Package com.mooltiverse.oss.nyx.gradle
Class NyxPlugin<T>
- java.lang.Object
-
- com.mooltiverse.oss.nyx.gradle.NyxPlugin<T>
-
- Type Parameters:
T
- the type of object the plugin is applied to. The actual type is defined by Gradle and can beProject
orSettings
depending on how and where the plugin is applied.
- All Implemented Interfaces:
Plugin<T>
public class NyxPlugin<T> extends Object implements Plugin<T>
The main plugin class. This plugin can be applied toProject
orSettings
objects, which means theapply(Object)
method can receive any of these object types. The actual type of the object passed to theapply(Object)
method is defined by Gradle based on how the plugin is used, or better, where the plugin is applied.
If the plugin is applied the common way, using the plugin DSL in thebuild.gradle
file, then aProject
object is passed. If the plugin is used as a settings plugin using the plugin DSL in thesettings.gradle
then aSettings
object is passed. See Writing a simple plugin for more.
The main difference between the different options is that when the plugin is used as a regular project plugin (applied in thebuild.gradle
, so using aProject
object) Nyx inference may happen too late as some properties like the projectversion
are needed since the project evaluation. For example, Maven publications are statically defined and evaluated before the Nyx inference has run, so they would likely get theundefined
default value when reading theproject.version
property. When the plugin is applied to thesettings.gradle
instead, the inference happens before the project is evaluated and theversion
property, along with other values coming from the inference, are available earlier.
Please note that when applying the plugin in thesettings.gradle
the plugin is also applied at the project level so that users don't need to apply it twice.
See Developing Custom Gradle Plugins for an introduction on custom Gradle plugin development.
-
-
Constructor Summary
Constructors Constructor Description NyxPlugin()
Default constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
apply(T target)
Creates and registers all the plugin resources for the given target.protected static void
defineTasks(Project project, NyxExtension extension)
Sets up the tasks and dependencies to the project.protected static void
triggerInference(Project project)
Runs theInferTask
on the given project so that the outcomes of the inference (like theproject.property
) are available as soon as possible.
-
-
-
Field Detail
-
ID
public static final String ID
The plugin ID. Value is "com.mooltiverse.oss.nyx".- See Also:
- Constant Field Values
-
-
Method Detail
-
apply
public void apply(T target)
Creates and registers all the plugin resources for the given target.- Specified by:
apply
in interfacePlugin<T>
- Parameters:
target
- the target the plugin is applied to and resources created into. More in the class level documentation on this.- See Also:
Plugin.apply(Object)
-
defineTasks
protected static void defineTasks(Project project, NyxExtension extension)
Sets up the tasks and dependencies to the project.- Parameters:
project
- the project to define the tasks inextension
- the extension to be passed to tasks
-
-