GradleUtils is a support plugin for NeoForged projects, which provides Git-based versioning and changelog generation.
Apply the plugin to the buildscript as normal (substitute the version with the latest version):
plugins {
id 'net.neoforged.gradleutils' version '3.0.0'
}
The gradleutils
project extension provides access to versioning. To apply the versioning configured in GradleUtils,
use the version
property on the extension. The returned object will calculate the version when toString()
ed.
Configuring the versioning is done through the related version
spec on the extension. (The difference is that
the property to access the calculated version does not accept a closure.) Configuration should be done before the
first time the version is calculated.
gradleutils.version {
// ... configure the version here ...
}
project.version = gradleutils.version
The changelog
project extension provides access to changelog generation. The changelog generation will use the same
versioning configuration, as configured in the gradleutils
project extension.
To generate a changelog, simply call the from
method on the extension with the earliest revision (tag or commit ID) to
be included. The changelog is generated by the createChangelog
task, which is linked to the assemble
task.
By default, the changelog is included in all MavenPublication
on the project as an artifact with the -changelog
classifier, if the maven-publish
plugin is applied. To manually control the changelog's publishing, call
disableAutomaticPublicationRegistration()
on the extension, and use the publish(MavenPublication)
method to attach
the changelog to publications as desired.
changelog {
from '2.0'
// For fine-grained changelog publication control
disableAutomaticPublicationRegistration()
}
publishing {
publications {
mavenJava(MavenPublication) {
// ...
changelog.publish(it) // 'it' refers to the 'mavenJava' publication
}
}
}
The net.neoforged.gradleutils.immaculate
plugin provides integration (a formatter configuration) with Immaculate.
When you apply the plugin alongside Immaculate, it automatically configures a java workflow.
Example usage in settings.gradle to apply it to all projects that contain java code:
plugins {
id 'net.neoforged.gradleutils' version '4.0.0' apply false
id 'net.neoforged.gradleutils.immaculate' version '4.0.0' apply false
id 'dev.lukebemish.immaculate' version '0.1.6' apply false
}
gradle.lifecycle.beforeProject { project ->
project.plugins.withId("java") {
apply plugin: 'dev.lukebemish.immaculate'
apply plugin: 'net.neoforged.gradleutils.immaculate'
}
}
This project is licensed under the GNU Lesser General Public License, or LGPL, version 2.1 only. See the LICENSE
file
for the full license text.