Skip to content

Commit 26aa574

Browse files
committed
feat: modify api name
1 parent 0b76a98 commit 26aa574

File tree

9 files changed

+69
-69
lines changed

9 files changed

+69
-69
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,8 @@ gradle
127127

128128
```
129129
apply(from = "$rootDir/gradle/expose/expose.gradle.kts")
130-
val includeWithApi: (projectPaths: String) -> Unit by extra
131-
val includeWithJavaApi: (projectPaths: String) -> Unit by extra
130+
val includeWithExpose: (projectPaths: String) -> Unit by extra
131+
val includeWithJavaExpose: (projectPaths: String) -> Unit by extra
132132
```
133133

134134
(PS:只要正确启用kts,settings.gradle应该也是可以导入includeWithApi的,但是我没尝试;其次老项目针对ModuleExpose改造kts时,可以渐进式改造,即只改settings.gradle.kts即可)
@@ -140,8 +140,8 @@ val includeWithJavaApi: (projectPaths: String) -> Unit by extra
140140
将需要暴露的模块,在settings.gradle.kts 使用includeWithApi(或includeWithJavaApi)导入;
141141

142142
```
143-
includeWithApi(":feature:settings")
144-
includeWithApi(":feature:search")
143+
includeWithExpose(":feature:settings")
144+
includeWithExpose(":feature:search")
145145
```
146146

147147
即可自动生成新模块 `${module_expose}`;然后在模块源码目录下创建名为expose的目录,将需要暴露的文件放在expose目录下, expose目录下的文件即可在新模块中自动拷贝生成;
@@ -307,7 +307,7 @@ setting.gradle.kts中使用自定义的includeWithApi函数,实现原有includ
307307
**1、分析下脚本includeWithApi处理细节和性能问题**
308308

309309
```
310-
fun includeWithApi(module: String, isJava: Boolean, expose: String, condition: (String) -> Boolean) {
310+
fun includeWithExpose(module: String, isJava: Boolean, expose: String, condition: (String) -> Boolean) {
311311
include(module)
312312
measure("Expose ${module}", true) {
313313
val moduleProject = project(module)

feature/benchmark/src/main/java/cn/jailedbird/feature/benchmark/expose/expose

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,22 @@ import kotlin.io.path.absolutePathString
1616
Project: https://github.com/JailedBird/ModuleExpose
1717
1) import this gradle script in setting.gradle.kts, like this:
1818
apply(from = "$rootDir/gradle/expose/expose.gradle.kts")
19-
2) import function includeWithApi & includeWithJavaApi, like this:
20-
val includeWithApi: (projectPaths: String) -> Unit by extra
21-
val includeWithJavaApi: (projectPaths: String) -> Unit by extra
22-
3) use includeWithApi or includeWithJavaApi include your project, like this:
23-
includeWithApi(":feature:settings")
24-
includeWithApi(":feature:search")
19+
2) import function includeWithExpose & includeWithJavaExpose, like this:
20+
val includeWithExpose: (projectPaths: String) -> Unit by extra
21+
val includeWithJavaExpose: (projectPaths: String) -> Unit by extra
22+
3) use includeWithExpose or includeWithJavaExpose include your project, like this:
23+
includeWithExpose(":feature:settings")
24+
includeWithExpose(":feature:search")
2525
4) in your module, create expose directory and place your file that need to be exposed
2626

2727
Note: ensure your project enable kts! TODO: support traditional gradle project
2828
*/
29-
extra["includeWithApi"] = { module: String ->
30-
includeWithApi(module, isJava = false, DEFAULT_EXPOSE_DIR_NAME, DEFAULT_CONDITION)
29+
extra["includeWithExpose"] = { module: String ->
30+
includeWithExpose(module, isJava = false, DEFAULT_EXPOSE_DIR_NAME, DEFAULT_CONDITION)
3131
}
3232

33-
extra["includeWithJavaApi"] = { module: String ->
34-
includeWithApi(module, isJava = true, DEFAULT_EXPOSE_DIR_NAME, DEFAULT_CONDITION)
33+
extra["includeWithJavaExpose"] = { module: String ->
34+
includeWithExpose(module, isJava = true, DEFAULT_EXPOSE_DIR_NAME, DEFAULT_CONDITION)
3535
}
3636

3737
private val MODULE_EXPOSE_TAG = "expose"
@@ -51,7 +51,7 @@ private val DEFAULT_CONDITION: (String) -> Boolean = if (ENABLE_FILE_CONDITION)
5151
::noFilter
5252
}
5353

54-
fun includeWithApi(
54+
fun includeWithExpose(
5555
module: String,
5656
isJava: Boolean,
5757
expose: String,

feature/benchmark/src/main/java/cn/jailedbird/feature/benchmark/expose/expose1

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,22 @@ import kotlin.io.path.absolutePathString
1616
Project: https://github.com/JailedBird/ModuleExpose
1717
1) import this gradle script in setting.gradle.kts, like this:
1818
apply(from = "$rootDir/gradle/expose/expose.gradle.kts")
19-
2) import function includeWithApi & includeWithJavaApi, like this:
20-
val includeWithApi: (projectPaths: String) -> Unit by extra
21-
val includeWithJavaApi: (projectPaths: String) -> Unit by extra
22-
3) use includeWithApi or includeWithJavaApi include your project, like this:
23-
includeWithApi(":feature:settings")
24-
includeWithApi(":feature:search")
19+
2) import function includeWithExpose & includeWithJavaExpose, like this:
20+
val includeWithExpose: (projectPaths: String) -> Unit by extra
21+
val includeWithJavaExpose: (projectPaths: String) -> Unit by extra
22+
3) use includeWithExpose or includeWithJavaExpose include your project, like this:
23+
includeWithExpose(":feature:settings")
24+
includeWithExpose(":feature:search")
2525
4) in your module, create expose directory and place your file that need to be exposed
2626

2727
Note: ensure your project enable kts! TODO: support traditional gradle project
2828
*/
29-
extra["includeWithApi"] = { module: String ->
30-
includeWithApi(module, isJava = false, DEFAULT_EXPOSE_DIR_NAME, DEFAULT_CONDITION)
29+
extra["includeWithExpose"] = { module: String ->
30+
includeWithExpose(module, isJava = false, DEFAULT_EXPOSE_DIR_NAME, DEFAULT_CONDITION)
3131
}
3232

33-
extra["includeWithJavaApi"] = { module: String ->
34-
includeWithApi(module, isJava = true, DEFAULT_EXPOSE_DIR_NAME, DEFAULT_CONDITION)
33+
extra["includeWithJavaExpose"] = { module: String ->
34+
includeWithExpose(module, isJava = true, DEFAULT_EXPOSE_DIR_NAME, DEFAULT_CONDITION)
3535
}
3636

3737
private val MODULE_EXPOSE_TAG = "expose"
@@ -51,7 +51,7 @@ private val DEFAULT_CONDITION: (String) -> Boolean = if (ENABLE_FILE_CONDITION)
5151
::noFilter
5252
}
5353

54-
fun includeWithApi(
54+
fun includeWithExpose(
5555
module: String,
5656
isJava: Boolean,
5757
expose: String,

feature/benchmark/src/main/java/cn/jailedbird/feature/benchmark/expose/expose2

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,22 @@ import kotlin.io.path.absolutePathString
1616
Project: https://github.com/JailedBird/ModuleExpose
1717
1) import this gradle script in setting.gradle.kts, like this:
1818
apply(from = "$rootDir/gradle/expose/expose.gradle.kts")
19-
2) import function includeWithApi & includeWithJavaApi, like this:
20-
val includeWithApi: (projectPaths: String) -> Unit by extra
21-
val includeWithJavaApi: (projectPaths: String) -> Unit by extra
22-
3) use includeWithApi or includeWithJavaApi include your project, like this:
23-
includeWithApi(":feature:settings")
24-
includeWithApi(":feature:search")
19+
2) import function includeWithExpose & includeWithJavaExpose, like this:
20+
val includeWithExpose: (projectPaths: String) -> Unit by extra
21+
val includeWithJavaExpose: (projectPaths: String) -> Unit by extra
22+
3) use includeWithExpose or includeWithJavaExpose include your project, like this:
23+
includeWithExpose(":feature:settings")
24+
includeWithExpose(":feature:search")
2525
4) in your module, create expose directory and place your file that need to be exposed
2626

2727
Note: ensure your project enable kts! TODO: support traditional gradle project
2828
*/
29-
extra["includeWithApi"] = { module: String ->
30-
includeWithApi(module, isJava = false, DEFAULT_EXPOSE_DIR_NAME, DEFAULT_CONDITION)
29+
extra["includeWithExpose"] = { module: String ->
30+
includeWithExpose(module, isJava = false, DEFAULT_EXPOSE_DIR_NAME, DEFAULT_CONDITION)
3131
}
3232

33-
extra["includeWithJavaApi"] = { module: String ->
34-
includeWithApi(module, isJava = true, DEFAULT_EXPOSE_DIR_NAME, DEFAULT_CONDITION)
33+
extra["includeWithJavaExpose"] = { module: String ->
34+
includeWithExpose(module, isJava = true, DEFAULT_EXPOSE_DIR_NAME, DEFAULT_CONDITION)
3535
}
3636

3737
private val MODULE_EXPOSE_TAG = "expose"
@@ -51,7 +51,7 @@ private val DEFAULT_CONDITION: (String) -> Boolean = if (ENABLE_FILE_CONDITION)
5151
::noFilter
5252
}
5353

54-
fun includeWithApi(
54+
fun includeWithExpose(
5555
module: String,
5656
isJava: Boolean,
5757
expose: String,

gradle/expose/expose.gradle.kts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,22 @@ import kotlin.io.path.absolutePathString
1616
Project: https://github.com/JailedBird/ModuleExpose
1717
1) import this gradle script in setting.gradle.kts, like this:
1818
apply(from = "$rootDir/gradle/expose/expose.gradle.kts")
19-
2) import function includeWithApi & includeWithJavaApi, like this:
20-
val includeWithApi: (projectPaths: String) -> Unit by extra
21-
val includeWithJavaApi: (projectPaths: String) -> Unit by extra
22-
3) use includeWithApi or includeWithJavaApi include your project, like this:
23-
includeWithApi(":feature:settings")
24-
includeWithApi(":feature:search")
19+
2) import function includeWithExpose & includeWithJavaExpose, like this:
20+
val includeWithExpose: (projectPaths: String) -> Unit by extra
21+
val includeWithJavaExpose: (projectPaths: String) -> Unit by extra
22+
3) use includeWithExpose or includeWithJavaExpose include your project, like this:
23+
includeWithExpose(":feature:settings")
24+
includeWithExpose(":feature:search")
2525
4) in your module, create expose directory and place your file that need to be exposed
2626
2727
Note: ensure your project enable kts! TODO: support traditional gradle project
2828
*/
29-
extra["includeWithApi"] = { module: String ->
30-
includeWithApi(module, isJava = false, DEFAULT_EXPOSE_DIR_NAME, DEFAULT_CONDITION)
29+
extra["includeWithExpose"] = { module: String ->
30+
includeWithExpose(module, isJava = false, DEFAULT_EXPOSE_DIR_NAME, DEFAULT_CONDITION)
3131
}
3232

33-
extra["includeWithJavaApi"] = { module: String ->
34-
includeWithApi(module, isJava = true, DEFAULT_EXPOSE_DIR_NAME, DEFAULT_CONDITION)
33+
extra["includeWithJavaExpose"] = { module: String ->
34+
includeWithExpose(module, isJava = true, DEFAULT_EXPOSE_DIR_NAME, DEFAULT_CONDITION)
3535
}
3636

3737
private val MODULE_EXPOSE_TAG = "expose"
@@ -51,7 +51,7 @@ private val DEFAULT_CONDITION: (String) -> Boolean = if (ENABLE_FILE_CONDITION)
5151
::noFilter
5252
}
5353

54-
fun includeWithApi(
54+
fun includeWithExpose(
5555
module: String,
5656
isJava: Boolean,
5757
expose: String,

gradle/expose_gradle/expose.gradle

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ import java.nio.file.SimpleFileVisitor
66
import java.nio.file.StandardCopyOption
77
import java.nio.file.attribute.BasicFileAttributes
88

9-
ext.includeWithApi = { String module ->
10-
includeWithApi(module, false, ModuleExposeConfig.DEFAULT_EXPOSE_DIR_NAME, ModuleExposeConfig.DEFAULT_CONDITION)
9+
ext.includeWithExpose = { String module ->
10+
includeWithExpose(module, false, ModuleExposeConfig.DEFAULT_EXPOSE_DIR_NAME, ModuleExposeConfig.DEFAULT_CONDITION)
1111
}
1212

13-
ext.includeWithJavaApi = { String module ->
14-
includeWithApi(module, true, ModuleExposeConfig.DEFAULT_EXPOSE_DIR_NAME, ModuleExposeConfig.DEFAULT_CONDITION)
13+
ext.includeWithJavaExpose = { String module ->
14+
includeWithExpose(module, true, ModuleExposeConfig.DEFAULT_EXPOSE_DIR_NAME, ModuleExposeConfig.DEFAULT_CONDITION)
1515
}
1616
class ModuleExposeConfig{
1717
static MODULE_EXPOSE_TAG = "expose"
@@ -48,7 +48,7 @@ class ModuleExposeConfig{
4848

4949
}
5050

51-
def includeWithApi(
51+
def includeWithExpose(
5252
String module,
5353
Boolean isJava,
5454
String expose,

settings.gradle.kts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ dependencyResolutionManagement {
2727
enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
2828

2929
apply(from = "$rootDir/gradle/expose/expose.gradle.kts")
30-
val includeWithApi: (projectPaths: String) -> Unit by extra
31-
val includeWithJavaApi: (projectPaths: String) -> Unit by extra
30+
val includeWithExpose: (projectPaths: String) -> Unit by extra
31+
val includeWithJavaExpose: (projectPaths: String) -> Unit by extra
3232

3333
rootProject.name = "ModuleExpose"
3434
include(":app")
3535
include(":core:settings")
3636
include(":core:resource")
37-
includeWithJavaApi(":core:common")
38-
includeWithApi(":feature:settings")
39-
includeWithApi(":feature:search")
40-
includeWithApi(":feature:about")
41-
includeWithApi(":feature:benchmark")
37+
includeWithJavaExpose(":core:common")
38+
includeWithExpose(":feature:settings")
39+
includeWithExpose(":feature:search")
40+
includeWithExpose(":feature:about")
41+
includeWithExpose(":feature:benchmark")

subproj/GradleSample/gradle/expose_gradle/expose.gradle

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ import java.nio.file.SimpleFileVisitor
99
import java.nio.file.StandardCopyOption
1010
import java.nio.file.attribute.BasicFileAttributes
1111

12-
ext.includeWithApi = { String module ->
13-
includeWithApi(module, false, ModuleExposeConfig.DEFAULT_EXPOSE_DIR_NAME, ModuleExposeConfig.DEFAULT_CONDITION)
12+
ext.includeWithExpose = { String module ->
13+
includeWithExpose(module, false, ModuleExposeConfig.DEFAULT_EXPOSE_DIR_NAME, ModuleExposeConfig.DEFAULT_CONDITION)
1414
}
1515

16-
ext.includeWithJavaApi = { String module ->
17-
includeWithApi(module, true, ModuleExposeConfig.DEFAULT_EXPOSE_DIR_NAME, ModuleExposeConfig.DEFAULT_CONDITION)
16+
ext.includeWithJavaExpose = { String module ->
17+
includeWithExpose(module, true, ModuleExposeConfig.DEFAULT_EXPOSE_DIR_NAME, ModuleExposeConfig.DEFAULT_CONDITION)
1818
}
1919
class ModuleExposeConfig{
2020
static MODULE_EXPOSE_TAG = "expose"
@@ -51,7 +51,7 @@ class ModuleExposeConfig{
5151

5252
}
5353

54-
def includeWithApi(
54+
def includeWithExpose(
5555
String module,
5656
Boolean isJava,
5757
String expose,

subproj/GradleSample/settings.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ dependencyResolutionManagement {
1616
rootProject.name = "Gradle sample"
1717

1818
apply from: "gradle/expose_gradle/expose.gradle"
19-
includeWithApi(":app")
20-
includeWithApi ':mylibrary'
21-
includeWithJavaApi ':lib'
19+
includeWithExpose(":app")
20+
includeWithExpose ':mylibrary'
21+
includeWithJavaExpose ':lib'

0 commit comments

Comments
 (0)