Package com.mooltiverse.oss.nyx.gradle
Class NyxExtension
java.lang.Object
com.mooltiverse.oss.nyx.gradle.NyxExtension
The plugin configuration object. This object is responsible for reading the
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
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:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
The class to model a single 'releaseAssets' item within the extension.static class
The class to model the 'changelog' block within the extension.static class
The class to model the 'commitMessageConventions' block within the extension.static class
The class to model the 'git' block within the extension.static class
The class to model the 'releaseTypes' block within the extension.static class
The class to model a single 'services' item within the extension.static class
The class to model the 'substitutions' block within the extension. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
changelog
(Action<? super NyxExtension.ChangelogConfiguration> configurationAction) Accepts the DSL configuration for thechangelog
block, needed for defining the block using the curly braces syntax in Gradle build scripts.void
commitMessageConventions
(Action<? super NyxExtension.CommitMessageConventions> configurationAction) Accepts the DSL configuration for thecommitMessageConventions
block, needed for defining the block using the curly braces syntax in Gradle build scripts.static NyxExtension
Creates the extension into the given settings.static NyxExtension
Creates the extension into the given project.getBump()
Returns the name of the version identifier to bump.Returns the object mapping thechangelog
block.Returns the object mapping thecommitMessageConventions
block.Returns the custom configuration file to use.Returns the directory to use as the base repository location.Returns the flag that, whentrue
, prevents Nyx from applying any change to the repository or any other resource.getGit()
Returns the object mapping thegit
block.Returns the initial version to use when no past version can be inferred from the commit history.protected abstract ObjectFactory
Returns an object factory instance.Returns the selected preset configuration name.Returns the object mapping thereleaseAssets
block.Returns the flag that, whentrue
, lets Nyx interpret release names with whatever prefix.Returns the prefix used to generate release names.Returns the object mapping thereleaseTypes
block.Returns the flag that, whentrue
, loads a previously saved state file (if any) to resume execution from there.Returns the versioning scheme to use.Returns the object mapping theservices
block.Returns the custom shared configuration file to use.Returns the optional path where to save the state file.Returns the object mapping thesubstitutions
block.Returns the flag that, whentrue
, prints a state summary to the console.Returns the optional path where to save the summary file.Returns the logging verbosity.void
git
(Action<? super NyxExtension.GitConfiguration> configurationAction) Accepts the DSL configuration for thegit
block, needed for defining the block using the curly braces syntax in Gradle build scripts.void
releaseAssets
(Action<? super NamedDomainObjectContainer<NyxExtension.AssetConfiguration>> configurationAction) Accepts the DSL configuration for thereleaseAssets
block, needed for defining the block using the curly braces syntax in Gradle build scripts.void
releaseTypes
(Action<? super NyxExtension.ReleaseTypes> configurationAction) Accepts the DSL configuration for thereleaseTypes
block, needed for defining the block using the curly braces syntax in Gradle build scripts.void
services
(Action<? super NamedDomainObjectContainer<NyxExtension.ServiceConfiguration>> configurationAction) Accepts the DSL configuration for theservices
block, needed for defining the block using the curly braces syntax in Gradle build scripts.void
substitutions
(Action<? super NyxExtension.Substitutions> configurationAction) Accepts the DSL configuration for thesubstitutions
block, needed for defining the block using the curly braces syntax in Gradle build scripts.
-
Field Details
-
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
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
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
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
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
Returns the object mapping thechangelog
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
Accepts the DSL configuration for thechangelog
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 thechangelog
block
-
getCommitMessageConventions
Returns the object mapping thecommitMessageConventions
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 thecommitMessageConventions
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 thecommitMessageConventions
block
-
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
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
Returns the flag that, whentrue
, 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 thegit
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
Accepts the DSL configuration for thegit
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 thegit
block
-
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
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 thereleaseAssets
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 thereleaseAssets
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 thereleaseAssets
block
-
getReleaseLenient
Returns the flag that, whentrue
, 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
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
Returns the object mapping thereleaseTypes
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
Accepts the DSL configuration for thereleaseTypes
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 thereleaseTypes
block
-
getResume
Returns the flag that, whentrue
, 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
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 theservices
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 theservices
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 theservices
block
-
getSummary
Returns the flag that, whentrue
, 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
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
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
Returns the object mapping thesubstitutions
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
Accepts the DSL configuration for thesubstitutions
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 thesubstitutions
block
-
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
-