Class NyxExtension


  • public abstract class NyxExtension
    extends Object
    The plugin configuration object. This object is responsible for reading the nyx {...} configuration block that users define within the build.gradle script.
    See Modeling DSL-like APIs for more o developing extension.
    See Developing Custom Gradle Types, Developing Custom Gradle Plugins, Implementing Gradle plugins and Lazy Configuration for an introduction on custom Gradle types development.

    NOTES ON NESTED OBJECTS:
    In order to support DSL (the curly braces syntax) for nested objects we also need to support one additional method for each nested object to accept and configure the closure. Take the commitMessageConventions for example. According to the API docs, defining the field and the getter method as as:

          private CommitMessageConventions commitMessageConventions = getObjectfactory().newInstance(CommitMessageConventions.class);
     
          public CommitMessageConventions getCommitMessageConventions() {
              return commitMessageConventions;
              }
     
    should be enough but it's not, in fact at runtime, when using the curly braces syntax to define that property like:

     nyx {
       commitMessageConventions {
          enabled = ['conventionalCommits']
       }
     }
     
    throws an exception like:

     org.gradle.api.GradleScriptException: A problem occurred evaluating root project...
          ...
          Caused by: groovy.lang.MissingMethodException: No signature of method: build_araz4us455w31lfualzy83h1f.nyx() is applicable for argument types: (build_araz4us455w31lfualzy83h1f$_run_closure1) values: [build_araz4us455w31lfualzy83h1f$_run_closure1@22b6a7c8]
          Possible solutions: any(), any(groovy.lang.Closure), run(), run(), sync(org.gradle.api.Action), uri(java.lang.Object)
          ...
     
    So thanks to posts like this (which points to this example here), this and this it turns out there must be another method to accept the closure. I don't know Groovy so I'm not sure what it's needed for but the additional method can be in one of the two following variants (still using the commitMessageConventions example):

          public void commitMessageConventions(groovy.lang.Closure closure) {
              closure.setResolveStrategy(groovy.lang.Closure.DELEGATE_FIRST);
              closure.setDelegate(commitMessageConventions);
              closure.call();
          }
     
    or:
          public void commitMessageConventions(org.gradle.api.Action<? super CommitMessageConventions> configuration) {
              configuration.execute(commitMessageConventions);
          }
     
    I opted for the second one, as it's a little more comprehensible, although I don't know exactly what happens under the hood.
    See Also:
    ExtensionAware, ExtensionContainer
    • Field Detail

      • NAME

        public static final String NAME
        The name of the extension object. This is the name of the configuration block inside Gradle scripts.
        See Also:
        Constant Field Values
    • Constructor Detail

      • NyxExtension

        public NyxExtension()
    • Method Detail

      • getObjectfactory

        @Inject
        protected abstract ObjectFactory getObjectfactory()
        Returns an object factory instance. The instance is injected by Gradle as soon as this getter method is invoked. Using property injection instead of constructor injection has a few advantages: it allows Gradle to refer injecting the object until it's required and is safer for backward compatibility (older versions can be supported).
        Returns:
        the object factory instance
      • create

        public static NyxExtension create​(Project project)
        Creates the extension into the given project.
        Parameters:
        project - the project to create the extension into
        Returns:
        the extension instance, within the given project
      • create

        public static NyxExtension create​(Settings settings)
        Creates the extension into the given settings.
        Parameters:
        settings - the settings to create the extension into
        Returns:
        the extension instance, within the given settings
      • getBump

        public Property<String> getBump()
        Returns the name of the version identifier to bump. When this is set by the user it overrides the inference performed by Nyx. We provide an implementation of this method instead of using the abstract definition as it's safer for old Gradle versions we support.
        Returns:
        the name of the version identifier to bump
      • getCommitMessageConventions

        public NyxExtension.CommitMessageConventions getCommitMessageConventions()
        Returns the object mapping the commitMessageConventions block. We provide an implementation of this method instead of using the abstract definition as it's safer for old Gradle versions we support.
        Returns:
        the object mapping the commitMessageConventions block
      • commitMessageConventions

        public void commitMessageConventions​(Action<? super NyxExtension.CommitMessageConventions> configuration)
        Accepts the DSL configuration for the commitMessageConventions block, needed for defining the block using the curly braces syntax in Gradle build scripts. See the documentation on top of this class for more.
        Parameters:
        configuration - the configuration object for the commitMessageConventions block
      • getDirectory

        public Property<File> getDirectory()
        Returns the directory to use as the base repository location. We provide an implementation of this method instead of using the abstract definition as it's safer for old Gradle versions we support.
        Returns:
        the directory to use as the base repository location
      • getDryRun

        public Property<Boolean> getDryRun()
        Returns the flag that, when true, prevents Nyx from applying any change to the repository or any other resource. We provide an implementation of this method instead of using the abstract definition as it's safer for old Gradle versions we support.
        Returns:
        the flag that, when true, prevents Nyx from applying any change to the repository or any other resource
        See Also:
        Defaults.DRY_RUN
      • getInitialVersion

        public Property<String> getInitialVersion()
        Returns the initial version to use when no past version can be inferred from the commit history. We provide an implementation of this method instead of using the abstract definition as it's safer for old Gradle versions we support.
        Returns:
        the flag that, when true, prevents Nyx from applying any change to the repository or any other resource
        See Also:
        Defaults.DRY_RUN
      • getReleasePrefix

        public Property<String> getReleasePrefix()
        Returns the prefix used to generate release names. We provide an implementation of this method instead of using the abstract definition as it's safer for old Gradle versions we support.
        Returns:
        the prefix used to generate release names
        See Also:
        Defaults.RELEASE_PREFIX
      • getReleaseLenient

        public Property<Boolean> getReleaseLenient()
        Returns the flag that, when true, lets Nyx interpret release names with whatever prefix. We provide an implementation of this method instead of using the abstract definition as it's safer for old Gradle versions we support.
        Returns:
        the flag that, when true, lets Nyx interpret release names with whatever prefix
        See Also:
        Defaults.RELEASE_LENIENT
      • getResume

        public Property<Boolean> getResume()
        Returns the flag that, when true, loads a previously saved state file (if any) to resume execution from there. We provide an implementation of this method instead of using the abstract definition as it's safer for old Gradle versions we support.
        Returns:
        the flag that, when true, prevents Nyx from applying any change to the repository or any other resource
        See Also:
        Defaults.DRY_RUN
      • getScheme

        public Property<String> getScheme()
        Returns the versioning scheme to use. We provide an implementation of this method instead of using the abstract definition as it's safer for old Gradle versions we support.
        Returns:
        the versioning scheme to use
        See Also:
        Defaults.SCHEME
      • getStateFile

        public Property<File> getStateFile()
        Returns the optional path where to save the state file. We provide an implementation of this method instead of using the abstract definition as it's safer for old Gradle versions we support.
        Returns:
        the directory to use as the base repository location
      • getVerbosity

        public Property<String> getVerbosity()
        Returns the logging verbosity. Please note that the verbosity option is actually ignored in this plugin implementation and the backing Nyx implementation as it's controlled by Gradle. We provide an implementation of this method instead of using the abstract definition as it's safer for old Gradle versions we support.
        Returns:
        the logging verbosity