# gradle 跨工程引用

由于项目需要，SDK的工程和主工程需要在不同的目录：

```
root

    |-SDK-project

     ----|-lib

    |-App-project

     ----|-app
```

模块app需要SDK-project工程目录下的lib，但在`settings.gradle`中是不能直接include ‘:SDK-project:lib’的。 这时候就需要一个特殊方法：`includeFlat` `includeFlat`可以引入和当前工程同一级上的工程，但不能引入模块。模块还是需要`include`来引入。

`settings.gradle`中修改为：

```
includeFlat 'SDK-project'  

include ':app'  
include ':SDK-project:lib'
```

在 app 的build.gradle中的 dependencies的引用：

```
dependencies {  
    compile project(':SDK-project:lib')
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://java-woms.gitbook.io/java/gradle/gradle-usage-summary/02.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
