Is there a clean or better way to apply the plugin...
# community-support
r
Is there a clean or better way to apply the plugin written in included build as well as in the builds which includes the included build.
Curious to hear how others have solved this šŸ” 🄚 problem, without relying on applied script plugins.
v
You mean applying the plugin you build in a build to the build that builds the plugin? I guess I'd just apply a previously published version of it and upgrade that after the next publication.
šŸ‘ 1
r
You mean applying the plugin you build in a build to the build that builds the plugin?
Yea
> I guess I'd just apply a previously published version of it and upgrade that after the next publication. This works, if you are pushing it to the artifactory and the to be consumed as a binary plugin.
Unrelated question, if you apply a different settings plugin in settings.gradle.kts, which project does it gets applied to, the root project only? I looked for documentation but couldn't find this info, but from my testing it looks like only root-project, as the root-project is included by default without any include() šŸ¤”
v
This works, if you are pushing it to the artifactory and the to be consumed as a binary plugin
Yes. If not, you do not have much chances, not in a clean way. Depending on what it is you need, you could for example move the part you need in both builds to yet another included build that you then include from both builds.
Unrelated question, if you apply a different settings plugin in settings.gradle.kts, which project does it gets applied to, the root project only?
I don't get the question. Why should a setting plugin ever be applied to a project? That would just blow up, as it is a settings plugin, not a project plugin. A plugin is applied where you apply it.
r
Yea, you are right, thanks. I think i got confused with few things.
šŸ‘Œ 1
Well, i don't like my current solution, but i went ahead with a hacky solution. In included build add the plugin by type -
apply<MyCustomPlugin::class.java>
once it's in the class-path where i want it. For the build which consumes the included build, apply it by ID.
v
But how do you get it on the classpath?
r
Ignore, my previous message - i thought i got it working. Looks like i was much invested into it, making it somehow work without going into the trouble of additional setup.
Thing is, i cannot even have a separate included build, because that build can also throw UnknownException/SocketTimeOut or other exceptions. What i want is any exception thrown in the project as whole, should be caught by my plugin. As you already called out above • either take the approach of binary plugin • or, duplicate logic not sure if there are other ways or hacks to do it, i would be fine with any non-cleaner way or hacks atm and then convert it to binary plugin later by pushing it in our artifactory.
v
Well, the not so clean way you already stated. Legacy script plugin.