I have the following project setup:
Project X
|—> ModuleA
|—> ModuleB
Now i am trying to add a dependency in B for the sources of module A. So in the gradle.build file of Module A i have added the following:
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
configurations {
packageSources
}
artifacts {
packageSources sourcesJar
}
And in the gradle.build of Module B i have added:
dependencies {
compile (
[project(':ModuleA')],
[project(path: ':ModuleA', configuration: "packageSources")]
)
}
The result pom-file that is created when executing clean build install now contains two times the same dependency, both mentioning the normal dependency. I expected one normale dependency and one for the sources.
<dependency>
<groupId>some.groupid</groupId>
<artifactId>ModuleA</artifactId>
<version>1.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>some.groupid</groupId>
<artifactId>ModuleA</artifactId>
<version>1.0</version>
<scope>compile</scope>
</dependency>
So my question is, how can i add a dependency to ModuleB so that ModuleB includes to sources for ModuleA in it’s resulting POM file.