Skip to content

Commit 5db0203

Browse files
committed
添加个性化构建文件输出路径相关的代码
1 parent 3e9e1d5 commit 5db0203

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

common.gradle

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,22 @@ android {
1515
targetCompatibility JavaVersion.VERSION_1_8
1616
sourceCompatibility JavaVersion.VERSION_1_8
1717
}
18+
19+
// 读取 local.properties 文件配置
20+
def properties = new Properties()
21+
def localPropertiesFile = rootProject.file("local.properties")
22+
if (localPropertiesFile.exists()) {
23+
localPropertiesFile.withInputStream { inputStream ->
24+
properties.load(inputStream)
25+
}
26+
}
27+
28+
String buildDirPath = properties.getProperty("build.dir")
29+
if (buildDirPath != null && buildDirPath != "") {
30+
// 将构建文件统一输出到指定的目录下
31+
project.buildDir = new File(buildDirPath, rootProject.name + "/build/${path.replaceAll(':', '/')}")
32+
} else {
33+
// 将构建文件统一输出到项目根目录下的 build 文件夹
34+
project.buildDir = new File(rootDir, "build/${path.replaceAll(':', '/')}")
35+
}
1836
}

0 commit comments

Comments
 (0)