Is there any callback that is fired after plugin initialization is done, but before all other build configuration code? And also after closed own plugi extension? I would like to use some features from another plugin, but afterEvaluate is too late.
It is already lazy, but it needs maven-publish to be initialized
So if I do this:
plugins {
`java-library`
`maven-publish`
id("com.mycompany.myplugin") version "0.9.1-SNAPSHOT"
}
It always fails because my plugin is initialized first.
I will check your response if there is some way to replace the<PublishingExtension>() with something more lazy.
There’s no need to worry about maven-publish being applied twice (eg once in your plugin, and another time in the client build.gradle) as Gradle applies plugins idempotently
Thanks! I will do it this way.
But what about if this dependency is optional?
I mean that my plugin can cooperate with another plugin only if it is available?
I can simply check the existence of PublishingExtension, but I cannot be sure because I don’t know the order of initialization.
void all​(Closure) - Executes the given closure against all objects in this collection, and any objects subsequently added to this collection.
And
void whenObjectAdded​(Closure) - Adds a closure to be called when an object is added to this collection
With whenObjectAdded, ordering is important (I think). If you attach a whenObjectAdded listener after the object was added to the collection, you won’t get events for these objects (I think) and will only get notified for subsequent additions. With all and matching the order is not important (you always get the event)