|
@@ -10,7 +10,7 @@ use crate::{
|
|
|
interface::{AppInterface, AppSettings, DevProcess, Interface, Options as InterfaceOptions},
|
|
|
ConfigValue,
|
|
|
};
|
|
|
-#[cfg(target_os = "macos")]
|
|
|
+#[cfg(unix)]
|
|
|
use anyhow::Context;
|
|
|
use anyhow::{bail, Result};
|
|
|
use heck::ToSnekCase;
|
|
@@ -325,7 +325,10 @@ fn ensure_init(
|
|
|
let java_folder = project_dir
|
|
|
.join("app/src/main/java")
|
|
|
.join(tauri_config_.identifier.replace('.', "/").replace('-', "_"));
|
|
|
- if !java_folder.exists() {
|
|
|
+ if java_folder.exists() {
|
|
|
+ #[cfg(unix)]
|
|
|
+ ensure_gradlew(&project_dir)?;
|
|
|
+ } else {
|
|
|
project_outdated_reasons
|
|
|
.push("you have modified your \"identifier\" in the Tauri configuration");
|
|
|
}
|
|
@@ -362,6 +365,31 @@ fn ensure_init(
|
|
|
Ok(())
|
|
|
}
|
|
|
|
|
|
+#[cfg(unix)]
|
|
|
+fn ensure_gradlew(project_dir: &std::path::Path) -> Result<()> {
|
|
|
+ use std::os::unix::fs::PermissionsExt;
|
|
|
+
|
|
|
+ let gradlew_path = project_dir.join("gradlew");
|
|
|
+ if let Ok(metadata) = gradlew_path.metadata() {
|
|
|
+ let mut permissions = metadata.permissions();
|
|
|
+ let is_executable = permissions.mode() & 0o111 != 0;
|
|
|
+ if !is_executable {
|
|
|
+ permissions.set_mode(permissions.mode() | 0o111);
|
|
|
+ std::fs::set_permissions(&gradlew_path, permissions)
|
|
|
+ .context("failed to mark gradlew as executable")?;
|
|
|
+ }
|
|
|
+ std::fs::write(
|
|
|
+ &gradlew_path,
|
|
|
+ std::fs::read_to_string(&gradlew_path)
|
|
|
+ .context("failed to read gradlew")?
|
|
|
+ .replace("\r\n", "\n"),
|
|
|
+ )
|
|
|
+ .context("failed to replace gradlew CRLF with LF")?;
|
|
|
+ }
|
|
|
+
|
|
|
+ Ok(())
|
|
|
+}
|
|
|
+
|
|
|
fn log_finished(outputs: Vec<PathBuf>, kind: &str) {
|
|
|
if !outputs.is_empty() {
|
|
|
let mut printable_paths = String::new();
|