0

I have a multi-module project as follow:

top-level-module
  sub-module-1
  sub-module-2
  sub-module-3

Top level module gradle config looks like this:

...
def javaProjects() {
    subprojects.findAll { new File(it.projectDir, 'src/main/java').directory }
}

configure(javaProjects()) {
    apply plugin: "io.franzbecker.gradle-lombok"
    apply plugin: 'java'
    apply plugin: 'groovy'
    apply plugin: "jacoco"
    apply plugin: 'maven'
    apply plugin: 'maven-publish'

...
    publishing {
        repositories {
            maven {
                url = ...
                credentials {
                    username = ...
                    password = ...
                }
            }
        }
    }
}

sub-module-1 and sub-module-2 have a gradle config like this:

plugins {
    id 'java'
    id 'groovy'
    id 'application'
    id 'maven'
    id 'maven-publish'
}

mainClassName = 'com.mycompany.MyClass'
applicationName = 'xxx-cli' // xxx-cli is different for both modules

...

publishing {
    publications {
        XXXCliTar(MavenPublication) {  // XXXCliTar is different in two modules
            artifact(distTar)
            artifactId "${applicationName}"
        }
    }
}

When I use the publish task as follows:

gradle -i build publish

I find that only the artifacts from sub-module1 is published.

What is really odd about this is that this only happens when run in Jenkis job (on a linux slave). It dos not happen when run on my windows dev machine!

I am wondering why artifacts from sub-module2 is not published.

Farrukh Najmi
  • 5,055
  • 3
  • 35
  • 54

1 Answers1

0

I think there is a bug in the maven-publish plugin. The workaround was to not define the publishing.repositories.maven config in root module and instead duplicating it in sub-module1 and sub-modules2 like this:

publishing {
    publishing {
        repositories {
            maven {
                url = ...
                credentials {
                    username = ...
                    password = ...
                }
            }
        }
    }
    publications {
        XXXCliTar(MavenPublication) {  // XXXCliTar is different in two modules
            artifact(distTar)
            artifactId "${applicationName}"
        }
    }
}

Make sure to not apply the maven-publish plugin in rootProject's common config for sub-modules.

Farrukh Najmi
  • 5,055
  • 3
  • 35
  • 54