Skip to content

Commit

Permalink
Improve upToDate check for installLiberty (#826)
Browse files Browse the repository at this point in the history
  • Loading branch information
cherylking authored May 31, 2023
1 parent 71c3268 commit ec468e0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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")

}
}

0 comments on commit ec468e0

Please sign in to comment.