From 992cd49219ccf9c4197db0d2ad461e0220d0a3e3 Mon Sep 17 00:00:00 2001 From: Cheryl King Date: Thu, 31 Aug 2023 15:19:28 -0500 Subject: [PATCH] Fix devc permissions issues for Docker --- .../tools/common/plugins/util/DevUtil.java | 5 ++++- .../tools/common/plugins/util/OSUtil.java | 12 +++++++++++- .../tools/common/plugins/util/VersionUtility.java | 1 + 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/main/java/io/openliberty/tools/common/plugins/util/DevUtil.java b/src/main/java/io/openliberty/tools/common/plugins/util/DevUtil.java index aabd526fb..fbee9fd8e 100644 --- a/src/main/java/io/openliberty/tools/common/plugins/util/DevUtil.java +++ b/src/main/java/io/openliberty/tools/common/plugins/util/DevUtil.java @@ -1328,9 +1328,12 @@ private void checkDockerBuildTime(long startTime, File dockerBuildContext) { private void startContainer() { try { - if (OSUtil.isLinux()) { + if (OSUtil.isLinux() || OSUtil.isMac()) { // Added Mac since started getting permission errors for logs folder // Allow the server to write to the log files. If we don't create it here docker daemon will create it as root. runCmd("mkdir -p " + serverDirectory + "/logs"); + // Added two hidden folders since started getting permissions errors on the dropins folder. + runCmd("mkdir -p " + buildDirectory + "/" + DEVC_HIDDEN_FOLDER + "/apps"); + runCmd("mkdir -p " + buildDirectory + "/" + DEVC_HIDDEN_FOLDER + "/dropins"); } info("Starting Docker container..."); diff --git a/src/main/java/io/openliberty/tools/common/plugins/util/OSUtil.java b/src/main/java/io/openliberty/tools/common/plugins/util/OSUtil.java index a18425be5..581991947 100644 --- a/src/main/java/io/openliberty/tools/common/plugins/util/OSUtil.java +++ b/src/main/java/io/openliberty/tools/common/plugins/util/OSUtil.java @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corporation 2018, 2020. + * (C) Copyright IBM Corporation 2018, 2023. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,4 +38,14 @@ public static boolean isLinux() { return osName.indexOf("linux") >= 0; } + /** + * Determines if the current OS is a MAC OS. + * + * @return true if running on Mac, false otherwise + */ + public static boolean isMac() { + String osName = System.getProperty("os.name", "unknown").toLowerCase(); + return osName.indexOf("mac") >= 0; + } + } diff --git a/src/main/java/io/openliberty/tools/common/plugins/util/VersionUtility.java b/src/main/java/io/openliberty/tools/common/plugins/util/VersionUtility.java index 45a48e116..9e10460a7 100644 --- a/src/main/java/io/openliberty/tools/common/plugins/util/VersionUtility.java +++ b/src/main/java/io/openliberty/tools/common/plugins/util/VersionUtility.java @@ -50,6 +50,7 @@ public static int compareArtifactVersion(String currentVersion, String compareVe Version minVersion = new Version(majorVersion, minorVersion, patchLevel, null, null, null); // check for and strip off any classifier + currentVersion = currentVersion.trim(); // guard against trailing blank space if (currentVersion.contains("-")) { currentVersion = currentVersion.substring(0, currentVersion.indexOf("-")); }