refactor(android): use tauri.settings.gradle and tauri.build.gradle.kts to define tauri plugins (#6217)

This commit is contained in:
Lucas Fernandes Nogueira 2023-02-08 07:52:53 -08:00 committed by GitHub
parent a81750d779
commit 481d9de739
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 19 additions and 7 deletions

View File

@ -74,14 +74,11 @@ project(':{pkg_name}').projectDir = new File('./tauri-plugins/{pkg_name}')"
let app_build_gradle = fs::read_to_string(&app_build_gradle_path)?;
let implementation = format!(r#"implementation(project(":{pkg_name}"))"#);
let target_implementation = r#"implementation(project(":tauri-android"))"#;
let target = "dependencies {";
if !app_build_gradle.contains(&implementation) {
fs::write(
&app_build_gradle_path,
app_build_gradle.replace(
target_implementation,
&format!("{target_implementation}\n {implementation}"),
),
app_build_gradle.replace(target, &format!("{target}\n {implementation}")),
)?
}
}

View File

@ -140,11 +140,14 @@ pub fn get_config(
set_var("TAURI_PLUGIN_OUTPUT_PATH", plugin_output_path);
set_var(
"TAURI_GRADLE_SETTINGS_PATH",
config.project_dir().join("settings.gradle"),
config.project_dir().join("tauri.settings.gradle"),
);
set_var(
"TAURI_APP_GRADLE_BUILD_PATH",
config.project_dir().join("app").join("build.gradle.kts"),
config
.project_dir()
.join("app")
.join("tauri.build.gradle.kts"),
);
(app, config, metadata)

View File

@ -89,6 +89,8 @@ dependencies {
implementation(project(":tauri-android"))
}
apply(from = "tauri.build.gradle.kts")
afterEvaluate {
android.applicationVariants.all {
tasks["mergeUniversalReleaseJniLibFolders"].dependsOn(tasks["rustBuildRelease"])

View File

@ -0,0 +1,7 @@
// THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
val implementation by configurations
dependencies {
}

View File

@ -4,3 +4,5 @@ include ':{{this}}'{{/each}}
include ':tauri-android'
project(':tauri-android').projectDir = new File('./tauri-api')
apply from: 'tauri.settings.gradle'

View File

@ -0,0 +1 @@
// THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.