diff --git a/src/main/groovy/io/openliberty/tools/gradle/tasks/InstallLibertyTask.groovy b/src/main/groovy/io/openliberty/tools/gradle/tasks/InstallLibertyTask.groovy index ac705f96..db2be553 100644 --- a/src/main/groovy/io/openliberty/tools/gradle/tasks/InstallLibertyTask.groovy +++ b/src/main/groovy/io/openliberty/tools/gradle/tasks/InstallLibertyTask.groovy @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corporation 2014, 2021. + * (C) Copyright IBM Corporation 2014, 2023. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -50,7 +50,9 @@ class InstallLibertyTask extends AbstractLibertyTask { group 'Liberty' }) outputs.upToDateWhen { - getInstallDir(project).exists() && project.buildDir.exists() && new File(project.buildDir, 'liberty-plugin-config.xml').exists() + // ensure a Liberty installation exists at the install directory + getInstallDir(project).exists() && new File(getInstallDir(project), 'lib/ws-launch.jar').exists() && + project.buildDir.exists() && new File(project.buildDir, 'liberty-plugin-config.xml').exists() } } diff --git a/src/test/groovy/io/openliberty/tools/gradle/InstallLiberty_runtimeDep_upToDate_Test.groovy b/src/test/groovy/io/openliberty/tools/gradle/InstallLiberty_runtimeDep_upToDate_Test.groovy index 2fae7003..69ebaf5a 100644 --- a/src/test/groovy/io/openliberty/tools/gradle/InstallLiberty_runtimeDep_upToDate_Test.groovy +++ b/src/test/groovy/io/openliberty/tools/gradle/InstallLiberty_runtimeDep_upToDate_Test.groovy @@ -27,6 +27,7 @@ class InstallLiberty_runtimeDep_upToDate_Test extends AbstractIntegrationTest{ static File resourceDir = new File("build/resources/test/liberty-test") static File buildDir = new File(integTestDir, "/InstallLiberty_upToDate_Test") static String runTimeDep_UpToDate_buildFilename = "installLiberty_upToDate_runtimeDep_Test.gradle" + static File wsLaunchJar = new File(buildDir, "build/wlp/lib/ws-launch.jar") @BeforeClass public static void setup() { @@ -41,7 +42,18 @@ class InstallLiberty_runtimeDep_upToDate_Test extends AbstractIntegrationTest{ @Test public void test_installLiberty_upToDate() { + // same version as installed in the setup method, so upToDate check should return true assert runTaskCheckForUpToDate(buildDir, 'installLiberty', "-PlibertyVersion=21.0.0.1") + + // changing the libertyVersion causes the upToDate check to return false assertFalse runTaskCheckForUpToDate(buildDir, 'installLiberty', "-PlibertyVersion=21.0.0.2") + + // verify upToDate check returns true for same libertyVersion + assert runTaskCheckForUpToDate(buildDir, 'installLiberty', "-PlibertyVersion=21.0.0.2") + + // now delete the ws-launch.jar from the installation and ensure the upToDate check returns false even though the libertyVersion did not change + wsLaunchJar.delete() + assertFalse runTaskCheckForUpToDate(buildDir, 'installLiberty', "-PlibertyVersion=21.0.0.2") + } }