Skip to content

Commit

Permalink
Merge pull request #35 from wyjsonGo/develop
Browse files Browse the repository at this point in the history
publish v2.4.3
helper任务添加Cache功能,提升执行速度
  • Loading branch information
wyjsonGo authored Dec 20, 2023
2 parents 25e2d9a + 128ea74 commit 2d8efa0
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.wyjson.router.gradle_plugin.helper

import com.android.build.api.variant.Variant
import com.google.gson.Gson
import com.google.gson.JsonParser
import com.wyjson.router.gradle_plugin.model.RouteHelperModel
import com.wyjson.router.gradle_plugin.utils.Constants
import com.wyjson.router.gradle_plugin.utils.Logger
Expand Down Expand Up @@ -40,7 +41,12 @@ abstract class GenerateGoRouterHelperTask : DefaultTask() {
setDependModeList(variantName, buildType, flavorName)

if (!scanRouteModule(variantName, buildType)) {
Logger.w(TAG, "GoRouterHelper task end.")
Logger.i(TAG, "GoRouterHelper task end.")
return
}

if (checkCache()) {
Logger.i(TAG, "GoRouterHelper(UP-TO-DATE) task end.")
return
}

Expand All @@ -55,9 +61,27 @@ abstract class GenerateGoRouterHelperTask : DefaultTask() {
val path = "/src/${catalog}/java/com/wyjson/router/helper"
val packageFile = File(dir, path)
AssembleGoRouteHelperCode(routeHelperModel!!).generateJavaFile(packageFile)
saveCache()
Logger.i(TAG, "GoRouterHelper task end. ${dir}${path}")
}

private fun checkCache(): Boolean {
val cacheFile = File(project.buildDir, "/tmp/gorouter/route-helper-cache.json")
if (!cacheFile.exists())
return false
try {
return JsonParser.parseString(cacheFile.readText()).equals(JsonParser.parseString(Gson().toJson(routeHelperModel)))
} catch (_: Exception) {
}
return false
}

private fun saveCache() {
val cacheFile = File(project.buildDir, "/tmp/gorouter/route-helper-cache.json")
cacheFile.parentFile.mkdirs()
cacheFile.writeText(Gson().toJson(routeHelperModel), Charsets.UTF_8)
}

private fun scanRouteModule(variantName: String, buildType: String?): Boolean {
project.dependProject().plus(project).forEach { curProject ->
var file = searchJSONFile(curProject, variantName)
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ dependencyResolutionManagement {
}
dependencies {
api 'com.github.wyjsonGo.GoRouter:GoRouter-Api:2.4.2'
api 'com.github.wyjsonGo.GoRouter:GoRouter-Api:2.4.3'
}
// Kotlin配置参见8-1
```
Expand All @@ -89,7 +89,7 @@ android {
}
dependencies {
annotationProcessor 'com.github.wyjsonGo.GoRouter:GoRouter-Compiler:2.4.2'
annotationProcessor 'com.github.wyjsonGo.GoRouter:GoRouter-Compiler:2.4.3'
}
```

Expand Down Expand Up @@ -157,7 +157,7 @@ pluginManagement {
// 项目根目录下的build.gradle
buildscript {
dependencies {
classpath 'com.github.wyjsonGo.GoRouter:GoRouter-Gradle-Plugin:2.4.2'
classpath 'com.github.wyjsonGo.GoRouter:GoRouter-Gradle-Plugin:2.4.3'
}
}
```
Expand Down Expand Up @@ -890,7 +890,7 @@ kapt {
}

dependencies {
kapt 'com.github.wyjsonGo.GoRouter:GoRouter-Compiler:2.4.2'
kapt 'com.github.wyjsonGo.GoRouter:GoRouter-Compiler:2.4.3'
}
```

Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
dependencies {
classpath "com.github.wyjsonGo.GoRouter:GoRouter-Gradle-Plugin:${VERSION}"
// classpath "com.github.wyjsonGo.GoRouter:GoRouter-Gradle-Plugin:${VERSION}"
}
}

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ android.nonTransitiveRClass=true
# org.gradle.jvmargs=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005

GROUP_ID=com.github.wyjsonGo.GoRouter
VERSION=2.4.2
VERSION=2.4.3
10 changes: 5 additions & 5 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ dependencyResolutionManagement {

rootProject.name = "GoRouter"

include ':app'
include ':module_main'
include ':module_user'
include ':module_kotlin'
include ':module_common'
//include ':app'
//include ':module_main'
//include ':module_user'
//include ':module_kotlin'
//include ':module_common'

include ':GoRouter-Api'
include ':GoRouter-Annotation'
Expand Down

0 comments on commit 2d8efa0

Please sign in to comment.