Skip to content

Commit 0b316d3

Browse files
committed
Fix import failure on non-java projects
1 parent 4eb8929 commit 0b316d3

File tree

5 files changed

+14
-39
lines changed

5 files changed

+14
-39
lines changed

build.gradle

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ plugins {
1717
alias libs.plugins.shadow
1818
}
1919

20-
final projectDisplayName = 'Forge Gradle Utilities'
20+
gradleutils.displayName = 'Forge Gradle Utilities'
2121
description = 'Small collection of utilities for standardizing MinecraftForge gradle scripts'
2222
base.archivesName = 'gradleutils'
2323
group = 'net.minecraftforge'
@@ -48,7 +48,7 @@ configurations {
4848
// This was added in Gradle 7, gives consumers useful errors if they are on an old version
4949
def applyGradleVersionAttribute = { Configuration configuration ->
5050
configuration.attributes {
51-
attribute(GradlePluginApiVersion.GRADLE_PLUGIN_API_VERSION_ATTRIBUTE, objects.named(GradlePluginApiVersion, libs.versions.gradle.asProvider().get()))
51+
attribute(GradlePluginApiVersion.GRADLE_PLUGIN_API_VERSION_ATTRIBUTE, objects.named(GradlePluginApiVersion, gradleutils.unpack(libs.versions.gradle)))
5252
}
5353
}
5454

@@ -73,15 +73,6 @@ dependencies {
7373
implementation libs.yaml
7474
}
7575

76-
// Removes local Gradle API from compileOnly. This is a workaround for bugged plugins.
77-
// Publish Plugin: https://github.com/gradle/plugin-portal-requests/issues/260
78-
// Shadow: https://github.com/GradleUp/shadow/pull/1422
79-
afterEvaluate { project ->
80-
project.configurations.named(JavaPlugin.COMPILE_ONLY_CONFIGURATION_NAME) { compileOnly ->
81-
compileOnly.dependencies.remove(project.dependencies.gradleApi())
82-
}
83-
}
84-
8576
license {
8677
header = rootProject.file('LICENSE-header.txt')
8778
newLine = false
@@ -98,17 +89,8 @@ tasks.named('shadowJar', ShadowJar) {
9889
relocationPrefix = 'net.minecraftforge.gradleutils.shadow'
9990
}
10091

101-
tasks.withType(GroovyCompile).configureEach {
102-
groovyOptions.optimizationOptions.indy = true
103-
}
104-
10592
tasks.withType(Javadoc).configureEach {
10693
javadocTool = javaToolchains.javadocToolFor { languageVersion = JavaLanguageVersion.of(24) }
107-
108-
options { StandardJavadocDocletOptions options ->
109-
options.windowTitle = projectDisplayName + project.version
110-
options.tags 'apiNote:a:API Note:', 'implNote:a:Implementation Note:', 'implSpec:a:Implementation Requirements:'
111-
}
11294
}
11395

11496
changelog {
@@ -122,7 +104,7 @@ gradlePlugin {
122104
plugins.register('gradleutils') {
123105
id = 'net.minecraftforge.gradleutils'
124106
implementationClass = 'net.minecraftforge.gradleutils.GradleUtilsPlugin'
125-
displayName = projectDisplayName
107+
displayName = gradleutils.displayName
126108
description = project.description
127109
tags = ['minecraftforge']
128110
}
@@ -138,7 +120,7 @@ publishing {
138120
gradleutils.promote(it)
139121

140122
pom { pom ->
141-
name = projectDisplayName
123+
name = gradleutils.displayName
142124
description = project.description
143125

144126
gradleutils.pom.addRemoteDetails(pom)
@@ -155,6 +137,3 @@ publishing {
155137
}
156138
}
157139
}
158-
159-
idea.module { downloadSources = downloadJavadoc = true }
160-
eclipse.classpath { downloadSources = downloadJavadoc = true }

gradle.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,7 @@ org.gradle.configuration-cache.problems=warn
88

99
systemProp.org.gradle.unsafe.suppress-gradle-api=true
1010

11+
net.minecraftforge.gradleutils.ide.automatic.sources=true
12+
net.minecraftforge.gradleutils.compilation.defaults=true
13+
1114
net.minecraftforge.gitversion.log.version=true

gradleutils-shared/build.gradle

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ plugins {
1313
alias libs.plugins.shadow
1414
}
1515

16-
final projectDisplayName = 'Minecraft Forge Shared Plugin Base'
16+
gradleutils.displayName = 'Minecraft Forge Shared Plugin Base'
1717
description = 'The shared base used by all of Minecraft Forge\'s Gradle plugins'
1818
base.archivesName = 'gradleutils-shared'
1919
group = 'net.minecraftforge'
@@ -54,11 +54,6 @@ tasks.named('shadowJar', ShadowJar) {
5454

5555
tasks.withType(Javadoc).configureEach {
5656
javadocTool = javaToolchains.javadocToolFor { languageVersion = JavaLanguageVersion.of(24) }
57-
58-
options { StandardJavadocDocletOptions options ->
59-
options.windowTitle = projectDisplayName + project.version
60-
options.tags 'apiNote:a:API Note:', 'implNote:a:Implementation Note:', 'implSpec:a:Implementation Requirements:'
61-
}
6257
}
6358

6459
// Allows the thin jar to be published, but won't be considered as the java-runtime variant in the module
@@ -78,7 +73,7 @@ publishing {
7873
gradleutils.promote(it)
7974

8075
pom { pom ->
81-
name = projectDisplayName
76+
name = gradleutils.displayName
8277
description = project.description
8378

8479
gradleutils.pom.addRemoteDetails(pom)
@@ -93,6 +88,3 @@ publishing {
9388
}
9489
}
9590
}
96-
97-
idea.module { downloadSources = downloadJavadoc = true }
98-
eclipse.classpath { downloadSources = downloadJavadoc = true }

settings.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ plugins {
1313
// NOTE: We need to load this into the classpath before GradleUtils for the service to load correctly
1414
id 'io.freefair.javadoc-links' version '8.14' apply false // https://plugins.gradle.org/plugin/io.freefair.javadoc-links
1515

16-
id 'net.minecraftforge.gradleutils' version '3.2.0' // https://plugins.gradle.org/plugin/net.minecraftforge.gradleutils
17-
id 'net.minecraftforge.gitversion' version '3.0.2' // https://plugins.gradle.org/plugin/net.minecraftforge.gitversion
16+
id 'net.minecraftforge.gradleutils' version '3.2.23' // https://plugins.gradle.org/plugin/net.minecraftforge.gradleutils
17+
id 'net.minecraftforge.gitversion' version '3.0.7' // https://plugins.gradle.org/plugin/net.minecraftforge.gitversion
1818
}
1919

2020
rootProject.name = 'gradleutils'
@@ -34,7 +34,7 @@ dependencyResolutionManagement {
3434
version 'gradle-javadoc-links', '8.14'
3535

3636
plugin 'licenser', 'net.minecraftforge.licenser' version '1.2.0' // https://plugins.gradle.org/plugin/net.minecraftforge.licenser
37-
plugin 'changelog', 'net.minecraftforge.changelog' version '3.0.2' // https://plugins.gradle.org/plugin/net.minecraftforge.changelog
37+
plugin 'changelog', 'net.minecraftforge.changelog' version '3.0.6' // https://plugins.gradle.org/plugin/net.minecraftforge.changelog
3838
plugin 'plugin-publish', 'com.gradle.plugin-publish' version '1.3.1' // https://plugins.gradle.org/plugin/com.gradle.plugin-publish
3939
plugin 'shadow', 'com.gradleup.shadow' version '9.0.2' // https://plugins.gradle.org/plugin/com.gradleup.shadow
4040

src/main/groovy/net/minecraftforge/gradleutils/GradleUtilsExtensionImpl.groovy

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import org.gradle.api.provider.ProviderFactory
2424
import org.gradle.api.publish.PublishingExtension
2525
import org.gradle.api.publish.maven.MavenPublication
2626
import org.gradle.api.publish.maven.tasks.PublishToMavenRepository
27+
import org.gradle.api.specs.Spec
2728
import org.gradle.api.tasks.TaskProvider
2829
import org.gradle.api.tasks.compile.GroovyCompile
2930
import org.gradle.api.tasks.compile.JavaCompile
@@ -162,7 +163,7 @@ import static net.minecraftforge.gradleutils.GradleUtilsPlugin.LOGGER
162163
// Shadow: https://github.com/GradleUp/shadow/pull/1422
163164
if (this.providers.systemProperty('org.gradle.unsafe.suppress-gradle-api').map(Boolean.&parseBoolean).getOrElse(false)) {
164165
final gradleApi = project.dependencies.gradleApi()
165-
project.configurations.named(JavaPlugin.COMPILE_ONLY_CONFIGURATION_NAME) { compileOnly ->
166+
project.configurations.named(JavaPlugin.COMPILE_ONLY_CONFIGURATION_NAME.&equals as Spec<String>).configureEach { compileOnly ->
166167
compileOnly.withDependencies { it.remove(gradleApi) }
167168
}
168169
}

0 commit comments

Comments
 (0)