-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Third-party plugins cannot be applied by ID from external build scripts #1262
Comments
Big +1 to this. Another (related) place where this is an issue is init scripts. |
I think that rather than fixing this issue we should address remaining gaps and un-incubate new plugin DSL. As a part of that we should allow the plugins block in all script types including script plugins. |
@pioterj That would be another option. The |
Yes, that's what I meant by addressing the remaining gaps.
This is already available. |
Having this fixed would be highly appreciated! |
Probably the same root cause as #1894 (Unable to refer classes from extenal plugins in other *.gradle files). |
Is there any update for this? I'm trying to use the OWASP dependency check plugin in an external gradle script because we have hundreds of repositories and we don't want to include it in all the build.gradle files in each repo. This is the plugin - https://github.com/jeremylong/dependency-check-gradle I'm getting this when the following is added to an external gradle script. external-script.gradle: buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath "org.owasp:dependency-check-gradle:2.1.1"
}
}
allprojects {
apply plugin: 'org.owasp.dependencycheck'
} Error:
|
@bzon your issue may be fixed by putting
Instead of
|
Any update on this issue. Fixing this issue will help maintain organization wide gradle files which can be directly imported (apply from) into new projects. |
Any update on the status of this? @wilkinsona have you seen this before? I tried to put |
Following a discussion on twitter with @melix on how to improve error message, in this case that the plugin with id cannot be found :
I propose the exception message suggest possible reasons for the error to happen, in this case one of the reason is this issue. Gradle could fail with a message like this (à la Mockito)
Also in this regard the website https://plugins.gradle.org/ could link to these issues where the plugin id cannot be used. Also it could be useful to also describe the way to apply a plugin with the class (with a warning of course). |
|
@emersonf Instead of :
use
You need to refer to the |
Looks like this bug is not going to be fixed for a while. Can we at least improve the error message? Something like:
|
Really looking forward to see this fixed. Took two hours of my time today... |
So I know this is fairly old, but I've ran into issues trying to use the plugin DSL in
Using
Should I make a separate issue for it on the kotlin dsl repo? |
reference > gradle/gradle#1262 (comment)
Note that it is now recommended to use the Example: https://docs.gradle.org/6.7-rc-2/samples/sample_convention_plugins.html |
But that doesn't make this issue less a bug, does it? |
Temporal fix based on gradle/gradle#1262
https://docs.gradle.org/current/userguide/plugins.html#sec:build_scripts_only
Is there any plan to lift this restriction? |
I bumped into that once more. The problem is still valid with 7.4.2. Sometimes, it makes Gradle scripts separation slightly harder. |
For reference, if you're looking to apply a plugin by implementation class in the Kotlin DSL, you'll have to use the following syntax: apply<com.example.package.of.ImplementationClass>() instead of apply(plugin="com.example.package.of.ImplementationClass") |
Yes, still on 8.2.1. Are there any official celebrations yet? This bug is over 6 years old ;P |
Original issue: https://issues.gradle.org/browse/GRADLE-2136
Expected Behavior
An external plugin can be applied in a script plugin by ID. The plugin can be added to the build script's classpath and applied with the plugins DSL or the
buildscript
block.Current Behavior
An external plugin can only be applied in a script plugin by type. If applied in a script plugin an exception is thrown saying that the plugin cannot be found.
Context
This is an unnecessary limitation of Gradle's plugin system. Users run into the issue all the time. The limitation is not documented.
Steps to Reproduce (for bugs)
build.gradle:
script.gradle:
Another manifestation:
The text was updated successfully, but these errors were encountered: