Class NyxPlugin<T>

  • Type Parameters:
    T - the type of object the plugin is applied to. The actual type is defined by Gradle and can be Project or Settings 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 to Project or Settings objects, which means the apply(Object) method can receive any of these object types. The actual type of the object passed to the apply(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 the build.gradle file, then a Project object is passed. If the plugin is used as a settings plugin using the plugin DSL in the settings.gradle then a Settings 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 the build.gradle, so using a Project object) Nyx inference may happen too late as some properties like the project version 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 the undefined default value when reading the project.version property. When the plugin is applied to the settings.gradle instead, the inference happens before the project is evaluated and the version property, along with other values coming from the inference, are available earlier.
    Please note that when applying the plugin in the settings.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 Detail

      • NyxPlugin

        public NyxPlugin()
        Default constructor.
    • Method Detail

      • apply

        public void apply​(T target)
        Creates and registers all the plugin resources for the given target.
        Specified by:
        apply in interface Plugin<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 in
        extension - the extension to be passed to tasks
      • triggerInference

        protected static void triggerInference​(Project project)
        Runs the InferTask on the given project so that the outcomes of the inference (like the project.property) are available as soon as possible.
        Parameters:
        project - the project to run the inference for