Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
626 views
in Technique[技术] by (71.8m points)

build - Gradle nested multi-projects with project compile dependencies

I have an identical problem to this Gradle Multi-Module Project Setup but I have to use project compile dependencies to build and cannot use the library(jar) dependencies solution that was given as a solution in the above question.

Root
|__ P1
|   |_ PP1
|   |_ PP2
|
|__ P2
   |_PP3
   |_PP4

PP1, PP2, PP3 and PP4 are sub-projects and each have their own build.gradle files; P1 and P2 also have build.gradle and settings.gradle files.

How can I declare PP1 as a compile dependency in PP3's build.gradle file?

apply plugin: 'java' 
dependencies {
    compile('P1:PP1') //does not work
    compile group: 'P1', name: 'PP1', version: '0.1' // jar library dependency not an option

    compile('{ant_target}')? //follow up question - an ant target as a dependency
}

I'm running Gradle v1.2

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

A build can only have a single settings.gradle file. Assuming settings.gradle is in the root directory and includes projects like so:

include "P1:PP1"

You can add a compile dependency like so:

dependencies {
    compile(project(":P1:PP1"))
}

For more information, see the "Multi-Project Builds" chapter in the Gradle User Guide.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...