Gradle-多项目与外部项目? [英] Gradle- Multi-project with outside projects?

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

问题描述

Gradle多项目设置中无法在主项目文件夹之外使用外部依赖项吗?



像在 settings.gradle 文件中,我可以没有像

include'C:\some\path\to\dependent\project\ChildA','ChildB'



还是必须总是在父项目文件夹中包含相关项目?

解决方案

假设以下文件系统层次结构:

  | 
\工作区
|
\
MyProject
|
\
DependencyA

将以下内容添加到 settings.gradle in MyProject

  include'..:DependencyA'

并在您的内部 build.gradle MyProject

 依赖关系{
compile project(':..:DependencyA')
}

重复as许多项目依赖于 DependencyA


Is it not possible in a Gradle multi-project setup to use external dependencies outside the main project folder?

Like in the settings.gradle file, can I not have something like

include 'C:\some\path\to\dependent\project\ChildA','ChildB'

or do I have to always include the dependent projects in the parent project folder?

解决方案

Assuming the following filesystem hierarchy:

|
 \ workspace
     |
      \
       MyProject
     |
      \
       DependencyA

Add the following into your settings.gradle in MyProject:

include '..:DependencyA'

and inside your inner build.gradle of MyProject

dependencies {
    compile project(':..:DependencyA')
}

Repeat for as many projects as you have that depend on DependencyA.

这篇关于Gradle-多项目与外部项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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