Problem with publishing with maven-publish in a multi module project


(Marcin Zajączkowski) #1

Hi. I would like to publish artifacts with ‘maven-publish’ from my multi module project to a Maven repository (Artifactory). I have configured a plugin in a way that worked with a single module project, but on ‘’‘gradle publish’’’ I’ve got:

‘’‘Maven publication ‘myMaven’ cannot include multiple components’’’

I based my multi module publishing configuration on an example for Ivy:

publishing {

publications {

myMaven(org.gradle.api.publish.maven.MavenPublication) {

from components.java

artifact sourcesJar

artifact javadocJar

artifact groovydocJar

}

repositories {

maven {

name = ‘repo’

url ‘…’

}

}

}

}

I looked into DefaultMavenPublication.java, but don’t know how should I configure publishing to make it work with a multi module project?

Marcin


Problem with publishing with maven-publish in a multi module project II
(Marcin Zajączkowski) #2

I solved it. I put a publishing configuration into subprojects section, but applied plugin to a root project.


(Peter Niederwieser) #3

There is no fundamental difference for multi-project builds. It appears that you are adding multiple components (‘from’'s) to the same publication, which isn’t supported.


(Marcin Zajączkowski) #4

Probably due to a fact a plugin was applied in a root project a configuration in every submodule tried to use/modify it. When I moved “apply” to subprojects section it started to work normally.