diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index db3cc284..128e0f35 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 @@ -100,7 +100,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 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..1c5fd5a3 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(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 e79b8b3b..5bbeedb6 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 } } } @@ -681,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 473aa2d0..244d24b3 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(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 1f8dc0b3..3b66e588 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. @@ -23,13 +23,13 @@ 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.*" private static final long APP_STOP_TIMEOUT_DEFAULT = 30 * 1000 - protected ServerConfigDocument scd - protected List appFiles = new ArrayList() UndeployTask() { @@ -79,7 +79,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(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)