DeferredConfigurable evaluated too early

(RJ Ewing) #1

Is it possible to use the maven-publish plugin in a multi-project build? I keep getting the error Cannot configure the 'publishing' extension after it has been accessed.

I have a root project that includes a “core” project in a multi-project build.

in the root project & the “core” project build.gradle files, I have the following lines configuring the maven-publish plugin

publishing {
    repositories {
        maven {
           url "my_repo"
    publications {
        mavenJava(MavenPublication) {

If I’m in the “core” project home directory, I can successfully publish.

If I’m in the “root” project home directory, I get the error about the publishing extension already being accessed.

reading the docs, it seems like I should be able to configure the publishing plugin multiple times, as long as I don’t directly access it.

(RJ Ewing) #3

okay, I created a test project that was able to reproduce the issue in a sample project ( (99.3 KB))

If I remove the evaluationDependsOnChildren(), the error will go away, however I need to call this in my actual project.

If I remove the org.ajoberstar.release-opinion plugin, the error will go away.

I was suspecting that the release-opinion plugin was the issue, however If I place some print statements in the publishing closures, they are never called before the error occurs. Which seems to me like that means the publishing configuration is not evaluated before the error occurs.

If I apply the maven-publish plugin directly above the publishing closure in each build.gradle, it works correctly. If I apply the maven-publish plugin in the TestPlugin for each project or at the top of the build.gradle files, I get the error

Any ideas?