Skip to content

Commit d0e1da5

Browse files
committed
Fix workaround for local Gradle API suppression not working
1 parent 3a88914 commit d0e1da5

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

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

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package net.minecraftforge.gradleutils
66

77
import groovy.transform.CompileStatic
88
import groovy.transform.PackageScope
9+
import org.codehaus.groovy.runtime.InvokerHelper
910
import org.gradle.api.Action
1011
import org.gradle.api.Project
1112
import org.gradle.api.artifacts.repositories.MavenArtifactRepository
@@ -75,6 +76,10 @@ import static net.minecraftforge.gradleutils.GradleUtilsPlugin.LOGGER
7576
}
7677
}
7778

79+
def methodMissing(String name, def args) {
80+
InvokerHelper.invokeStaticMethod(GradleUtilsProblems, name, args)
81+
}
82+
7883
@Override
7984
Action<MavenArtifactRepository> getPublishingForgeMaven(String fallbackPublishingEndpoint) {
8085
this.getPublishingForgeMaven(fallbackPublishingEndpoint, this.rootDirectory.dir('repo'))
@@ -148,19 +153,22 @@ import static net.minecraftforge.gradleutils.GradleUtilsPlugin.LOGGER
148153

149154
project.tasks.register(GenerateActionsWorkflow.NAME, GenerateActionsWorkflowImpl)
150155

156+
// NOTE: Gradle#projectsEvaluates ensures that this runs after everything else, including other plugins.
157+
project.gradle.projectsEvaluated {
158+
// Removes local Gradle API from compileOnly. This is a workaround for bugged plugins.
159+
// Publish Plugin: https://github.com/gradle/plugin-portal-requests/issues/260
160+
// Shadow: https://github.com/GradleUp/shadow/pull/1422
161+
if (this.providers.systemProperty('org.gradle.unsafe.suppress-gradle-api').map(Boolean.&parseBoolean).getOrElse(false)) {
162+
project.configurations.named(JavaPlugin.COMPILE_ONLY_CONFIGURATION_NAME) { compileOnly ->
163+
compileOnly.dependencies.remove(project.dependencies.gradleApi())
164+
}
165+
}
166+
}
167+
151168
project.afterEvaluate { this.finish(it) }
152169
}
153170

154171
private void finish(Project project) {
155-
// Removes local Gradle API from compileOnly. This is a workaround for bugged plugins.
156-
// Publish Plugin: https://github.com/gradle/plugin-portal-requests/issues/260
157-
// Shadow: https://github.com/GradleUp/shadow/pull/1422
158-
if (this.providers.systemProperty('org.gradle.unsafe.suppress-gradle-api').map(Boolean.&parseBoolean).getOrElse(false)) {
159-
project.configurations.named(JavaPlugin.COMPILE_ONLY_CONFIGURATION_NAME) { compileOnly ->
160-
compileOnly.dependencies.remove(project.dependencies.gradleApi())
161-
}
162-
}
163-
164172
if (this.problems.test('net.minecraftforge.gradleutils.publishing.use-base-archives-name')) {
165173
project.extensions.getByType(PublishingExtension).publications.withType(MavenPublication).configureEach {
166174
it.artifactId = project.extensions.getByType(BasePluginExtension).archivesName

0 commit comments

Comments
 (0)