Multi Module project with project(...) source dependency?


#1

Hi,

I have a multi module project with modules A and B. In module B I have

dependencies {
  compile project(':A')
}

However I also need to depend on the sources of module A.

So when I build the multi module project and upload it to Maven I want the pom.xml of module B to contain

<dependencies>
  <!-- CLASS DEPENDENCY -->
  <dependency>
    <groupId>some.group</groupId>
    <artifactId>A</artifactId>
    <version>1.0.0</version>
    <scope>compile</scope>
  </dependency>
  <!-- SOURCE DEPENDENCY. How do I get that? -->
  <dependency>
    <groupId>some.group</groupId>
    <artifactId>A</artifactId>
    <version>1.0.0</version>
    <scope>compile</scope>
    <classifier>sources</classifier>
  </dependency>
</dependencies>

How do I tell Gradle to generate such a pom.xml? Can this be achieved through some special project dependency or do I have to add that manually to pom.xml?

Thanks in advance.


#2

Just found:

https://discuss.gradle.org/t/after-upgrade-to-4-7-from-4-4-task-is-no-longer-found/27083/9

That snippet also works great for adding a source artifact as dependency