From e3a5d70a5efb289e549fd6f3c38c8dec4febe479 Mon Sep 17 00:00:00 2001 From: Brandon Fergerson Date: Wed, 9 Feb 2022 20:30:47 -0500 Subject: [PATCH] use chattr if root --- build.gradle.kts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 97b26c39..7a3d36cc 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -103,7 +103,11 @@ tasks.register("restrictDeletionOfJsonMappers") { } } if (Os.isFamily(Os.FAMILY_UNIX)) { - commandLine("chmod", "a-w", "$buildDir/generated/source/kapt/main/META-INF/vertx") + if (System.getProperty("user.name") == "root") { + commandLine("chattr", "+i", "$buildDir/generated/source/kapt/main/META-INF/vertx") + } else { + commandLine("chmod", "a-w", "$buildDir/generated/source/kapt/main/META-INF/vertx") + } } else { executable("cmd.exe") args("/C") //no-op @@ -115,7 +119,11 @@ tasks.register("unrestrictDeletionOfJsonMappers") { mustRunAfter("compileKotlinJvm") if (Os.isFamily(Os.FAMILY_UNIX)) { if (file("$buildDir/generated/source/kapt/main/META-INF/vertx").exists()) { - commandLine("chmod", "a+w", "$buildDir/generated/source/kapt/main/META-INF/vertx") + if (System.getProperty("user.name") == "root") { + commandLine("chattr", "-i", "$buildDir/generated/source/kapt/main/META-INF/vertx") + } else { + commandLine("chmod", "a+w", "$buildDir/generated/source/kapt/main/META-INF/vertx") + } } else { commandLine("true") //no-op }