groupId cannot be empty

I get the below error when I use the gradle publish task,

Execution failed for task ‘:publishMavenJavaPublicationToMavenRepository’. Failed to publish publication ‘mavenJava’ to repository ‘maven’

Invalid publication ‘mavenJava’: groupId cannot be empty

To resolve this I need to specify the group id in the project though it had already been specified in settigns.gradle for all subprojects. Also - only certain projects report this error . Someprojects are able to get the group defined in the parent settings.gradle

It works fine if i use the old upload task. I am using gradle 1.10

Few observation :

The issue actually happens when i add apply plugin:‘java’ to init.gradle ( This is needed for the publishing task ) . If I remove the apply plugin:‘java’ and use the normal upload task - it works fine.

Let me know if somebody had faced this issue and found a solution.

I think i was able to figure this out .

in the build.gradle of the root project ( which has the settings.gradle ) , I had mentioned the group within the subprojects. I did not mention it touside the subprojects {}

When I mentioned the group outisde as well it worked. May be the root project is also getting published .

group='mygroup'
 subprojects {
 apply plugin: 'java'
 apply plugin: 'sonar-runner'
                  group='mygroup'
}

It’s a good idea to set ‘group’ for ‘allprojects’.