-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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
Transitive dependency isn't analyzed for potentially containing a plugin when plugins
configuration block is used
#18628
Comments
This issue has been automatically marked as stale because it has not had recent activity. Given the limited bandwidth of the team, it will be automatically closed if no further activity occurs. If you're interested in how we try to keep the backlog in a healthy state, please read our blog post on how we refine our backlog. If you feel this is something you could contribute, please have a look at our Contributor Guide. Thank you for your contribution. |
Sorry for the late reply! After discussing that we decided that this should not be implemented in the way you described. |
I didn’t mean that either. User should define which plugins they want to apply and where (unless a plugin applies another one internally as you mentioned). |
That part was a bit confusing, sorry for the misunderstanding. Despite that, the expected way to apply a plugin in your case is either:
File(testProjectDir, "settings.gradle.kts")
.also { it.createNewFile() }
.writeText("""
pluginManagement {
repositories {
mavenLocal()
gradlePluginPortal()
}
plugins {
id("$dependentPluginId") version "$version"
id("$dependencyPluginId") version "$version" // <-- here
}
}
""".trimIndent()) or File(testProjectDir, "settings.gradle.kts")
.also { it.createNewFile() }
.writeText("""
pluginManagement {
repositories {
mavenLocal()
gradlePluginPortal()
}
}
""".trimIndent())
File(testProjectDir, "build.gradle.kts")
.also { it.createNewFile() }
.writeText("""
plugins {
id("$dependentPluginId") version "$version"
id("$dependencyPluginId") version "$version"
}
""".trimIndent()) |
The problem with your suggestion is the ambiguity of the |
I'm glad you've mentioned plugin version example, @ov7a . pluginManagement {
plugins {
id("B") version "Bv1"
id("C") version "Cv1"
id("A") version "Av3"
}
} When someone uses in build script following code: plugins {
id("A")
id("B")
} which version of A is going to be loaded? Will there be a conflict? |
We do have a related issue for this: There's nothing special in depending on another plugin without applying it - it is the same as having some "regular" third-party library as a common dependency for multiple plugins. |
Awesome! Indeed, the overall problem can be split into two parts.
So instead of specifying the plugin IDs in Plugins Management config, Gradle could figure out additional plugin IDs from dependencies. That would allow creation of plugins bundles which are not necessary mantained by same team, or enterprises to distribute plugin definitions without asking all projects to copy-paste lots of plugin IDs in Plugin Management config. Also new settings plugins could appear which would reliably know much more about plugins that will be available in a build when that settings plugin is applied. |
I see your point, but I think the second point is covered by convention plugins in a project or by a proper plugin which combines (and applies) other plugins. If you want to reuse some code, these are the approaches you should consider. I think they should work in most (sane) cases. |
When a Gradle plugin (A) depends on other Gradle plugin (B) as transitive dependency,
then if plugin A is loaded inside
plugins
block, it doesn't mean the plugin B also can be used without being explicitly mentioned.doesn't mean
Expected Behavior
Transitive dependencies of a Gradle plugin are analyzed for potentially containing plugin descriptors too.
Current Behavior
The transitive dependency is not being analyzed, hence can not be used in build scripts.
User is required to specify the plugin ID and version in their scripts.
Adding the plugin dependency to classpath in the buildscript configuration block works. But promotes legacy way of applying plugins.
Context
My team has plugins which are re-used in lots of repositories. Those plugins can have dependency on other internal plugin binaries, or external, e.g. Android plugin.
Currently we apply our high-level plugins in a legacy way, using "buildscript" configuration block.
We would like to switch to the new way, using pluginManagement inside
settings.gradle
file, and using IDs instead of full dependency notation.Currently we can not do the transition because this would mean mentioning in
settings.gradle
files all plugins that our high-level plugins rely on. This also can lead to a wrong version being selected by user for a transitive dependency of one of our plugins, which is not ready for the newer version yet, or doesn't support an older one.We also want to keep simple the repositories where plugins are applied, so they won't require much changes and versions tracking when we update our plugins.
The reason for raising a bug, is that specifying a plugin ID inside
plugins
configuration block leads to the plugin's marker being downloaded, then the dependency it has will be downloaded and plugin would be loaded. So why not continue searching for plugins inside transitive dependencies? This could be configurable, but should be possible.It also feels like the
plugins
configuration block was designed to load only plugin IDs specified inside of it, and even if a jar file has more, it doesn't mean other plugins will be abailable for use. So maybe there's another alternative which doesn't require usage ofbuildscript
configuration, orbuildSrc
project?Steps to Reproduce
PluginDependencyIssueDemo.zip
The project contains two tests which illustrate the problem
Your Environment
Build scan URL: https://gradle.com/s/jcir4qkpwptjg
The text was updated successfully, but these errors were encountered: