You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Depending on what plugins and in which order you add to gradles plugins { ... } block in the build file, forbiddenapis does not load. Using the currently documented way it works, but since the plugin was released to the Gradle Plugin Portal (see #107) this does not work:
build.gradle
plugins {
id 'java'
id 'de.thetaphi.forbiddenapis' version '2.5'
}
repositories {
jcenter()
}
group ='test'
version ='1.0.0'
sourceCompatibility =JavaVersion.VERSION_1_8
targetCompatibility =JavaVersion.VERSION_1_8
* Where:
Build file '/Users/dev/tmp/forbiddenapis/build.gradle' line: 3
* What went wrong:
An exception occurred applying plugin request [id: 'de.thetaphi.forbiddenapis', version: '2.5']
> Failed to apply plugin [id 'de.thetaphi.forbiddenapis']
> Cannot execute Groovy script for apply(Project).
> Forbidden-apis only works in projects using the java plugin.
The problem is that plugin-init.groovy check, if the JavaBasePlugin was loaded before the forbidden plugin was applied. With the new plugin mechanism it's not guaranteed.
To fix this, we change the init script to just apply the JavaBasePlugin on startup. Newer gradle plugins do this in the same way.
Unfortunately we have to release a new version. Thanks @sdavids for reporting.
The text was updated successfully, but these errors were encountered:
diff --git a/src/main/resources/de/thetaphi/forbiddenapis/gradle/plugin-init.groovy b/src/main/resources/de/thetaphi/forbiddenapis/gradle/plugin-init.groovy
index 1b0f9c4..a7f14b0 100644
--- a/src/main/resources/de/thetaphi/forbiddenapis/gradle/plugin-init.groovy+++ b/src/main/resources/de/thetaphi/forbiddenapis/gradle/plugin-init.groovy@@ -18,11 +18,8 @@
import java.lang.reflect.Modifier;
import org.gradle.api.plugins.JavaBasePlugin;
-import org.gradle.api.plugins.PluginInstantiationException;-if (project.plugins.withType(JavaBasePlugin.class).isEmpty()) {- throw new PluginInstantiationException('Forbidden-apis only works in projects using the java plugin.');-}+project.plugins.apply(JavaBasePlugin.class);
// check if running in Gradle Daemon?
// see: http://stackoverflow.com/questions/23265217/how-to-know-whether-you-are-running-inside-a-gradle-daemon
@sdavids: I was about to release a 2.5.1 bugfix release, but this fix alone does not help. To work correctly, also the fix for #138 is needed, otherwise it would not apply the tasks for all sourcesets (the "java-base" plugin does not add sourcesets, so the order is important, too).
Depending on what plugins and in which order you add to gradles
plugins { ... }
block in the build file, forbiddenapis does not load. Using the currently documented way it works, but since the plugin was released to the Gradle Plugin Portal (see #107) this does not work:build.gradle
The problem is that plugin-init.groovy check, if the
JavaBasePlugin
was loaded before the forbidden plugin was applied. With the new plugin mechanism it's not guaranteed.To fix this, we change the init script to just apply the JavaBasePlugin on startup. Newer gradle plugins do this in the same way.
Unfortunately we have to release a new version. Thanks @sdavids for reporting.
The text was updated successfully, but these errors were encountered: