Class Configuration
- java.lang.Object
-
- com.mooltiverse.oss.nyx.configuration.Configuration
-
public class Configuration extends Object implements Root
The Nyx configuration. The configuration is a live object that resolves each option lazily, only when required. This not only improves the overall performances but is also safer as in case of malformed configuration options, only those actually needed are resolved. This means that even if the configuration sources don't change throughout a release process, the state of the configuration may change every time a not yet resolved oprion is requested and evaluated. The configuration is layered, where each layer represents a source of configuration options. There is a clear definition of priorities among different layers so there is a clear precedence of options coming from one layer or another. Thanks to this, each option can be overridden by other layer with higher priority. There must be only one instance of this class for every execution and it's retrieved byNyx.configuration()
.
-
-
Constructor Summary
Constructors Constructor Description Configuration()
Default constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getBump()
Returns the version identifier to bump as it's defined by this configuration.CommitMessageConventions
getCommitMessageConventions()
Returns the commit message convention configuration block.File
getDirectory()
Returns the directory to use as the working directory as it's defined by this configuration.Boolean
getDryRun()
Returns the value of the dry run flag as it's defined by this configuration.String
getInitialVersion()
Returns the initial version defined by this configuration to use when no past version is available in the commit history.Boolean
getReleaseLenient()
Returns the flag that enables tolerance in reading release names with arbitrary prefixes or extra non critical characters as it's defined by this configuration.String
getReleasePrefix()
Returns the prefix to use in release name generation as it's defined by this configuration.Boolean
getResume()
Returns the value of the resume flag as it's defined by this configuration.Scheme
getScheme()
Returns the versioning scheme to use as it's defined by this configuration.String
getStateFile()
Returns the path to the file where the NyxState
must be saved as it's defined by this configuration.Verbosity
getVerbosity()
Returns the logging verbosity level as it's defined by this configuration.String
getVersion()
Returns the version defined by this configuration.static void
setDefaultDirectory(File directory)
This method allows to override the default directory that will be returned bygetDirectory()
.Configuration
withCommandLineConfiguration(ConfigurationLayer layer)
Adds, replaces or removes the layer at theLayerPriority.COMMAND_LINE
level.Configuration
withPluginConfiguration(ConfigurationLayer layer)
Adds, replaces or removes the layer at theLayerPriority.PLUGIN
level.
-
-
-
Constructor Detail
-
Configuration
public Configuration() throws DataAccessException, IllegalPropertyException
Default constructor. Returns a new configuration object at its initial state. Instances if this class are created using theNyx.configuration()
method so this constructor should never be used alone. SeeNyx.configuration()
- Throws:
DataAccessException
- in case data cannot be read or accessed.IllegalPropertyException
- in case some option has been defined but has incorrect values or it can't be resolved.
-
-
Method Detail
-
withCommandLineConfiguration
public Configuration withCommandLineConfiguration(ConfigurationLayer layer) throws DataAccessException, IllegalPropertyException
Adds, replaces or removes the layer at theLayerPriority.COMMAND_LINE
level.- Parameters:
layer
- the configuration layer to set at theLayerPriority.COMMAND_LINE
level. Ifnull
any existing configuration layer at the same level is removed (if any).- Returns:
- a reference to this same object.
- Throws:
DataAccessException
- in case data cannot be read or accessed.IllegalPropertyException
- in case some option has been defined but has incorrect values or it can't be resolved.
-
withPluginConfiguration
public Configuration withPluginConfiguration(ConfigurationLayer layer) throws DataAccessException, IllegalPropertyException
Adds, replaces or removes the layer at theLayerPriority.PLUGIN
level.- Parameters:
layer
- the configuration layer to set at theLayerPriority.PLUGIN
level. Ifnull
any existing configuration layer at the same level is removed (if any).- Returns:
- a reference to this same object.
- Throws:
DataAccessException
- in case data cannot be read or accessed.IllegalPropertyException
- in case some option has been defined but has incorrect values or it can't be resolved.
-
getBump
public String getBump() throws DataAccessException, IllegalPropertyException
Returns the version identifier to bump as it's defined by this configuration.- Specified by:
getBump
in interfaceRoot
- Returns:
- the configured value for this option or
null
if the value hasn't been defined. - Throws:
DataAccessException
- in case the option cannot be read or accessed.IllegalPropertyException
- in case the option has been defined but has incorrect values or it can't be resolved.
-
getCommitMessageConventions
public CommitMessageConventions getCommitMessageConventions() throws DataAccessException, IllegalPropertyException
Returns the commit message convention configuration block.- Specified by:
getCommitMessageConventions
in interfaceRoot
- Returns:
- the commit message convention configuration block. Never
null
. - Throws:
DataAccessException
- in case the option cannot be read or accessed.IllegalPropertyException
- in case the option has been defined but has incorrect values or it can't be resolved.
-
getDirectory
public File getDirectory() throws DataAccessException, IllegalPropertyException
Returns the directory to use as the working directory as it's defined by this configuration.- Specified by:
getDirectory
in interfaceRoot
- Returns:
- the configured value for this option or
null
if the value hasn't been defined. - Throws:
DataAccessException
- in case the option cannot be read or accessed.IllegalPropertyException
- in case the option has been defined but has incorrect values or it can't be resolved.- See Also:
State.getDirectory()
-
setDefaultDirectory
public static void setDefaultDirectory(File directory)
This method allows to override the default directory that will be returned bygetDirectory()
.- Parameters:
directory
- the new default directory. Ifnull
then the standard default directory will be used.
-
getDryRun
public Boolean getDryRun() throws DataAccessException, IllegalPropertyException
Returns the value of the dry run flag as it's defined by this configuration.- Specified by:
getDryRun
in interfaceRoot
- Returns:
- the configured value for this option or
null
if the value hasn't been defined. - Throws:
DataAccessException
- in case the option cannot be read or accessed.IllegalPropertyException
- in case the option has been defined but has incorrect values or it can't be resolved.
-
getInitialVersion
public String getInitialVersion() throws DataAccessException, IllegalPropertyException
Returns the initial version defined by this configuration to use when no past version is available in the commit history.- Specified by:
getInitialVersion
in interfaceRoot
- Returns:
- the configured value for this option or
null
if the value hasn't been defined. - Throws:
DataAccessException
- in case the option cannot be read or accessed.IllegalPropertyException
- in case the option has been defined but has incorrect values or it can't be resolved.
-
getReleasePrefix
public String getReleasePrefix() throws DataAccessException, IllegalPropertyException
Returns the prefix to use in release name generation as it's defined by this configuration.- Specified by:
getReleasePrefix
in interfaceRoot
- Returns:
- the configured value for this option or
null
if the value hasn't been defined. - Throws:
DataAccessException
- in case the option cannot be read or accessed.IllegalPropertyException
- in case the option has been defined but has incorrect values or it can't be resolved.
-
getReleaseLenient
public Boolean getReleaseLenient() throws DataAccessException, IllegalPropertyException
Returns the flag that enables tolerance in reading release names with arbitrary prefixes or extra non critical characters as it's defined by this configuration.- Specified by:
getReleaseLenient
in interfaceRoot
- Returns:
- the configured value for this option or
null
if the value hasn't been defined. - Throws:
DataAccessException
- in case the option cannot be read or accessed.IllegalPropertyException
- in case the option has been defined but has incorrect values or it can't be resolved.
-
getResume
public Boolean getResume() throws DataAccessException, IllegalPropertyException
Returns the value of the resume flag as it's defined by this configuration.- Specified by:
getResume
in interfaceRoot
- Returns:
- the configured value for this option or
null
if the value hasn't been defined. - Throws:
DataAccessException
- in case the option cannot be read or accessed.IllegalPropertyException
- in case the option has been defined but has incorrect values or it can't be resolved.
-
getScheme
public Scheme getScheme() throws DataAccessException, IllegalPropertyException
Returns the versioning scheme to use as it's defined by this configuration.- Specified by:
getScheme
in interfaceRoot
- Returns:
- the configured value for this option or
null
if the value hasn't been defined. - Throws:
DataAccessException
- in case the option cannot be read or accessed.IllegalPropertyException
- in case the option has been defined but has incorrect values or it can't be resolved.
-
getStateFile
public String getStateFile() throws DataAccessException, IllegalPropertyException
Returns the path to the file where the NyxState
must be saved as it's defined by this configuration.- Specified by:
getStateFile
in interfaceRoot
- Returns:
- the configured value for this option or
null
if the value hasn't been defined. - Throws:
DataAccessException
- in case the option cannot be read or accessed.IllegalPropertyException
- in case the option has been defined but has incorrect values or it can't be resolved.
-
getVerbosity
public Verbosity getVerbosity() throws DataAccessException, IllegalPropertyException
Returns the logging verbosity level as it's defined by this configuration. Please note that the verbosity option is actually ignored in this library implementation as the event filtering based on the verbosity needs to be configured outside this library, depending on the logging framework deployed along with SLF4J. See here for more.- Specified by:
getVerbosity
in interfaceRoot
- Returns:
- the configured value for this option or
null
if the value hasn't been defined. - Throws:
DataAccessException
- in case the option cannot be read or accessed.IllegalPropertyException
- in case the option has been defined but has incorrect values or it can't be resolved.
-
getVersion
public String getVersion() throws DataAccessException, IllegalPropertyException
Returns the version defined by this configuration.- Specified by:
getVersion
in interfaceRoot
- Returns:
- the configured value for this option or
null
if the value hasn't been defined. - Throws:
DataAccessException
- in case the option cannot be read or accessed.IllegalPropertyException
- in case the option has been defined but has incorrect values or it can't be resolved.
-
-