11import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
22
33plugins {
4- id ' dev.gradleplugins.groovy-gradle-plugin'
4+ id ' java-gradle-plugin'
5+ id ' groovy'
56 id ' idea'
67 id ' eclipse'
78 id ' maven-publish'
9+ alias libs. plugins. versions
810 alias libs. plugins. licenser
911 alias libs. plugins. gradleutils
12+ alias libs. plugins. gitversion
13+ alias libs. plugins. changelog
1014 alias libs. plugins. plugin. publish
1115 alias libs. plugins. shadow
1216}
1317
14- final projectDisplayName = ' Forge Gradle Utilities'
15- description = ' Small collection of utilities for standardizing MinecraftForge gradle scripts '
18+ gradleutils . displayName = ' Forge Gradle Utilities'
19+ description = " Small collection of utilities for standardizing Forge's buildscripts. "
1620group = ' net.minecraftforge'
1721version = gitversion. tagOffset
1822
1923println " Version: $version "
2024
2125// Git Version requires Java 17
22- java. toolchain. languageVersion = JavaLanguageVersion . of 17
26+ java {
27+ toolchain. languageVersion = JavaLanguageVersion . of(17 )
28+ withSourcesJar()
29+ withJavadocJar()
30+ }
31+
32+ gradleutils. pluginDevDefaults(configurations, libs. versions. gradle)
2333
2434configurations {
2535 named(JavaPlugin . RUNTIME_CLASSPATH_CONFIGURATION_NAME ) {
@@ -28,15 +38,16 @@ configurations {
2838 }
2939}
3040
31- repositories {
32- maven { url = ' https://maven.minecraftforge.net' }
33- mavenCentral()
34- }
35-
3641dependencies {
3742 // Static Analysis
3843 compileOnly libs. nulls
3944
45+ // Gradle API
46+ compileOnly libs. gradle
47+
48+ // Versions Plugin
49+ compileOnly libs. gradle. versions
50+
4051 // GitHub Actions Workflows
4152 implementation libs. yaml
4253
@@ -47,59 +58,55 @@ dependencies {
4758 implementation libs. jgit
4859}
4960
50- // Removes local Gradle API from compileOnly. This is a workaround for bugged plugins.
51- // TODO [GradleUtils][GradleAPI] Remove this once they are fixed.
52- // Publish Plugin: https://github.com/gradle/plugin-portal-requests/issues/260
53- // Shadow: https://github.com/GradleUp/shadow/pull/1422
54- afterEvaluate { project ->
55- project. configurations. named(JavaPlugin . COMPILE_ONLY_CONFIGURATION_NAME ) { compileOnly ->
56- compileOnly. dependencies. remove project. dependencies. gradleApi()
57- }
58- }
59-
6061license {
61- header = rootProject. file ' LICENSE-header.txt'
62+ header = rootProject. file( ' LICENSE-header.txt' )
6263 newLine = false
6364 exclude ' **/*.properties'
6465}
6566
67+ tasks. named(' javadoc' , Javadoc ) {
68+ // Groovydoc is used instead
69+ enabled = false
70+ }
71+
72+ tasks. named(' groovydoc' , Groovydoc ) {
73+ use = true
74+ }
75+
6676tasks. named(' jar' , Jar ) {
6777 archiveClassifier = ' thin'
6878}
6979
7080tasks. named(' shadowJar' , ShadowJar ) {
71- enableRelocation = true
81+ enableAutoRelocation = true
7282 archiveClassifier = null
7383 relocationPrefix = ' net.minecraftforge.gradleutils.shadow'
7484}
7585
76- tasks. withType(GroovyCompile ). configureEach {
77- groovyOptions. optimizationOptions. indy = true
86+ // javadocJar is created after evaluation, so we need to configure it here
87+ afterEvaluate {
88+ tasks. named(' javadocJar' , Jar ) {
89+ final groovydoc = tasks. named(' groovydoc' , Groovydoc )
90+
91+ dependsOn = [groovydoc]
92+ archiveClassifier = ' groovydoc'
93+ from groovydoc. map(Groovydoc . &getDestinationDir)
94+ }
7895}
7996
8097changelog {
8198 fromBase()
82- publishAll = false
8399}
84100
85101gradlePlugin {
86102 website. set gitversion. url
87103 vcsUrl. set gitversion. url + ' .git'
88104
89- compatibility {
90- minimumGradleVersion = libs. versions. gradle. get()
91- }
92-
93- groovy {
94- withSourcesJar()
95- withGroovydocJar()
96- }
97-
98105 plugins {
99106 register(' gradleutils' ) {
100107 id = ' net.minecraftforge.gradleutils'
101108 implementationClass = ' net.minecraftforge.gradleutils.GradleUtilsPlugin'
102- displayName = projectDisplayName
109+ displayName = project . gradleutils . displayName . get() // project. before gradleutils otherwise it would reference itself
103110 description = project. description
104111 tags = [' minecraftforge' ]
105112 }
@@ -114,16 +121,19 @@ gradlePlugin {
114121}
115122
116123publishing {
117- publications. register(' pluginMaven' , MavenPublication ) {
118- artifactId = project. name
124+ repositories {
125+ maven gradleutils. publishingForgeMaven
126+ }
119127
120- changelog. publish it
128+ publications. register(' pluginMaven' , MavenPublication ) {
129+ changelog. publish(it)
130+ gradleutils. promote(it)
121131
122132 pom { pom ->
123- name = projectDisplayName
133+ name = gradleutils . displayName
124134 description = project. description
125135
126- gradleutils. pom. setGitHubDetails pom
136+ gradleutils. pom. addRemoteDetails( pom)
127137
128138 licenses {
129139 license gradleutils.pom.licenses.LGPLv2_1
@@ -138,10 +148,4 @@ publishing {
138148 }
139149 }
140150 }
141-
142- repositories {
143- maven gradleutils. publishingForgeMaven
144- }
145151}
146-
147- idea. module { downloadSources = downloadJavadoc = true }
0 commit comments