Skip to content

Commit

Permalink
fix #543
Browse files Browse the repository at this point in the history
  • Loading branch information
JarvanMo committed Dec 10, 2023
1 parent 9881fb7 commit 942822d
Showing 1 changed file with 35 additions and 30 deletions.
65 changes: 35 additions & 30 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -76,32 +76,34 @@ Map loadPubspec() {


tasks.register("generateFluwxHelperFile") {
Map config = loadPubspec()
Map fluwx = (Map) config.get("fluwx")
String enableLogging = "false"
String interruptWeChatRequestByFluwx = "true"
String flutterActivity = ""
if (fluwx) {
Map android = (Map) fluwx.get("android")
if (android) {
def iwr = android.get("interrupt_wx_request")
if (iwr && iwr == "true" || iwr == "false") {
interruptWeChatRequestByFluwx = (String) iwr
}

def activity = android.get("flutter_activity")
if (activity) {
flutterActivity = (String) activity
}
}

def logging = fluwx.get("debug_logging")
if (logging && logging == "true" || logging == "false") {
enableLogging = (String) logging
}
}

generateFluwxConfigurations(interruptWeChatRequestByFluwx, flutterActivity, enableLogging)
doFirst {
Map config = loadPubspec()
Map fluwx = (Map) config.get("fluwx")
String enableLogging = "false"
String interruptWeChatRequestByFluwx = "true"
String flutterActivity = ""
if (fluwx) {
Map android = (Map) fluwx.get("android")
if (android) {
def iwr = android.get("interrupt_wx_request")
if (iwr && iwr == "true" || iwr == "false") {
interruptWeChatRequestByFluwx = (String) iwr
}

def activity = android.get("flutter_activity")
if (activity) {
flutterActivity = (String) activity
}
}

def logging = fluwx.get("debug_logging")
if (logging && logging == "true" || logging == "false") {
enableLogging = (String) logging
}
}

generateFluwxConfigurations(interruptWeChatRequestByFluwx, flutterActivity, enableLogging)
}
}

def generateFluwxConfigurations(String interruptWeChatRequestByFluwx, String flutterActivity, String enableLogging) {
Expand All @@ -125,8 +127,11 @@ def generateFluwxConfigurations(String interruptWeChatRequestByFluwx, String flu
file("${generateFolder.absolutePath}/FluwxConfigurations.kt").text = source
}

tasks.withType(JavaCompile) { javaCompile ->
javaCompile.configure {
dependsOn("generateFluwxHelperFile")
}
//tasks.withType(JavaCompile) { javaCompile ->
// javaCompile.configure {
// dependsOn("generateFluwxHelperFile")
// }
//}
android.libraryVariants.configureEach {
it.registerGeneratedResFolders(project.files(new File("${buildDir}/generated/src/kotlin/com/jarvan/fluwx")).builtBy(generateFluwxHelperFile))
}

0 comments on commit 942822d

Please sign in to comment.