From 982df5e2ec7b948ed86af507f777c6cf88f941a4 Mon Sep 17 00:00:00 2001 From: Cheryl King Date: Thu, 18 Jan 2024 08:43:35 -0600 Subject: [PATCH 1/3] Changes needed because of ci.common changes --- .github/workflows/gradle.yml | 9 +++++---- .../tools/gradle/tasks/AbstractServerTask.groovy | 14 ++++++++++++-- .../tools/gradle/tasks/DeployTask.groovy | 5 +++-- .../tools/gradle/tasks/StartTask.groovy | 4 ++-- .../tools/gradle/tasks/UndeployTask.groovy | 6 ++---- 5 files changed, 24 insertions(+), 14 deletions(-) diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index db3cc284..9172f6ed 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -18,7 +18,7 @@ jobs: matrix: # test against latest update of each major Java version, as well as specific updates of LTS versions: RUNTIME: [ol, wlp] - RUNTIME_VERSION: [23.0.0.11] + RUNTIME_VERSION: [23.0.0.12] java: [21, 17, 11, 8] exclude: - java: 8 @@ -39,7 +39,8 @@ jobs: - name: Checkout ci.common uses: actions/checkout@v3 with: - repository: OpenLiberty/ci.common + repository: cherylking/ci.common + ref: makeThreadSafe path: ci.common - name: Checkout ci.ant uses: actions/checkout@v3 @@ -100,7 +101,7 @@ jobs: matrix: # test against latest update of each major Java version, as well as specific updates of LTS versions: RUNTIME: [ol, wlp] - RUNTIME_VERSION: [23.0.0.11] + RUNTIME_VERSION: [23.0.0.12] java: [21, 17, 11, 8] exclude: - java: 8 @@ -124,7 +125,7 @@ jobs: - name: Clone ci.ant, ci.common, ci.gradle repos to C drive run: | cp -r D:/a/ci.gradle/ci.gradle C:/ci.gradle - git clone https://github.com/OpenLiberty/ci.common.git C:/ci.common + git clone https://github.com/cherylking/ci.common.git --branch makeThreadSafe --single-branch C:/ci.common git clone https://github.com/OpenLiberty/ci.ant.git C:/ci.ant # Cache mvn/gradle packages - name: Cache Maven packages diff --git a/src/main/groovy/io/openliberty/tools/gradle/tasks/AbstractServerTask.groovy b/src/main/groovy/io/openliberty/tools/gradle/tasks/AbstractServerTask.groovy index 47ed659c..b16e1b11 100644 --- a/src/main/groovy/io/openliberty/tools/gradle/tasks/AbstractServerTask.groovy +++ b/src/main/groovy/io/openliberty/tools/gradle/tasks/AbstractServerTask.groovy @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corporation 2017, 2023. + * (C) Copyright IBM Corporation 2017, 2024. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -77,6 +77,7 @@ abstract class AbstractServerTask extends AbstractLibertyTask { protected Map combinedBootstrapProperties = null protected List combinedJvmOptions = null protected Map combinedEnvProperties = null + protected ServerConfigDocument scd = null; protected def server protected def springBootBuildTask @@ -513,13 +514,22 @@ abstract class AbstractServerTask extends AbstractLibertyTask { configureMultipleAppsConfigDropins(serverNode) } + protected ServerConfigDocument getServerConfigDocument(CommonLogger log, File serverXML, File configDir, File bootstrapFile, + Map bootstrapProp, File serverEnvFile, boolean giveConfigDirPrecedence, Map libertyDirPropertyFiles) throws IOException { + if (scd == null || !scd.getServerXML().getCanonicalPath().equals(serverXML.getCanonicalPath())) { + scd = new ServerConfigDocument(log, serverXML, configDir, bootstrapFile, bootstrapProp, serverEnvFile, giveConfigDirPrecedence, libertyDirPropertyFiles) + } + + return scd + } + protected boolean isAppConfiguredInSourceServerXml(String fileName) { boolean configured = false; File serverConfigFile = new File(getServerDir(project), 'server.xml') if (serverConfigFile != null && serverConfigFile.exists()) { try { Map props = combinedBootstrapProperties == null ? convertPropertiesToMap(server.bootstrapProperties) : combinedBootstrapProperties; - ServerConfigDocument scd = ServerConfigDocument.getInstance(CommonLogger.getInstance(project), serverConfigFile, server.configDirectory, server.bootstrapPropertiesFile, props, server.serverEnvFile, + getServerConfigDocument(CommonLogger.getInstance(project), serverConfigFile, server.configDirectory, server.bootstrapPropertiesFile, props, server.serverEnvFile, false, getLibertyDirectoryPropertyFiles(null)); if (scd != null && isLocationFound( scd.getLocations(), fileName)) { logger.debug("Application configuration is found in server.xml : " + fileName) diff --git a/src/main/groovy/io/openliberty/tools/gradle/tasks/DeployTask.groovy b/src/main/groovy/io/openliberty/tools/gradle/tasks/DeployTask.groovy index e79b8b3b..649260ee 100644 --- a/src/main/groovy/io/openliberty/tools/gradle/tasks/DeployTask.groovy +++ b/src/main/groovy/io/openliberty/tools/gradle/tasks/DeployTask.groovy @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corporation 2014, 2023. + * (C) Copyright IBM Corporation 2014, 2024. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -109,7 +109,8 @@ class DeployTask extends AbstractServerTask { } else { if (libertyConfigDropinsAppXml.exists()){ libertyConfigDropinsAppXml.delete() - ServerConfigDocument.markInstanceStale() + // force reinitialization of ServerConfigDocument + scd = null } } } diff --git a/src/main/groovy/io/openliberty/tools/gradle/tasks/StartTask.groovy b/src/main/groovy/io/openliberty/tools/gradle/tasks/StartTask.groovy index 473aa2d0..52a81501 100644 --- a/src/main/groovy/io/openliberty/tools/gradle/tasks/StartTask.groovy +++ b/src/main/groovy/io/openliberty/tools/gradle/tasks/StartTask.groovy @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corporation 2014, 2023. + * (C) Copyright IBM Corporation 2014, 2024. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,7 +86,7 @@ class StartTask extends AbstractServerTask { if (serverConfigFile != null && serverConfigFile.exists()) { try { Map props = combinedBootstrapProperties == null ? convertPropertiesToMap(server.bootstrapProperties) : combinedBootstrapProperties; - ServerConfigDocument scd = ServerConfigDocument.getInstance(CommonLogger.getInstance(project), serverConfigFile, server.configDirectory, server.bootstrapPropertiesFile, props, server.serverEnvFile, + getServerConfigDocument(CommonLogger.getInstance(project), serverConfigFile, server.configDirectory, server.bootstrapPropertiesFile, props, server.serverEnvFile, false, getLibertyDirectoryPropertyFiles(null)); if (scd != null) { appNames = scd.getNames() diff --git a/src/main/groovy/io/openliberty/tools/gradle/tasks/UndeployTask.groovy b/src/main/groovy/io/openliberty/tools/gradle/tasks/UndeployTask.groovy index 1f8dc0b3..5a4c99a1 100644 --- a/src/main/groovy/io/openliberty/tools/gradle/tasks/UndeployTask.groovy +++ b/src/main/groovy/io/openliberty/tools/gradle/tasks/UndeployTask.groovy @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corporation 2014, 2023. + * (C) Copyright IBM Corporation 2014, 2024. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,8 +28,6 @@ class UndeployTask extends AbstractServerTask { private static final String STOP_APP_MESSAGE_CODE_REG = "CWWKZ0009I.*" private static final long APP_STOP_TIMEOUT_DEFAULT = 30 * 1000 - protected ServerConfigDocument scd - protected List appFiles = new ArrayList() UndeployTask() { @@ -79,7 +77,7 @@ class UndeployTask extends AbstractServerTask { File serverXML = new File(getServerDir(project).getCanonicalPath(), "server.xml") try { - scd = ServerConfigDocument.getInstance(CommonLogger.getInstance(project), serverXML, server.configDirectory, + getServerConfigDocument(CommonLogger.getInstance(project), serverXML, server.configDirectory, server.bootstrapPropertiesFile, combinedBootstrapProperties, server.serverEnvFile, false, getLibertyDirectoryPropertyFiles(null)) //appName will be set to a name derived from appFile if no name can be found. From 57e398a6e920209f8fd7d351e077c793db963c00 Mon Sep 17 00:00:00 2001 From: Cheryl King Date: Thu, 18 Jan 2024 11:51:14 -0600 Subject: [PATCH 2/3] Make CommonLogger non-singleton --- .../gradle/tasks/AbstractServerTask.groovy | 2 +- .../tools/gradle/tasks/DeployTask.groovy | 2 +- .../tools/gradle/tasks/StartTask.groovy | 2 +- .../tools/gradle/tasks/UndeployTask.groovy | 4 +++- .../tools/gradle/utils/CommonLogger.groovy | 18 +++--------------- 5 files changed, 9 insertions(+), 19 deletions(-) diff --git a/src/main/groovy/io/openliberty/tools/gradle/tasks/AbstractServerTask.groovy b/src/main/groovy/io/openliberty/tools/gradle/tasks/AbstractServerTask.groovy index b16e1b11..1c5fd5a3 100644 --- a/src/main/groovy/io/openliberty/tools/gradle/tasks/AbstractServerTask.groovy +++ b/src/main/groovy/io/openliberty/tools/gradle/tasks/AbstractServerTask.groovy @@ -529,7 +529,7 @@ abstract class AbstractServerTask extends AbstractLibertyTask { if (serverConfigFile != null && serverConfigFile.exists()) { try { Map props = combinedBootstrapProperties == null ? convertPropertiesToMap(server.bootstrapProperties) : combinedBootstrapProperties; - getServerConfigDocument(CommonLogger.getInstance(project), serverConfigFile, server.configDirectory, server.bootstrapPropertiesFile, props, server.serverEnvFile, + getServerConfigDocument(new CommonLogger(project), serverConfigFile, server.configDirectory, server.bootstrapPropertiesFile, props, server.serverEnvFile, false, getLibertyDirectoryPropertyFiles(null)); if (scd != null && isLocationFound( scd.getLocations(), fileName)) { logger.debug("Application configuration is found in server.xml : " + fileName) diff --git a/src/main/groovy/io/openliberty/tools/gradle/tasks/DeployTask.groovy b/src/main/groovy/io/openliberty/tools/gradle/tasks/DeployTask.groovy index 649260ee..5bbeedb6 100644 --- a/src/main/groovy/io/openliberty/tools/gradle/tasks/DeployTask.groovy +++ b/src/main/groovy/io/openliberty/tools/gradle/tasks/DeployTask.groovy @@ -682,7 +682,7 @@ class DeployTask extends AbstractServerTask { File serverXML = new File(getServerDir(project).getCanonicalPath(), "server.xml") try { - scd = ServerConfigDocument.getInstance(CommonLogger.getInstance(project), serverXML, server.configDirectory, + scd = getServerConfigDocument(new CommonLogger(project), serverXML, server.configDirectory, server.bootstrapPropertiesFile, combinedBootstrapProperties, server.serverEnvFile, false, getLibertyDirectoryPropertyFiles(null)) //appName will be set to a name derived from appFile if no name can be found. diff --git a/src/main/groovy/io/openliberty/tools/gradle/tasks/StartTask.groovy b/src/main/groovy/io/openliberty/tools/gradle/tasks/StartTask.groovy index 52a81501..244d24b3 100644 --- a/src/main/groovy/io/openliberty/tools/gradle/tasks/StartTask.groovy +++ b/src/main/groovy/io/openliberty/tools/gradle/tasks/StartTask.groovy @@ -86,7 +86,7 @@ class StartTask extends AbstractServerTask { if (serverConfigFile != null && serverConfigFile.exists()) { try { Map props = combinedBootstrapProperties == null ? convertPropertiesToMap(server.bootstrapProperties) : combinedBootstrapProperties; - getServerConfigDocument(CommonLogger.getInstance(project), serverConfigFile, server.configDirectory, server.bootstrapPropertiesFile, props, server.serverEnvFile, + getServerConfigDocument(new CommonLogger(project), serverConfigFile, server.configDirectory, server.bootstrapPropertiesFile, props, server.serverEnvFile, false, getLibertyDirectoryPropertyFiles(null)); if (scd != null) { appNames = scd.getNames() diff --git a/src/main/groovy/io/openliberty/tools/gradle/tasks/UndeployTask.groovy b/src/main/groovy/io/openliberty/tools/gradle/tasks/UndeployTask.groovy index 5a4c99a1..3b66e588 100644 --- a/src/main/groovy/io/openliberty/tools/gradle/tasks/UndeployTask.groovy +++ b/src/main/groovy/io/openliberty/tools/gradle/tasks/UndeployTask.groovy @@ -23,6 +23,8 @@ import org.gradle.api.logging.LogLevel import io.openliberty.tools.ant.ServerTask import io.openliberty.tools.common.plugins.config.ServerConfigDocument +import io.openliberty.tools.gradle.utils.CommonLogger + class UndeployTask extends AbstractServerTask { private static final String STOP_APP_MESSAGE_CODE_REG = "CWWKZ0009I.*" @@ -77,7 +79,7 @@ class UndeployTask extends AbstractServerTask { File serverXML = new File(getServerDir(project).getCanonicalPath(), "server.xml") try { - getServerConfigDocument(CommonLogger.getInstance(project), serverXML, server.configDirectory, + getServerConfigDocument(new CommonLogger(project), serverXML, server.configDirectory, server.bootstrapPropertiesFile, combinedBootstrapProperties, server.serverEnvFile, false, getLibertyDirectoryPropertyFiles(null)) //appName will be set to a name derived from appFile if no name can be found. diff --git a/src/main/groovy/io/openliberty/tools/gradle/utils/CommonLogger.groovy b/src/main/groovy/io/openliberty/tools/gradle/utils/CommonLogger.groovy index a5b00a44..c871ff64 100644 --- a/src/main/groovy/io/openliberty/tools/gradle/utils/CommonLogger.groovy +++ b/src/main/groovy/io/openliberty/tools/gradle/utils/CommonLogger.groovy @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corporation 2019, 2020. + * (C) Copyright IBM Corporation 2019, 2024. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,24 +21,12 @@ import org.gradle.api.Project public class CommonLogger implements CommonLoggerI { - private static CommonLogger logger = null - private static Project project + private Project project - CommonLogger(Project project) { + public CommonLogger(Project project) { this.project = project } - public static init(Project project) { - logger = new CommonLogger(project) - } - - public static CommonLogger getInstance(Project project) { - if (logger == null) { - CommonLogger.init(project) - } - return logger - } - @Override public void debug(String msg) { project.getLogger().debug(msg) From bdc273bc06a0b444a29e2be02146d5f00dbc077d Mon Sep 17 00:00:00 2001 From: Cheryl King Date: Thu, 18 Jan 2024 14:31:11 -0600 Subject: [PATCH 3/3] Remove temp yaml changes --- .github/workflows/gradle.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 9172f6ed..128e0f35 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -39,8 +39,7 @@ jobs: - name: Checkout ci.common uses: actions/checkout@v3 with: - repository: cherylking/ci.common - ref: makeThreadSafe + repository: OpenLiberty/ci.common path: ci.common - name: Checkout ci.ant uses: actions/checkout@v3 @@ -125,7 +124,7 @@ jobs: - name: Clone ci.ant, ci.common, ci.gradle repos to C drive run: | cp -r D:/a/ci.gradle/ci.gradle C:/ci.gradle - git clone https://github.com/cherylking/ci.common.git --branch makeThreadSafe --single-branch C:/ci.common + git clone https://github.com/OpenLiberty/ci.common.git C:/ci.common git clone https://github.com/OpenLiberty/ci.ant.git C:/ci.ant # Cache mvn/gradle packages - name: Cache Maven packages