如何将gradle添加到子项目根项目作为依赖关系? [英] How add gradle to subproject root project as dependency?

查看:1765
本文介绍了如何将gradle添加到子项目根项目作为依赖关系?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下项目结构 settings.gradle

 包括'B'
包括'C'

rootProject.name ='A'

如何将gradle添加到子项目根项目中作为依赖关系?

解决方案

> project 方法而言,根项目没有名称。所以这是项目B的build.gradle中的语法:

pre code $ dependency {
compile project(':')
}

但是,这样做不是一个好主意。结束循环依赖很容易。大多数多模块项目都有一个单独的主项目(称为main,core或base),其他模块可以很容易地依赖于使用 compile project(':core ')或其他。


I have the following project structure settings.gradle:

include 'B'
include 'C'

rootProject.name = 'A'

How add gradle to subproject root project as dependency?

解决方案

As far as the project method is concerned, the root project has no name. So this is the syntax in project B's build.gradle:

dependencies {
  compile project(':')
}

However, it is rarely a good idea to do this. It is too easy to end up with circular dependencies. Most multi-module projects have a separate "main" projects (called something like "main", "core" or "base"), and other modules can easily depend on that using compile project(':core') or whatever.

这篇关于如何将gradle添加到子项目根项目作为依赖关系?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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