Skip to content

armgit / core

Public Imported from GitHub
0

100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps

Gradle updates (minor)

Rich Turnerfa3265c9b3fc
diff --git a/build.gradle b/build.gradle
index d0b832f95..5471e4fa4 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,7 +1,12 @@
+allprojects {
+ apply from: "${findProject(":openremote") != null ? project(":openremote").projectDir : rootDir}/project.gradle"
+}
+
// Uncomment the following to configure files to be encrypted/decrypted
// Each file must be explicitly added to .gitignore otherwise git commit will fail
-// When using encryption the the GFE_PASSWORD environment variable must be set
+// When using encryption the the GFE_PASSWORD environment variable must be set or the build will fail
+// use ./gradlew encryptFiles to encrypt files
//apply plugin: "com.cherryperry.gradle-file-encrypt"
//gradleFileEncrypt {
// // files to encrypt
@@ -11,7 +16,3 @@
// // Use custom password provider as standard env mechanism doesn't seem to work
// passwordProvider = { return "$System.env.GFE_PASSWORD".toCharArray() }
//}
-
-allprojects {
- apply from: "${findProject(":openremote") != null ? project(":openremote").projectDir : rootDir}/project.gradle"
-}
diff --git a/project.gradle b/project.gradle
index d65c78b4f..f73814580 100644
--- a/project.gradle
+++ b/project.gradle
@@ -11,12 +11,16 @@ import org.jetbrains.gradle.ext.JUnit
// Ensure git hook creation task is executed
if (project == rootProject) {
- if (rootProject.hasProperty("gradleFileEncrypt")) {
- // Write git hook for encryption plugin checks before any commit
- def path = Paths.get(rootProject.projectDir.path, ".git/hooks/pre-commit")
- if (!Files.exists(path)) {
- def f = path.toFile()
- f.text = """#!/bin/sh
+ project.afterEvaluate {
+
+ if (rootProject.hasProperty("gradleFileEncrypt")) {
+ println("File encryption plugin config found, configuring git pre commit hook and decrypt task dependency")
+
+ // Write git hook for encryption plugin checks before any commit
+ def path = Paths.get(rootProject.projectDir.path, ".git/hooks/pre-commit")
+ if (!Files.exists(path)) {
+ def f = path.toFile()
+ f.text = """#!/bin/sh
echo "***** Running gradle encryption plugin checkFilesGitIgnored task ******"
@@ -26,31 +30,37 @@ status=\$?
exit \$status
"""
- Set<PosixFilePermission> perms = Files.readAttributes(path, PosixFileAttributes.class).permissions()
- perms.add(PosixFilePermission.OWNER_WRITE)
- perms.add(PosixFilePermission.OWNER_READ)
- perms.add(PosixFilePermission.OWNER_EXECUTE)
- perms.add(PosixFilePermission.GROUP_WRITE)
- perms.add(PosixFilePermission.GROUP_READ)
- perms.add(PosixFilePermission.GROUP_EXECUTE)
- perms.add(PosixFilePermission.OTHERS_READ)
- perms.add(PosixFilePermission.OTHERS_EXECUTE)
- Files.setPosixFilePermissions(path, perms)
- }
+ try {
+ Set<PosixFilePermission> perms = Files.readAttributes(path, PosixFileAttributes.class).permissions()
+ perms.add(PosixFilePermission.OWNER_WRITE)
+ perms.add(PosixFilePermission.OWNER_READ)
+ perms.add(PosixFilePermission.OWNER_EXECUTE)
+ perms.add(PosixFilePermission.GROUP_WRITE)
+ perms.add(PosixFilePermission.GROUP_READ)
+ perms.add(PosixFilePermission.GROUP_EXECUTE)
+ perms.add(PosixFilePermission.OTHERS_READ)
+ perms.add(PosixFilePermission.OTHERS_EXECUTE)
+ Files.setPosixFilePermissions(path, perms)
+ } catch (Exception ignored) {}
+ }
- // Add dependency on decrypt task for deployment installDist
- Task decryptTask = getTasksByName("decryptFiles", false)[0]
+ // Add dependency on decrypt task for deployment installDist
+ Task decryptTask = getTasksByName("decryptFiles", false)[0]
- try {
- def installDist = tasks.getByPath(":deployment:installDist")
- installDist.dependsOn decryptTask
- installDist.mustRunAfter(decryptTask)
- } catch (Exception ignored) {}
- } else {
- // Remove git hook
- try {
- Files.delete(Paths.get(rootProject.projectDir.path, ".git/hooks/pre-commit"))
- } catch (Exception ignored) {}
+ try {
+ def installDist = tasks.getByPath(":deployment:installDist")
+ installDist.dependsOn decryptTask
+ installDist.mustRunAfter(decryptTask)
+ } catch (Exception ex) {
+ println("Failed to add decryptFiles task dependency: " + ex)
+ }
+ } else {
+ // Remove git hook
+ try {
+ Files.delete(Paths.get(rootProject.projectDir.path, ".git/hooks/pre-commit"))
+ } catch (Exception ignored) {
+ }
+ }
}
}