Genesis Gradle Settings Plugin
The Genesis Gradle Settings plugin provides the following benefits:
- Centralised Genesis project configuration.
- Massive reduction in the number of lines of code in your Gradle files.
- Consistent configuration. For example, you won't need to remember to add a dictionary dependency - the Settings plugin will add it for you.
- Simplified development experience with the IntelliJ plugin.
There are two flavours of the Settings plugin, one which applies to the Legacy project structure and the other to the Simplified project structure. Projects existing before release 7.1.0 are in the format referred to as the Legacy structure.
This section explores the features of the Settings plugin for both structures.
How to enable?
Add the following to your "server" project's settings.gradle.kts file.
- Simplified Structure
- Legacy Structure
pluginManagement {
val genesisVersion: String by settings
plugins {
id("global.genesis.settings") version genesisVersion
}
}
plugins {
id("global.genesis.settings")
}
pluginManagement {
val genesisVersion: String by settings
plugins {
id("global.genesis.settings.legacy") version genesisVersion
}
}
plugins {
id("global.genesis.settings.legacy")
}
Common configuration
Once the Settings plugin has been applied, the genesis
extension will be available in your project's settings.gradle.kts file.
genesis {
}
There are a few common configuration options for both Legacy and Simplified. These are listed below.
Project type
There are two project types:
- PBC (Packaged Business Capability). Set this when the project contains reusable code and functionality that will be imported by other projects.
- APPLICATION is the default, and should be used at all other times.
The differences between the two are:
- When the project type is PBC, by default, the project's dictionary cache sub-modules have publishing tasks disabled. If you want to enable publishing, then disable the
genesisPublicationDisabler
plugin (see here for details). Projects with type APPLICATION will have publishing enabled for these modules. - When the project type is APPLICATION, a site-specific distribution is created in addition to the project's one.
genesis {
projectType = APPLICATION
}
Product name
By default, the product name is taken from the server Gradle project's rootProject name in the settings.gradle.kts file. You can use this property to specify a custom project name.
Example usage:
genesis {
productName = "position"
}
Dependencies
Here you should declare any dependencies on other Genesis products; this enables the Settings plugin to take care of where they should be added automatically.
Fo all the dependencies that you declare, the Settings plugin will:
- import the product's dictionary, so that the tables and views are available within your project
- capture runtime details of the product's processes, making them available to run through the Intellij plugin
- register GPAL script definitions, to help Intellij recognise these files correctly
The syntax is similar to Gradle dependencies - but not exactly the same. Specifically, you specify the group id, product name and version: "{groupId}:{productName}:{version}"
Here is an example of adding a dependency on Auth and Genesis Notify:
genesis {
dependencies {
dependency("global.genesis:auth:${extra.properties["authVersion"]}")
dependency("global.genesis:genesis-notify:${extra.properties["notifyVersion"]}")
}
}
Plugins
Other Gradle plugins that are necessary for your project are automatically added by the Settings plugin. Below you can see the plugins that are added for both Legacy and Simplified structures. These plugins can also be disabled if needed.
- Simplified Structure
- Legacy Structure
Plugin Name | Plugin ID | Description | Enabled by default |
---|---|---|---|
Kotlin | org.jetbrains.kotlin.jvm | Kotlin Gradle plugin | Yes |
Genesis Build | global.genesis.build | Core Genesis plugin to enable build tasks, including code generation | Yes |
Genesis Distribution | global.genesis.distribution | Creates the project's server distribution zip file. presently, this is based on the default configuration within the plugin. If you want to customise your distribution then you will need to disable this plugin and create your own configuration using the Gradle distribution plugin. In the future we will support customisation from this plugin directly. | Yes |
Genesis Site Specific Distribution | global.genesis.site-specific.distribution | Creates the site-specific distribution zip file. Presently, this is based on the default configuration within the plugin, the same as the Genesis Distribution plugin. | Yes, if project type is APPLICATION |
Genesis Publication Disabler | global.genesis.publication-disabler | Used to disable dictionary-cache sub-module publishing tasks if the project is of type PBC | Yes, if project type is PBC |
Genesis Exec | global.genesis.exec | Creates Gradle tasks used by the Genesis IntelliJ plugin | Yes |
Genesis Deploy | global.genesis.deploy | Creates deployment gradle tasks (Note: not required if using Genesis IntelliJ plugin for local development) | No |
Plugin Name | Plugin ID | Description | Enabled by default |
---|---|---|---|
Kotlin | org.jetbrains.kotlin.jvm | Kotlin Gradle plugin | Yes |
Genesis Build | global.genesis.build | Core Genesis plugin to enable build tasks, including code generation | Yes |
Genesis Distribution | global.genesis.distribution | Creates the project's server distribution zip file. Presently, this is based on the default configuration within the plugin. If you want to customise your distribution, you must disable this plugin and create your own configuration using the Gradle distribution plugin. In the future we will support customisation from this plugin directly. | Yes |
Genesis Site Specific Distribution | global.genesis.site-specific.distribution | Creates the site-specific distribution zip file. Presently, this is based on the default configuration within the plugin, the same as the Genesis Distribution plugin. | Yes, if project type is APPLICATION |
Genesis Exec | global.genesis.exec | Creates Gradle tasks used by the Genesis IntelliJ plugin | Yes |
Genesis Deploy | global.genesis.deploy | Creates deployment gradle tasks (Note: not required if using Genesis IntelliJ plugin for local development) | Yes |
Here is an example of disabling the Genesis Deploy plugin:
genesis {
plugins {
genesisDeploy.enabled = false
}
}
Simplified structure specific configuration
Below are the Settings plugin configurations specific to the Simplified structure.
Main module name
By default, the main module is identified by a module ending with -app.
You can also set a custom name for your main module with the property mainModuleName
. For example, this sets the main module name to "positionApp":
genesis {
mainModuleName = "position-core"
productName = "position"
}
When using this property, the productName property must also be specified.
Other features
The Settings plugin also provides some helper functions to make it simpler to add Genesis dependencies to your project.
Dependency on generated code
To add a dependency on your project's generated code in one of your project's modules, include the following in the module's build.gradle.kts file:
dependencies {
genesisGeneratedCode(withTestDependency = true)
}
The parameter withTestDependency
is an optional parameter; it adds your generated code as a test dependency. It defaults to false.
For example, if your project is named "position", this is equivalent to:
compileOnly(project(path = ":position-dictionary-cache", configuration = "codeGen"))
testImplementation(project(path = ":position-dictionary-cache", configuration = "codeGen"))
Genesis dependency
The Settings plugin automatically adds a Gradle platform dependency on the Genesis BOM and has some syntax sugar for adding dependencies on other Genesis modules. For example, if you want to add a dependency on genesis-eventhandler in a module’s build.gradle.kts file, include the following:
dependencies {
dependency(genesis("eventhandler"))
}
Gradle Configuration Cache
Genesis Gradle plugins are compatible with the Gradle configuration cache, which is enabled by default in the new project seed. This can greatly improve build times.