11import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
2+ import org.gradle.api.attributes.plugin.GradlePluginApiVersion
23
34plugins {
4- id ' dev.gradleplugins.groovy-gradle-plugin'
5+ id ' java-gradle-plugin'
6+ id ' groovy'
57 id ' idea'
68 id ' eclipse'
79 id ' maven-publish'
810 alias libs. plugins. licenser
911 alias libs. plugins. gradleutils
12+ alias libs. plugins. javadoc. links
1013 alias libs. plugins. plugin. publish
1114 alias libs. plugins. shadow
1215}
1316
1417final projectDisplayName = ' Forge Gradle Utilities'
18+ final projectArtifactId = base. archivesName = ' gradleutils'
1519description = ' Small collection of utilities for standardizing MinecraftForge gradle scripts'
1620group = ' net.minecraftforge'
1721version = gitversion. tagOffset
1822
1923println " Version: $version "
2024
21- // Git Version requires Java 17
22- java. toolchain. languageVersion = JavaLanguageVersion . of 17
25+ java {
26+ toolchain. languageVersion = JavaLanguageVersion . of(17 )
27+ withSourcesJar()
28+ withJavadocJar()
29+ }
2330
2431configurations {
2532 named(JavaPlugin . RUNTIME_CLASSPATH_CONFIGURATION_NAME ) {
2633 // Fixes a conflict between Git Version's shadowed SLF4J from JGit and Gradle's own loggers
2734 exclude group : ' org.slf4j' , module : ' slf4j-api'
2835 }
29- }
3036
31- repositories {
32- maven { url = ' https://maven.minecraftforge.net' }
33- mavenCentral()
37+ // Applies the "Gradle Plugin API Version" attribute to configuration
38+ // This was added in Gradle 7, gives consumers useful errors if they are on an old version
39+ def applyGradleVersionAttribute = { Configuration configuration ->
40+ configuration. attributes {
41+ attribute(GradlePluginApiVersion . GRADLE_PLUGIN_API_VERSION_ATTRIBUTE , objects. named(GradlePluginApiVersion , libs. versions. gradle. get()))
42+ }
43+ }
44+
45+ // TODO [GradleUtils] Re-enable this after first publish of GradleUtils 3.0.0
46+ // named('apiElements', applyGradleVersionAttribute)
47+ // named('runtimeElements', applyGradleVersionAttribute)
48+ // named('shadowRuntimeElements', applyGradleVersionAttribute)
3449}
3550
3651dependencies {
37- // Static Analysis
52+ // Gradle API
53+ compileOnly libs. gradle
3854 compileOnly libs. nulls
3955
56+ // JavaDoc Links Plugin
57+ compileOnly libs. gradle. javadoc. links
58+
4059 // GitHub Actions Workflows
4160 implementation libs. yaml
4261
43- // Git Version
44- implementation libs. gitver
45-
46- // Backwards compatibility
47- implementation libs. jgit
62+ // Tools
63+ implementation libs. bundles. utils
4864}
4965
5066// Removes local Gradle API from compileOnly. This is a workaround for bugged plugins.
@@ -58,7 +74,7 @@ afterEvaluate { project ->
5874}
5975
6076license {
61- header = rootProject. file ' LICENSE-header.txt'
77+ header = rootProject. file( ' LICENSE-header.txt' )
6278 newLine = false
6379 exclude ' **/*.properties'
6480}
@@ -68,7 +84,7 @@ tasks.named('jar', Jar) {
6884}
6985
7086tasks. named(' shadowJar' , ShadowJar ) {
71- enableRelocation = true
87+ enableAutoRelocation = true
7288 archiveClassifier = null
7389 relocationPrefix = ' net.minecraftforge.gradleutils.shadow'
7490}
@@ -77,64 +93,58 @@ tasks.withType(GroovyCompile).configureEach {
7793 groovyOptions. optimizationOptions. indy = true
7894}
7995
96+ tasks. withType(Javadoc ). configureEach {
97+ javadocTool = javaToolchains. javadocToolFor { languageVersion = JavaLanguageVersion . of(24 ) }
98+
99+ options { StandardJavadocDocletOptions options ->
100+ options. windowTitle = projectDisplayName + project. version
101+ options. tags ' apiNote:a:API Note:' , ' implNote:a:Implementation Note:' , ' implSpec:a:Implementation Requirements:'
102+ }
103+ }
104+
80105changelog {
81106 fromBase()
82107 publishAll = false
83108}
84109
85110gradlePlugin {
86- website. set gitversion. url
87- vcsUrl. set gitversion. url + ' .git'
88-
89- compatibility {
90- minimumGradleVersion = libs. versions. gradle. get()
91- }
92-
93- groovy {
94- withSourcesJar()
95- withGroovydocJar()
111+ website = gitversion. url
112+ vcsUrl = gitversion. url + ' .git'
113+
114+ plugins. register(' gradleutils' ) {
115+ id = ' net.minecraftforge.gradleutils'
116+ implementationClass = ' net.minecraftforge.gradleutils.GradleUtilsPlugin'
117+ displayName = projectDisplayName
118+ description = project. description
119+ tags. set([' minecraftforge' ])
96120 }
121+ }
97122
98- plugins {
99- register(' gradleutils' ) {
100- id = ' net.minecraftforge.gradleutils'
101- implementationClass = ' net.minecraftforge.gradleutils.GradleUtilsPlugin'
102- displayName = projectDisplayName
103- description = project. description
104- tags = [' minecraftforge' ]
105- }
106- register(' changelog' ) {
107- id = ' net.minecraftforge.changelog'
108- implementationClass = ' net.minecraftforge.gradleutils.changelog.ChangelogPlugin'
109- displayName = ' Git Changelog'
110- description = ' Creates a changelog text file based on git history using Git Version'
111- tags = [' git' , ' changelog' ]
112- }
113- }
123+ // Allows the thin jar to be published, but won't be considered as the java-runtime variant in the module
124+ // This forces Gradle to use the fat jar when applying the plugin
125+ (components. java as AdhocComponentWithVariants ). withVariantsFromConfiguration(configurations. runtimeElements) {
126+ skip()
114127}
115128
116129publishing {
117130 publications. register(' pluginMaven' , MavenPublication ) {
118- artifactId = project. name
119-
131+ artifactId = projectArtifactId
120132 changelog. publish it
121133
122134 pom { pom ->
123135 name = projectDisplayName
124136 description = project. description
125137
126- gradleutils. pom. setGitHubDetails pom
138+ gradleutils. pom. setGitHubDetails( pom)
127139
128140 licenses {
129141 license gradleutils.pom.licenses.LGPLv2_1
130142 }
131143
132- // TODO [GradleUtils][GU3.0] Re-evaluate active developers in GU 3.0
133144 developers {
134- developer gradleutils.pom.developers.LexManos
135- developer gradleutils.pom.developers.SizableShrimp
136- developer gradleutils.pom.developers.Paint_Ninja
137145 developer gradleutils.pom.developers.Jonathing
146+ developer gradleutils.pom.developers.Paint_Ninja
147+ developer gradleutils.pom.developers.LexManos
138148 }
139149 }
140150 }
0 commit comments