When I apply LibraryPlugin in a build.gradle file, build fails on project.publishing line in MyBasePlugin (never actually execute the second publishing in LibraryPlugin).
> Failed to apply plugin [id 'example.library']
> Failed to apply plugin [class 'com.example.MyBasePlugin']
> Cannot configure the 'publishing' extension after it has been accessed.
There are no other publishing before this and even if there were, I have seen invoking project.publishing { } multiple times across plugins work before.
This just doesn’t make sense to me. Can anyone see why this would happen? Or is there a hook I can add some logging to so I can see who is referencing it first?
That’s the frustrating part. I cannot reproduce it neither when I chuck everything in the same build.gradle file. It is only happening when they are spread out into their own classes in a binary plugin that I apply.
There is literally nothing between when MavenPublishPlugin is applied and the first instance of project.publishing {} so it is beyond me what is accessing it in that interval.
This is why I was asking if there is a way for me to find the culprit, for example through some debug logging. I think I may have to attach a debugger to this to find out what the heck is going on.
Are you sure you didn’t simplify too much your scenario ?
Maybe there is a problem with the way you publish your plugins ?
Beside these two points, there’s not much I can think of, except a Core Dev intervention
* What went wrong:
A problem occurred evaluating root project 'gradle'.
> Failed to apply plugin [class 'LibraryPlugin']
> Failed to apply plugin [class 'MyBasePlugin']
> Cannot configure the 'publishing' extension after it has been accessed.
yes, there aren’t many differences indeed …
I’m out of ideas…
maybe you can add the --debug --stacktrace output to really pinpoint the problem.
The difference between my working example and yours, concerning the project.publishing.repositories section, is that you define an url and some credentials, where I only define the maven repo name.