具有项目编译依赖项的 Gradle 嵌套多项目 [英] Gradle nested multi-projects with project compile dependencies

查看:30
本文介绍了具有项目编译依赖项的 Gradle 嵌套多项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个与此 Gradle 多模块项目设置相同的问题,但我必须使用项目编译依赖来构建,不能使用上述问题中作为解决方案给出的库(jar)依赖解决方案.

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、PP4是子项目,各自有自己的build.gradle文件;P1 和 P2 也有 build.gradle 和 settings.gradle 文件.

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.

如何在 PP3 的 build.gradle 文件中将 PP1 声明为编译依赖项?

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
}

我正在运行 Gradle v1.2

I'm running Gradle v1.2

推荐答案

一个构建只能有一个 settings.gradle 文件.假设 settings.gradle 位于根目录中并包含如下项目:

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"))
}

有关更多信息,请参阅 Gradle 中的多项目构建"一章用户指南.

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

这篇关于具有项目编译依赖项的 Gradle 嵌套多项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆