-
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
Unable to apply script plugin from precompiled script plugin #14517
Comments
There's no intention to ever make this work, but we should forbid it directly if we can. Our recommendation would be to convert the script plugin into another precompiled script plugin and apply that. |
Thanks for the feedback.
The script common script plugin I'm trying to apply here simply populates the project extra properties with dependency versions so that they can be reused across the subprojects. With that in mind I doubt it would be desirable to make it into another precompiled script plugin (i.e. move it to |
Ah, ok. We're working on making the recommendations and documentation around that use case better in the next release (6.8 or so). In short, what you can do is instead define a separate subproject that defines all of the versions you want to share. This is what we do in the Gradle build: We define a platform. Defining the list of Then in each of the subprojects, instead of doing something like:
You'd instead do (no version information):
And in each subproject, you'd also add the platform as a dependency:
The platform acts similar to a Maven BOM and shows up in reports as the source of the version information: e.g., see how HTH /cc @donat |
Thanks for the suggestions @big-guy. Having taken a closer look at the Platform plugin docs, I now see the sharing a set of dependency versions between subprojects use case you described there. Typically, I only considered the Platform plugin for the other two cases, but I like the idea of using it this way as well. However, my concern is that this would imply the need to publish such a platform subproject. I'd like to avoid that as platform that centralizes the dependency management between subproject is likely to cover both subprojects that are published and the internal ones. Moreover, if I decided to publish a platform that links to subprojects as described here, that would mean I've got two published platforms which could potentially be confusing for the consumers. I lurked around and found this sample demoing the concept of an internal platform. Is this something you'd recommend or even consider providing first-class support in future Gradle releases? |
@jjohannes ☝️ maybe you could chime in on what the internal platform meant? |
@vpavic yes you can use an "internal platform" (working title ;)) for this. This is not a built-in feature of Gradle (yet) though (#10861). To set it up as in the sample, you need to define a configuration to declare the dependency to the platform that is not part of the published dependencies. As it is done here: https://github.com/jjohannes/gradle-demos/blob/master/internal-platform/build.gradle.kts#L9-L19 This solution is also described in more detail here: #10861 (comment) You then need to be careful when publishing that you publish enough version information, or use publishing of resolved versions. |
Thanks @jjohannes, the internal platform approach worked great for me. 👍 It was exactly what I was looking for both from the perspective of build logic organization as well as the resulting publications. I'll follow #10861 for further developments on that approach. Back to the originally reported problem, after some exploration it seems that it's not limited to only applying script plugin from precompiled script plugin but rather any use of the old syntax of applying plugins meaning it can be reproduced even with something like This IMO adds to the already confusing situation with
|
Yes the docs need some updates to clarify the situation. We are on it. We are moving towards making the |
Just ran into this issue, maybe we could display a more helpful error message. It was actually rather simple to change the |
Note: add forbidding it explicitly, see Sterling's comment from the 15th of September. |
If I understand your original issue @vpavic. You wanted to apply script plugin inside of precompiled script plugin and it doesn't work? As I am afraid I have the same issue atm. |
We should clarify documentation to indicate that |
Same problem in Gradle 8.7… Workaround is: |
I'm not sure whether this is a defect or simply a limitation that appears to be undocumented, below are the details.
Expected Behavior
Applying the common script plugin should be possible using precompiled script plugin in order to share the common build login between subprojects.
Current Behavior
Attempt to do so results in
org.gradle.internal.service.UnknownServiceException: No service of type ClassLoaderScope available in ProjectScopeServices.
.Context
I've run into this while trying to align with the latest recommendations on organizing multi-project builds.
Applying the script plugin is of course possible from the
subprojects
block (as shown in the reproduction project) or within a custom plugin using something like:Steps to Reproduce
Clone the sample project and make the following changes:
8b39720
build.gradle:3
buildSrc/src/main/groovy/sample.java-conventions.gradle:10
Attempt to run any task results in:
Your Environment
The text was updated successfully, but these errors were encountered: