Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ public class AbstractFeatureTask extends AbstractServerTask {
}

private class InstallFeatureTaskUtil extends InstallFeatureUtil {
public InstallFeatureTaskUtil(File installDir, File buildDir, String from, String to, Set<String> pluginListedEsas, List<ProductProperties> propertiesList, String openLibertyVerion, String containerName, List<String> additionalJsons, String verify, Collection<Map<String,String>> keyMap) throws PluginScenarioException, PluginExecutionException {
super(installDir, buildDir, from, to, pluginListedEsas, propertiesList, openLibertyVerion, containerName, additionalJsons, verify, keyMap)
public InstallFeatureTaskUtil(File installDir, File buildDir, String from, String to, Set<String> pluginListedEsas, List<ProductProperties> propertiesList, String openLibertyVerion, String containerName, List<String> additionalJsons, String verify, Collection<Map<String,String>> keyMap, Map<String, String> environmentVariables) throws PluginScenarioException, PluginExecutionException {
super(installDir, buildDir, from, to, pluginListedEsas, propertiesList, openLibertyVerion, containerName, additionalJsons, verify, keyMap, environmentVariables)
setContainerEngine(this);
}

Expand Down Expand Up @@ -295,7 +295,11 @@ public class AbstractFeatureTask extends AbstractServerTask {
private void createNewInstallFeatureUtil(Set<String> pluginListedEsas, List<ProductProperties> propertiesList, String openLibertyVerion, String containerName, List<String> additionalJsons, Collection<Map<String,String>> keyMap) throws PluginExecutionException {
try {
logger.info("Feature signature verify option: " + server.features.verify)
util = new InstallFeatureTaskUtil(getInstallDir(project), project.getLayout().getBuildDirectory().getAsFile().get(), server.features.from, server.features.to, pluginListedEsas, propertiesList, openLibertyVerion, containerName, additionalJsons, server.features.verify, keyMap)
Map<String, String> envVars = getToolchainEnvVar()
if (envVars != null && !envVars.isEmpty() && envVars.containsKey("JAVA_HOME")) {
logger.debug("Passing toolchain JAVA_HOME to InstallFeatureUtil: " + envVars.get("JAVA_HOME"))
}
util = new InstallFeatureTaskUtil(getInstallDir(project), project.getLayout().getBuildDirectory().getAsFile().get(), server.features.from, server.features.to, pluginListedEsas, propertiesList, openLibertyVerion, containerName, additionalJsons, server.features.verify, keyMap, envVars)
} catch (PluginScenarioException e) {
logger.debug("Exception received: " + e.getMessage(), (Throwable) e)
logger.debug("Installing features from installUtility.")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package io.openliberty.tools.gradle

import org.gradle.testkit.runner.BuildResult
import org.junit.Before
import org.junit.BeforeClass
import org.junit.Test

import static org.junit.Assert.assertTrue

class InstallFeatureToolchainTest extends AbstractIntegrationTest {

static File resourceDir = new File("build/resources/test/kernel-install-feature-test")
static File buildDir = new File(integTestDir, "/install-feature-toolchain-test")
static String buildFilename = "install_features_dependencies.gradle"

@BeforeClass
public static void setup() {
createDir(buildDir)
createTestProject(buildDir, resourceDir, buildFilename)

File buildFile = new File(buildDir, "build.gradle")
def fileContent = buildFile.text
fileContent = fileContent.replace(
"apply plugin: 'liberty'",
"apply plugin: 'liberty'\napply plugin: 'java'\n\njava {\n toolchain {\n languageVersion = JavaLanguageVersion.of(17)\n }\n}"
)
buildFile.text = fileContent
}

@Before
public void before() {
runTasks(buildDir, "libertyCreate")
copyServer("server_empty.xml")
deleteDir(new File(buildDir, "build/wlp/lib/features"))
}

@Test
public void testInstallFeatureWithToolchain() {
BuildResult result = runTasksResult(buildDir, "installFeature")

String output = result.getOutput()

assertTrue("Should show toolchain configured message for installFeature task",
output.contains(String.format(TOOLCHAIN_CONFIGURED, "installFeature")))
}

private copyServer(String serverFile) {
assertTrue(new File(resourceDir, serverFile).exists())
copyFile(new File(resourceDir, serverFile), new File(buildDir, "build/wlp/usr/servers/defaultServer/server.xml"))
}
}
Loading