diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 6bef8a39..60025a96 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -39,7 +39,8 @@ jobs: - name: Checkout ci.common uses: actions/checkout@v3 with: - repository: OpenLiberty/ci.common + repository: cbridgha/ci.common + ref: VersionlessFeatureSupport path: ci.common - name: Checkout ci.ant uses: actions/checkout@v3 @@ -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/cbridgha/ci.common.git --branch VersionlessFeatureSupport --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/AbstractFeatureTask.groovy b/src/main/groovy/io/openliberty/tools/gradle/tasks/AbstractFeatureTask.groovy index 291cdc5c..4588e916 100644 --- a/src/main/groovy/io/openliberty/tools/gradle/tasks/AbstractFeatureTask.groovy +++ b/src/main/groovy/io/openliberty/tools/gradle/tasks/AbstractFeatureTask.groovy @@ -15,13 +15,14 @@ */ package io.openliberty.tools.gradle.tasks - import io.openliberty.tools.common.plugins.util.AbstractContainerSupportUtil import io.openliberty.tools.common.plugins.util.InstallFeatureUtil import io.openliberty.tools.common.plugins.util.InstallFeatureUtil.ProductProperties import io.openliberty.tools.common.plugins.util.PluginExecutionException import io.openliberty.tools.common.plugins.util.PluginScenarioException import io.openliberty.tools.common.plugins.util.ServerFeatureUtil +import io.openliberty.tools.common.plugins.util.ServerFeatureUtil.FeaturesPlatforms + import io.openliberty.tools.gradle.utils.ArtifactDownloadUtil import org.gradle.api.artifacts.Configuration import org.gradle.api.logging.LogLevel @@ -217,33 +218,36 @@ public class AbstractFeatureTask extends AbstractServerTask { return result; } - protected Set getSpecifiedFeatures(String containerName) throws PluginExecutionException { - InstallFeatureUtil util = getInstallFeatureUtil(null, containerName); + protected FeaturesPlatforms getSpecifiedFeatures(String containerName) throws PluginExecutionException { + InstallFeatureUtil util = getInstallFeatureUtil(null, containerName) + FeaturesPlatforms getServerFeaturesResult = new FeaturesPlatforms() // if createNewInstallFeatureUtil failed to create a new InstallFeatureUtil instance, then features are installed via ant if (installFeaturesFromAnt) { - Set featuresInstalledFromAnt; + Set featuresInstalledFromAnt if (server.features.name != null) { - featuresInstalledFromAnt = new HashSet(server.features.name); - return featuresInstalledFromAnt; + featuresInstalledFromAnt = new HashSet(server.features.name) + return new FeaturesPlatforms(featuresInstalledFromAnt, new HashSet()) } else { - featuresInstalledFromAnt = new HashSet(); - return featuresInstalledFromAnt; + featuresInstalledFromAnt = new HashSet() + return getServerFeaturesResult } } def pluginListedFeatures = getPluginListedFeatures(false) def dependencyFeatures = getDependencyFeatures() - def serverFeatures = null; // if DevMode provides a server directory parameter use that for finding the server features if (serverDirectoryParam != null) { - serverFeatures = util.getServerFeatures(new File(serverDirectoryParam), getLibertyDirectoryPropertyFiles(serverDirectoryParam)) + getServerFeaturesResult = util.getServerFeatures(new File(serverDirectoryParam), getLibertyDirectoryPropertyFiles(serverDirectoryParam)) } else if (getServerDir(project).exists()) { - serverFeatures = util.getServerFeatures(getServerDir(project), getLibertyDirectoryPropertyFiles(null)) + getServerFeaturesResult = util.getServerFeatures(getServerDir(project), getLibertyDirectoryPropertyFiles(null)) } + Set serverFeatures = getServerFeaturesResult != null ? getServerFeaturesResult.getFeatures() : new HashSet() + Set serverPlatforms = getServerFeaturesResult != null ? getServerFeaturesResult.getPlatforms() : new HashSet() + Set featuresToInstall = util.combineToSet(pluginListedFeatures, dependencyFeatures, serverFeatures) - return featuresToInstall + return new FeaturesPlatforms(featuresToInstall, serverPlatforms) } /* diff --git a/src/main/groovy/io/openliberty/tools/gradle/tasks/CompileJSPTask.groovy b/src/main/groovy/io/openliberty/tools/gradle/tasks/CompileJSPTask.groovy index 0fd15f2c..fd994410 100644 --- a/src/main/groovy/io/openliberty/tools/gradle/tasks/CompileJSPTask.groovy +++ b/src/main/groovy/io/openliberty/tools/gradle/tasks/CompileJSPTask.groovy @@ -28,8 +28,10 @@ import org.gradle.api.GradleException import org.gradle.api.tasks.bundling.War import org.gradle.api.logging.LogLevel -import org.apache.tools.ant.Project; -import io.openliberty.tools.ant.jsp.CompileJSPs; +import org.apache.tools.ant.Project +import io.openliberty.tools.ant.jsp.CompileJSPs +import io.openliberty.tools.common.plugins.util.ServerFeatureUtil.FeaturesPlatforms + class CompileJSPTask extends AbstractFeatureTask { protected Project ant = new Project(); @@ -89,7 +91,11 @@ class CompileJSPTask extends AbstractFeatureTask { setCompileJavaSourceVersion(compileJsp, task) //Feature list - Set installedFeatures = getSpecifiedFeatures(null); + Set installedFeatures = new HashSet(); + FeaturesPlatforms fp = getSpecifiedFeatures(null); + if (fp != null) { + installedFeatures = fp.getFeatures(); + } //Set JSP Feature Version setJspVersion(compileJsp, installedFeatures); diff --git a/src/main/groovy/io/openliberty/tools/gradle/tasks/DevTask.groovy b/src/main/groovy/io/openliberty/tools/gradle/tasks/DevTask.groovy index c558d544..c42116f0 100644 --- a/src/main/groovy/io/openliberty/tools/gradle/tasks/DevTask.groovy +++ b/src/main/groovy/io/openliberty/tools/gradle/tasks/DevTask.groovy @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corporation 2019, 2023, 2024. + * (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. @@ -38,10 +38,11 @@ import java.util.concurrent.ThreadPoolExecutor import io.openliberty.tools.ant.ServerTask import io.openliberty.tools.common.plugins.util.DevUtil -import io.openliberty.tools.common.plugins.util.InstallFeatureUtil; +import io.openliberty.tools.common.plugins.util.InstallFeatureUtil import io.openliberty.tools.common.plugins.util.PluginExecutionException import io.openliberty.tools.common.plugins.util.PluginScenarioException import io.openliberty.tools.common.plugins.util.ServerFeatureUtil +import io.openliberty.tools.common.plugins.util.ServerFeatureUtil.FeaturesPlatforms import io.openliberty.tools.common.plugins.util.ServerStatusUtil import io.openliberty.tools.common.plugins.util.ProjectModule import io.openliberty.tools.common.plugins.util.BinaryScannerUtil @@ -363,6 +364,7 @@ class DevTask extends AbstractFeatureTask { private class DevTaskUtil extends DevUtil { Set existingFeatures; + Set existingPlatforms; Set existingLibertyFeatureDependencies; @@ -388,7 +390,12 @@ class DevTask extends AbstractFeatureTask { this.libertyDirPropertyFiles = AbstractServerTask.getLibertyDirectoryPropertyFiles(installDirectory, userDirectory, serverDirectory); ServerFeatureUtil servUtil = getServerFeatureUtil(true, libertyDirPropertyFiles); - this.existingFeatures = servUtil.getServerFeatures(serverDirectory, libertyDirPropertyFiles); + FeaturesPlatforms fp = servUtil.getServerFeatures(serverDirectory, libertyDirPropertyFiles); + + if (fp != null) { + this.existingFeatures = fp.getFeatures() + this.existingPlatforms = fp.getPlatforms() + } this.existingLibertyFeatureDependencies = new HashSet(); @@ -823,7 +830,8 @@ class DevTask extends AbstractFeatureTask { @Override public void installFeatures(File configFile, File serverDir, boolean generateFeatures) { ServerFeatureUtil servUtil = getServerFeatureUtil(true, libertyDirPropertyFiles); - Set features = servUtil.getServerFeatures(serverDir, libertyDirPropertyFiles); + FeaturesPlatforms fp = servUtil.getServerFeatures(serverDir, libertyDirPropertyFiles); + Set features = fp == null ? null : fp.getFeatures(); if (features == null) { return; @@ -885,8 +893,10 @@ class DevTask extends AbstractFeatureTask { @Override public void updateExistingFeatures() { ServerFeatureUtil servUtil = getServerFeatureUtil(true, libertyDirPropertyFiles); - Set features = servUtil.getServerFeatures(getServerDir(project), libertyDirPropertyFiles); - existingFeatures = features; + FeaturesPlatforms fp = servUtil.getServerFeatures(getServerDir(project), libertyDirPropertyFiles); + + this.existingFeatures = fp == null ? new HashSet() : fp.getFeatures(); + this.existingPlatforms = fp == null ? new HashSet() : fp.getPlatforms(); } @Override diff --git a/src/main/groovy/io/openliberty/tools/gradle/tasks/GenerateFeaturesTask.groovy b/src/main/groovy/io/openliberty/tools/gradle/tasks/GenerateFeaturesTask.groovy index 8db57926..6a57fb4a 100644 --- a/src/main/groovy/io/openliberty/tools/gradle/tasks/GenerateFeaturesTask.groovy +++ b/src/main/groovy/io/openliberty/tools/gradle/tasks/GenerateFeaturesTask.groovy @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corporation 2021, 2023. + * (C) Copyright IBM Corporation 2021, 2024. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,6 +22,7 @@ import io.openliberty.tools.common.plugins.util.BinaryScannerUtil import static io.openliberty.tools.common.plugins.util.BinaryScannerUtil.*; import io.openliberty.tools.common.plugins.util.PluginExecutionException import io.openliberty.tools.common.plugins.util.ServerFeatureUtil +import io.openliberty.tools.common.plugins.util.ServerFeatureUtil.FeaturesPlatforms import io.openliberty.tools.gradle.utils.ArtifactDownloadUtil import org.gradle.api.GradleException @@ -174,10 +175,11 @@ class GenerateFeaturesTask extends AbstractFeatureTask { servUtil.setLowerCaseFeatures(false); // get set of user defined features so they can be omitted from the generated file that will be written - Set userDefinedFeatures = optimize ? existingFeatures : servUtil.getServerFeatures(server.configDirectory, server.serverXmlFile, new HashMap(), generatedFiles); + FeaturesPlatforms fp = optimize ? existingFeatures : servUtil.getServerFeatures(server.configDirectory, server.serverXmlFile, new HashMap(), generatedFiles); + Set userDefinedFeatures = fp == null ? new HashSet() : fp.getFeatures(); logger.debug("User defined features:" + userDefinedFeatures); servUtil.setLowerCaseFeatures(true); - if (userDefinedFeatures != null) { + if (!userDefinedFeatures.isEmpty()) { missingLibertyFeatures.removeAll(userDefinedFeatures); } } @@ -233,10 +235,9 @@ class GenerateFeaturesTask extends AbstractFeatureTask { private Set getServerFeatures(ServerFeatureUtil servUtil, Set generatedFiles, boolean excludeGenerated) { servUtil.setLowerCaseFeatures(false); // if optimizing, ignore generated files when passing in existing features to binary scanner - Set existingFeatures = servUtil.getServerFeatures(server.configDirectory, server.serverXmlFile, new HashMap(), excludeGenerated ? generatedFiles : null); // pass generatedFiles to exclude them - if (existingFeatures == null) { - existingFeatures = new HashSet(); - } + FeaturesPlatforms fp = servUtil.getServerFeatures(server.configDirectory, server.serverXmlFile, new HashMap(), excludeGenerated ? generatedFiles : null); // pass generatedFiles to exclude them + Set existingFeatures = fp == null ? new HashSet() : fp.getFeatures(); + servUtil.setLowerCaseFeatures(true); return existingFeatures; } diff --git a/src/main/groovy/io/openliberty/tools/gradle/tasks/InstallFeatureTask.groovy b/src/main/groovy/io/openliberty/tools/gradle/tasks/InstallFeatureTask.groovy index 0e222437..5b61a0f6 100644 --- a/src/main/groovy/io/openliberty/tools/gradle/tasks/InstallFeatureTask.groovy +++ b/src/main/groovy/io/openliberty/tools/gradle/tasks/InstallFeatureTask.groovy @@ -27,6 +27,7 @@ import io.openliberty.tools.common.plugins.util.InstallFeatureUtil import io.openliberty.tools.common.plugins.util.DevUtil import io.openliberty.tools.common.plugins.util.PluginExecutionException import io.openliberty.tools.common.plugins.util.PluginScenarioException +import io.openliberty.tools.common.plugins.util.ServerFeatureUtil.FeaturesPlatforms class InstallFeatureTask extends AbstractFeatureTask { @@ -78,8 +79,11 @@ class InstallFeatureTask extends AbstractFeatureTask { installFeatureFromAnt(); } else { - Set featuresToInstall = getSpecifiedFeatures(containerName); - util.installFeatures(server.features.acceptLicense, new ArrayList(featuresToInstall)) + FeaturesPlatforms fp = getSpecifiedFeatures(containerName); + Set featuresToInstall = fp == null ? new HashSet() : fp.getFeatures(); + Set platformsToInstall = fp == null ? new HashSet() : fp.getPlatforms(); + + util.installFeatures(server.features.acceptLicense, new ArrayList(featuresToInstall), new ArrayList(platformsToInstall)) } }