1
1
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
2
+ import org.gradle.api.attributes.plugin.GradlePluginApiVersion
2
3
3
4
plugins {
4
- id ' dev.gradleplugins.gradle-plugin-development' apply false
5
- id ' java'
5
+ id ' java-gradle-plugin'
6
6
id ' groovy'
7
7
id ' idea'
8
8
id ' eclipse'
9
9
id ' maven-publish'
10
10
alias libs. plugins. licenser
11
11
alias libs. plugins. gradleutils
12
- alias libs. plugins. plugin. publish apply false
12
+ alias libs. plugins. plugin. publish
13
13
alias libs. plugins. shadow
14
14
}
15
15
16
- // NOTE: Applying the Plugin Publish plugin causes local Gradle dependencies to be used
17
- // To develop using the target Gradle and Groovy versions, set this to 'false'
18
- final inCI = providers. environmentVariable(' CI' ). < boolean > map({ ' true' . equalsIgnoreCase it }). getOrElse(false )
19
-
20
- apply {
21
- if (! inCI) return
22
- plugin ' dev.gradleplugins.gradle-plugin-development'
23
- plugin libs. plugins. plugin. publish. get(). pluginId
24
- }
25
-
26
16
final projectDisplayName = ' Forge Gradle Utilities'
27
17
description = ' Small collection of utilities for standardizing MinecraftForge gradle scripts'
28
18
group = ' net.minecraftforge'
@@ -31,22 +21,29 @@ version = gitversion.tagOffset
31
21
println " Version: $version "
32
22
33
23
// Git Version requires Java 17
34
- java {
35
- toolchain. languageVersion = JavaLanguageVersion . of 17
36
- withSourcesJar()
37
- withJavadocJar()
38
- }
24
+ java. toolchain. languageVersion = JavaLanguageVersion . of 17
39
25
40
26
configurations {
27
+ // Applies the "Gradle Plugin API Version" attribute to configuration
28
+ // This was added in Gradle 7, gives consumers useful errors if they are on an old version
29
+ def applyGradleVersionAttribute = { Configuration configuration ->
30
+ configuration. attributes {
31
+ attribute org.gradle.api.attributes.plugin.GradlePluginApiVersion . GRADLE_PLUGIN_API_VERSION_ATTRIBUTE , objects. named(GradlePluginApiVersion , libs. versions. gradle. get())
32
+ }
33
+ }
34
+
35
+ named JavaPlugin . API_ELEMENTS_CONFIGURATION_NAME , applyGradleVersionAttribute
36
+ named JavaPlugin . RUNTIME_ELEMENTS_CONFIGURATION_NAME , applyGradleVersionAttribute
37
+
41
38
named(JavaPlugin . RUNTIME_CLASSPATH_CONFIGURATION_NAME ) {
39
+ // Fixes a conflict between Git Version's shadowed SLF4J from JGit and Gradle's own loggers
42
40
exclude group : ' org.slf4j' , module : ' slf4j-api'
43
41
}
44
42
}
45
43
46
44
dependencies {
47
45
// Gradle API
48
- compileOnly gradleApi(libs. versions. gradle. get())
49
- compileOnly libs. groovy
46
+ compileOnly libs. gradle
50
47
compileOnly libs. nulls
51
48
52
49
// GitHub Actions Workflows
@@ -59,8 +56,18 @@ dependencies {
59
56
implementation libs. jgit
60
57
}
61
58
59
+ // Removes local Gradle API from compileOnly. This is a workaround for bugged plugins.
60
+ // TODO [GradleUtils][GradleAPI] Remove this once they are fixed.
61
+ // Publish Plugin: https://github.com/gradle/plugin-portal-requests/issues/260
62
+ // Shadow: https://github.com/GradleUp/shadow/pull/1422
63
+ afterEvaluate { project ->
64
+ project. configurations. named(JavaPlugin . COMPILE_ONLY_CONFIGURATION_NAME ) { compileOnly ->
65
+ compileOnly. dependencies. remove project. dependencies. gradleApi()
66
+ }
67
+ }
68
+
62
69
license {
63
- header = file( ' LICENSE-header.txt' )
70
+ header = rootProject . file ' LICENSE-header.txt'
64
71
newLine = false
65
72
exclude ' **/*.properties'
66
73
}
@@ -79,13 +86,15 @@ tasks.withType(GroovyCompile).configureEach {
79
86
groovyOptions. optimizationOptions. indy = true
80
87
}
81
88
82
- // TODO [GradleUtils][GU3] Remove, as normal JavaDocs are used instead, with Groovy classes being hidden impl
89
+ // TODO [GradleUtils][GU3.0 ] Remove, as normal JavaDocs are used instead, with Groovy classes being hidden impl
83
90
// javadocJar is created after evaluation, so we need to configure it here
84
91
afterEvaluate {
85
92
tasks. named(' javadoc' , Javadoc ) { enabled = false }
86
93
tasks. named(' groovydoc' , Groovydoc ) { use = true }
87
94
88
95
tasks. named(' javadocJar' , Jar ) {
96
+ final groovydoc = tasks. named(' groovydoc' , Groovydoc ). get()
97
+
89
98
dependsOn groovydoc
90
99
from groovydoc. destinationDir
91
100
}
@@ -96,9 +105,7 @@ changelog {
96
105
publishAll = false
97
106
}
98
107
99
- // weird null-safe ?.tap is in case this extension doesn't exist.
100
- // see start of the buildscript. it's conditionally applied.
101
- extensions. findByType(GradlePluginDevelopmentExtension )?. tap {
108
+ gradlePlugin {
102
109
website. set gitversion. url
103
110
vcsUrl. set gitversion. url + ' .git'
104
111
@@ -122,8 +129,6 @@ extensions.findByType(GradlePluginDevelopmentExtension)?.tap {
122
129
123
130
publishing {
124
131
publications. register(' pluginMaven' , MavenPublication ) {
125
- if (! inCI) from components. java
126
-
127
132
artifactId = project. name
128
133
129
134
changelog. publish it
@@ -138,7 +143,7 @@ publishing {
138
143
license gradleutils.pom.licenses.LGPLv2_1
139
144
}
140
145
141
- // TODO [GradleUtils] Re-evaluate active developers in GU 3.0
146
+ // TODO [GradleUtils][GU3.0] Re-evaluate active developers in GU 3.0
142
147
developers {
143
148
developer gradleutils.pom.developers.LexManos
144
149
developer gradleutils.pom.developers.SizableShrimp
0 commit comments