Class NyxExtension

java.lang.Object
com.mooltiverse.oss.nyx.gradle.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:
  • Field Details

    • 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:
  • Constructor Details

    • NyxExtension

      public NyxExtension()
      Default constructor.
  • Method Details

    • 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
    • getChangelog

      public NyxExtension.ChangelogConfiguration getChangelog()
      Returns the object mapping the changelog 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 changelog block
    • changelog

      public void changelog(Action<? super NyxExtension.ChangelogConfiguration> configurationAction)
      Accepts the DSL configuration for the changelog 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:
      configurationAction - the configuration action for the changelog block
    • 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> configurationAction)
      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:
      configurationAction - the configuration action for the commitMessageConventions block
    • getConfigurationFile

      public Property<String> getConfigurationFile()
      Returns the custom configuration file 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 custom configuration file to use
      See Also:
    • 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:
    • getGit

      Returns the object mapping the git 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 git block
    • git

      public void git(Action<? super NyxExtension.GitConfiguration> configurationAction)
      Accepts the DSL configuration for the git 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:
      configurationAction - the configuration action for the git block
    • 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:
    • getPreset

      public Property<String> getPreset()
      Returns the selected preset configuration name. 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 selected preset configuration name.
      See Also:
    • getReleaseAssets

      Returns the object mapping the releaseAssets 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 releaseAssets block
    • releaseAssets

      public void releaseAssets(Action<? super NamedDomainObjectContainer<NyxExtension.AssetConfiguration>> configurationAction)
      Accepts the DSL configuration for the releaseAssets 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:
      configurationAction - the configuration action for the releaseAssets block
    • 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:
    • 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:
    • getReleaseTypes

      public NyxExtension.ReleaseTypes getReleaseTypes()
      Returns the object mapping the releaseTypes 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 releaseTypes block
    • releaseTypes

      public void releaseTypes(Action<? super NyxExtension.ReleaseTypes> configurationAction)
      Accepts the DSL configuration for the releaseTypes 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:
      configurationAction - the configuration action for the releaseTypes block
    • 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:
    • 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:
    • getServices

      Returns the object mapping the services 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 services block
    • services

      public void services(Action<? super NamedDomainObjectContainer<NyxExtension.ServiceConfiguration>> configurationAction)
      Accepts the DSL configuration for the services 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:
      configurationAction - the configuration action for the services block
    • getSharedConfigurationFile

      public Property<String> getSharedConfigurationFile()
      Returns the custom shared configuration file 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 custom shared configuration file to use
      See Also:
    • getSummary

      public Property<Boolean> getSummary()
      Returns the flag that, when true, prints a state summary to the console. 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:
    • getSummaryFile

      public Property<String> getSummaryFile()
      Returns the optional path where to save the summary 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
    • getStateFile

      public Property<String> 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
    • getSubstitutions

      public NyxExtension.Substitutions getSubstitutions()
      Returns the object mapping the substitutions 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 substitutions block
    • substitutions

      public void substitutions(Action<? super NyxExtension.Substitutions> configurationAction)
      Accepts the DSL configuration for the substitutions 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:
      configurationAction - the configuration action for the substitutions block
    • 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