mirror of https://github.com/tauri-apps/tauri
fix(cli): ensure gradlew is executable and does not use CRLF (#10751)
* test fix * ensure gradle is executable and does not use CRLF * fix import * add change file * add 0o111 instead
This commit is contained in:
parent
58dda44a59
commit
2d31aef759
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
"tauri-cli": patch:bug
|
||||
"@tauri-apps/cli": patch:bug
|
||||
---
|
||||
|
||||
Ensure gradlew is executable and does not use CRLF so it can be used on UNIX systems.
|
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue