From 751399d560afedbfd660fcc276072ab1fc60cfd3 Mon Sep 17 00:00:00 2001 From: dshimo Date: Thu, 11 Nov 2021 11:19:23 -0600 Subject: [PATCH 1/5] project property installDir --- src/main/groovy/io/openliberty/tools/gradle/Liberty.groovy | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/groovy/io/openliberty/tools/gradle/Liberty.groovy b/src/main/groovy/io/openliberty/tools/gradle/Liberty.groovy index 52abe9ff..833184cc 100644 --- a/src/main/groovy/io/openliberty/tools/gradle/Liberty.groovy +++ b/src/main/groovy/io/openliberty/tools/gradle/Liberty.groovy @@ -169,7 +169,9 @@ class Liberty implements Plugin { } private static File getInstallDir(Project project) { - if (project.liberty.installDir == null) { + if (project.hasProperty('liberty.installDir')) { + return new File(project.getProperties().getByName('liberty.installDir')) + } else if (project.liberty.installDir == null) { if (project.liberty.baseDir == null) { return new File(project.buildDir, 'wlp') } else { @@ -192,4 +194,5 @@ class Liberty implements Plugin { return new File(installDir, 'wlp').toString() } } + } From 9f93924461a7b23843f92494d479fbf938a60f86 Mon Sep 17 00:00:00 2001 From: dshimo Date: Thu, 18 Nov 2021 09:54:44 -0600 Subject: [PATCH 2/5] add to missing_wlp test. default projectDir --- .../io/openliberty/tools/gradle/Liberty.groovy | 4 +++- ...InstallLiberty_installDir_missing_wlp_Test.groovy | 12 ++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/main/groovy/io/openliberty/tools/gradle/Liberty.groovy b/src/main/groovy/io/openliberty/tools/gradle/Liberty.groovy index 833184cc..9e1bd1eb 100644 --- a/src/main/groovy/io/openliberty/tools/gradle/Liberty.groovy +++ b/src/main/groovy/io/openliberty/tools/gradle/Liberty.groovy @@ -170,7 +170,9 @@ class Liberty implements Plugin { private static File getInstallDir(Project project) { if (project.hasProperty('liberty.installDir')) { - return new File(project.getProperties().getByName('liberty.installDir')) + File installDirPropertyFile = new File(project.projectDir, project.getProperties().get('liberty.installDir')) + project.getLogger().info(MessageFormat.format("installDir project property detected. Using {0}.", installDirPropertyFile.getCanonicalPath())) + return installDirPropertyFile } else if (project.liberty.installDir == null) { if (project.liberty.baseDir == null) { return new File(project.buildDir, 'wlp') diff --git a/src/test/groovy/io/openliberty/tools/gradle/InstallLiberty_installDir_missing_wlp_Test.groovy b/src/test/groovy/io/openliberty/tools/gradle/InstallLiberty_installDir_missing_wlp_Test.groovy index 09d33388..8be25e7a 100644 --- a/src/test/groovy/io/openliberty/tools/gradle/InstallLiberty_installDir_missing_wlp_Test.groovy +++ b/src/test/groovy/io/openliberty/tools/gradle/InstallLiberty_installDir_missing_wlp_Test.groovy @@ -45,4 +45,16 @@ class InstallLiberty_installDir_missing_wlp_Test extends AbstractIntegrationTest String output = result.getOutput() assert output.contains("path does not reference a wlp folder") : "Expected warning about installDir path not containing wlp" } + + @Test + void test_installLiberty_installDir__cli_property() { + BuildResult result = GradleRunner.create() + .withProjectDir(buildDir) + .forwardOutput() + .withArguments('installLiberty', '-Pliberty.installDir=installDir-valid-install/build/wlp', '-i', '-s') + .build() + + String output = result.getOutput() + assert output.contains("installDir project property detected") + } } \ No newline at end of file From 06985e1657aa19d8ce92a82079d60289fd74d16d Mon Sep 17 00:00:00 2001 From: dshimo Date: Thu, 18 Nov 2021 15:39:32 -0600 Subject: [PATCH 3/5] edit w/ checkAndAppendWlp. + test --- .../openliberty/tools/gradle/Liberty.groovy | 28 ++++++++----------- ...Liberty_installDir_missing_wlp_Test.groovy | 19 +++++++++++-- 2 files changed, 29 insertions(+), 18 deletions(-) diff --git a/src/main/groovy/io/openliberty/tools/gradle/Liberty.groovy b/src/main/groovy/io/openliberty/tools/gradle/Liberty.groovy index 9e1bd1eb..27c581b6 100644 --- a/src/main/groovy/io/openliberty/tools/gradle/Liberty.groovy +++ b/src/main/groovy/io/openliberty/tools/gradle/Liberty.groovy @@ -170,30 +170,26 @@ class Liberty implements Plugin { private static File getInstallDir(Project project) { if (project.hasProperty('liberty.installDir')) { - File installDirPropertyFile = new File(project.projectDir, project.getProperties().get('liberty.installDir')) - project.getLogger().info(MessageFormat.format("installDir project property detected. Using {0}.", installDirPropertyFile.getCanonicalPath())) - return installDirPropertyFile + File installDir = checkAndAppendWlp(project, new File(project.projectDir, project.getProperties().get('liberty.installDir'))) + project.getLogger().info("installDir project property detected. Using ${installDir.getCanonicalPath()}.") + return installDir } else if (project.liberty.installDir == null) { - if (project.liberty.baseDir == null) { - return new File(project.buildDir, 'wlp') - } else { - return new File(project.liberty.baseDir, 'wlp') - } + if (project.liberty.baseDir == null) { + return new File(project.buildDir, 'wlp') + } else { + return new File(project.liberty.baseDir, 'wlp') + } } else { // installDir is specified - String installDirPath = checkAndAppendWlp(project) - File installDir = new File(installDirPath) - - return installDir; + return checkAndAppendWlp(project, new File(project.liberty.installDir)); } } - private static String checkAndAppendWlp(Project project) { - String installDir = project.liberty.installDir - if (installDir.endsWith("wlp")) { + private static File checkAndAppendWlp(Project project, File installDir) { + if (installDir.toString().endsWith("wlp")) { return installDir } else { // not valid wlp dir project.getLogger().warn(MessageFormat.format("The installDir {0} path does not reference a wlp folder. Using path {0}/wlp instead.", installDir)) - return new File(installDir, 'wlp').toString() + return new File(installDir, 'wlp') } } diff --git a/src/test/groovy/io/openliberty/tools/gradle/InstallLiberty_installDir_missing_wlp_Test.groovy b/src/test/groovy/io/openliberty/tools/gradle/InstallLiberty_installDir_missing_wlp_Test.groovy index 8be25e7a..28c08818 100644 --- a/src/test/groovy/io/openliberty/tools/gradle/InstallLiberty_installDir_missing_wlp_Test.groovy +++ b/src/test/groovy/io/openliberty/tools/gradle/InstallLiberty_installDir_missing_wlp_Test.groovy @@ -26,6 +26,8 @@ class InstallLiberty_installDir_missing_wlp_Test extends AbstractIntegrationTest static File resourceDir = new File("build/resources/test/install-dir-property-test/installDir-missing-wlp") static File buildDir = new File(integTestDir, "/InstallLiberty_installDir_missing_wlp") + static String expectedPropertyDir = new File(buildDir, 'installDir-valid-install/build/wlp').getCanonicalPath() + static String buildFilename = "build.gradle" @BeforeClass @@ -47,7 +49,7 @@ class InstallLiberty_installDir_missing_wlp_Test extends AbstractIntegrationTest } @Test - void test_installLiberty_installDir__cli_property() { + void test_installLiberty_installDir_cli_property_wlp() { BuildResult result = GradleRunner.create() .withProjectDir(buildDir) .forwardOutput() @@ -55,6 +57,19 @@ class InstallLiberty_installDir_missing_wlp_Test extends AbstractIntegrationTest .build() String output = result.getOutput() - assert output.contains("installDir project property detected") + assert output.contains("installDir project property detected. Using $expectedPropertyDir") + } + + @Test + void test_installLiberty_installDir_cli_property() { + BuildResult result = GradleRunner.create() + .withProjectDir(buildDir) + .forwardOutput() + .withArguments('installLiberty', '-Pliberty.installDir=installDir-valid-install/build', '-i', '-s') + .build() + + String output = result.getOutput() + assert output.contains("installDir project property detected. Using $expectedPropertyDir".drop(4)) + assert output.contains("Using path $expectedPropertyDir instead.") } } \ No newline at end of file From 54296ec439b21df619fe01806dab25bad00ebffa Mon Sep 17 00:00:00 2001 From: David Shi Date: Thu, 18 Nov 2021 22:46:21 -0600 Subject: [PATCH 4/5] Update libertyExtensions.md installDir sentence --- docs/libertyExtensions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/libertyExtensions.md b/docs/libertyExtensions.md index fdcc9621..f0ca4b1e 100644 --- a/docs/libertyExtensions.md +++ b/docs/libertyExtensions.md @@ -14,7 +14,7 @@ The [deploy](deploy.md), [undeploy](undeploy.md), [libertyPackage](libertyPackag | --------- | ---- | ----- | ----------- | ---------| | baseDir | String | 3.0 | The base installation directory. The actual installation directory of WebSphere Liberty server will be `${baseDir}/wlp`. The default value is `${project.buildDir}`. This was moved from the properties in the `install` block in version 3.0.| No | | cacheDir | String | 3.0 | The directory used for caching downloaded files such as the license or `.jar` files. The default value is `${java.io.tmpdir}/wlp-cache`. This was moved from the properties in the `install` block in version 3.0.| No | -| installDir | String | 1.0 | Path to the WebSphere Liberty server installation `wlp` directory. To use a pre-installed version of Liberty, set this property to the path of the Liberty `wlp` directory, including `wlp` in the path. | No | +| installDir | String | 1.0 | Path to the WebSphere Liberty server installation `wlp` directory. To use a pre-installed version of Liberty, set this property to the path of the Liberty `wlp` directory, including `wlp` in the path.

Additionally, `installDir` can be specified in the `gradle.properties` file or from the command line using `-Pliberty.installDir={wlp}`. | No | | outputDir | String | 1.0 | Deprecated. Value of the `${wlp_output_dir}` variable. The default value is `${installDir}/usr/servers/${serverName}`. This parameter has moved to the `server` block. | No | | runtime | Properties | 3.0 | For overriding the `group`, `name` or `version` of the `libertyRuntime` installed from The Central Repository. The default runtime artifact is the latest version of `io.openliberty:openliberty-kernel`. | userDir | String | 1.0 | Value of the `${wlp_user_dir}` variable. The default value is `${installDir}/usr/`. | No | From bcf72276621667a238dc3e5c17ef0220b288a053 Mon Sep 17 00:00:00 2001 From: dshimo Date: Fri, 19 Nov 2021 10:01:50 -0600 Subject: [PATCH 5/5] Update installLiberty + libertyExtensions --- docs/installLiberty.md | 12 ++++++++++++ docs/libertyExtensions.md | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/docs/installLiberty.md b/docs/installLiberty.md index e3e718b0..16f0b1e1 100644 --- a/docs/installLiberty.md +++ b/docs/installLiberty.md @@ -120,6 +120,18 @@ This will get version 19.0.0.11 of `com.ibm.websphere.appserver.runtime:wlp-webP } ``` +#### Override installDir + +In gradle.properties: +``` +liberty.installDir= +``` + +From the command line: +``` +gradle build -Pliberty.installDir= +``` + #### Using Maven artifact Use the [dependencies block](#dependencies) to specify the name of the repository artifact that contains your custom Liberty server or use one of the provided artifacts on [The Central Repository](http://search.maven.org/#search%7Cga%7C1%7Ccom.ibm.websphere.appserver.runtime). diff --git a/docs/libertyExtensions.md b/docs/libertyExtensions.md index f0ca4b1e..12c6a634 100644 --- a/docs/libertyExtensions.md +++ b/docs/libertyExtensions.md @@ -14,7 +14,7 @@ The [deploy](deploy.md), [undeploy](undeploy.md), [libertyPackage](libertyPackag | --------- | ---- | ----- | ----------- | ---------| | baseDir | String | 3.0 | The base installation directory. The actual installation directory of WebSphere Liberty server will be `${baseDir}/wlp`. The default value is `${project.buildDir}`. This was moved from the properties in the `install` block in version 3.0.| No | | cacheDir | String | 3.0 | The directory used for caching downloaded files such as the license or `.jar` files. The default value is `${java.io.tmpdir}/wlp-cache`. This was moved from the properties in the `install` block in version 3.0.| No | -| installDir | String | 1.0 | Path to the WebSphere Liberty server installation `wlp` directory. To use a pre-installed version of Liberty, set this property to the path of the Liberty `wlp` directory, including `wlp` in the path.

Additionally, `installDir` can be specified in the `gradle.properties` file or from the command line using `-Pliberty.installDir={wlp}`. | No | +| installDir | String | 1.0 | Path to the WebSphere Liberty server installation `wlp` directory. To use a pre-installed version of Liberty, set this property to the path of the Liberty `wlp` directory, including `wlp` in the path. Additionally, `installDir` can be specified in the `gradle.properties` file or from the [command line](installLiberty.md#override-installDir). | No | | outputDir | String | 1.0 | Deprecated. Value of the `${wlp_output_dir}` variable. The default value is `${installDir}/usr/servers/${serverName}`. This parameter has moved to the `server` block. | No | | runtime | Properties | 3.0 | For overriding the `group`, `name` or `version` of the `libertyRuntime` installed from The Central Repository. The default runtime artifact is the latest version of `io.openliberty:openliberty-kernel`. | userDir | String | 1.0 | Value of the `${wlp_user_dir}` variable. The default value is `${installDir}/usr/`. | No |