Gradle 1.12-rc-2: MavenPublish "groupId cannot be empty"


(John Engelman) #1

Just testing out the latest RC and ran into a problem with an existing build. It seems that a change in the MavenPublish code requires that

project.group

is set BEFORE the

publishing {}

block is configured. Otherwise you receive the error:

* What went wrong:
Execution failed for task ':publishPluginPublicationToMavenLocal'.
> Failed to publish publication 'plugin' to repository 'MavenLocal'
   > Invalid publication 'plugin': groupId cannot be empty.

Workaround is to move the

group = 'some.group.name'

to before the publications are declared.


(John Engelman) #2

Actually, it looks like none of the configuration for the publication works if the publication is declared first. Dependencies do not show up in the POM if they are declared after declaring the publication either.


(Peter Niederwieser) #3

Can you please check if this is a regression from 1.11?


(John Engelman) #4

Sure. I’m actually having trouble reproducing this in a new project. So it might just be something with my project. I’ll post an update soon.


(John Engelman) #5

Ok, so I think I tracked this down and just being an issue with my setup doing this:

bintrayUpload { task ->
  dependsOn project.publishing.publications.foo.artifacts
}

looks like this didn’t work for PublishToMavenLocal for while (as far back as Gradle 1.9), I think I just never did it before, so never encountered the problem till today.

Declaring the ‘dependsOn’ that way forces a resolve on the publication and the groupId would need to be declared at that point, so this seems like correct behavior. I’m satisfied with that answer.