diff --git a/README.md b/README.md index 9a58bac15..c89426b52 100644 --- a/README.md +++ b/README.md @@ -184,7 +184,7 @@ In certain cases, the Liberty license code may need to be provided in order to i | licenseCode | Liberty profile license code. See [above](#install-liberty-task). | Yes, if `type` is `webProfile6` or `runtimeUrl` specifies a `.jar` file. | | version | Exact or wildcard version of the Liberty profile server to install. Available versions are listed in the [index.yml](http://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/wasdev/downloads/wlp/index.yml) file. Only used if `runtimeUrl` is not set. The default value is `8.5.+`. | No | | runtimeUrl | URL to the Liberty profile's `.jar` or a `.zip` file. If not set, the Liberty repository will be used to find the Liberty runtime archive. | No | -| baseDir | The base installation directory. The actual installation directory of Liberty profile will be `${baseDir}/wlp`. The default value is `.` (current working directory). | No | +| baseDir | The base installation directory. The actual installation directory of Liberty profile will be `${baseDir}/wlp`. The default value is `${project.buildDir}`. | No | | cacheDir | The directory used for caching downloaded files such as the license or `.jar` files. The default value is `${java.io.tmpdir}/wlp-cache`. | No | | username | Username needed for basic authentication. | No | | password | Password needed for basic authentication. | No | @@ -489,4 +489,4 @@ liberty { } ``` Note: If you want to delete files from `${wlp_output_dir}/workarea` and `${wlp_output_dir}/logs` directories, the server needs to be stopped. -``` \ No newline at end of file +``` diff --git a/src/main/groovy/net/wasdev/wlp/gradle/plugins/extensions/InstallExtension.groovy b/src/main/groovy/net/wasdev/wlp/gradle/plugins/extensions/InstallExtension.groovy index 3d19a76fa..3b33a03b8 100644 --- a/src/main/groovy/net/wasdev/wlp/gradle/plugins/extensions/InstallExtension.groovy +++ b/src/main/groovy/net/wasdev/wlp/gradle/plugins/extensions/InstallExtension.groovy @@ -20,7 +20,7 @@ class InstallExtension { String licenseCode String version = "8.5.+" String runtimeUrl - String baseDir = "." + String baseDir String cacheDir String username String password diff --git a/src/main/groovy/net/wasdev/wlp/gradle/plugins/tasks/AbstractTask.groovy b/src/main/groovy/net/wasdev/wlp/gradle/plugins/tasks/AbstractTask.groovy index 5624e471b..7acfa3adb 100644 --- a/src/main/groovy/net/wasdev/wlp/gradle/plugins/tasks/AbstractTask.groovy +++ b/src/main/groovy/net/wasdev/wlp/gradle/plugins/tasks/AbstractTask.groovy @@ -33,12 +33,13 @@ abstract class AbstractTask extends DefaultTask { protected Map buildLibertyMap(Project project) { Map result = new HashMap(); result.put('serverName', project.liberty.serverName) - def libertyUserDirFile = getUserDir(project) - if (!libertyUserDirFile.isDirectory()) { - libertyUserDirFile.mkdirs() - } - result.put('userDir', libertyUserDirFile) - result.put('installDir', project.liberty.wlpDir) + + def installDir = getInstallDir(project) + result.put('installDir', installDir) + + def userDir = getUserDir(project, installDir) + result.put('userDir', userDir) + if (project.liberty.outputDir != null) { result.put('outputDir', project.liberty.outputDir) } @@ -49,9 +50,20 @@ abstract class AbstractTask extends DefaultTask { return result; } - protected File getUserDir(Project project) { - String wlpDir = project.liberty.wlpDir == null ? "" : project.liberty.wlpDir - return (project.liberty.userDir == null) ? new File(wlpDir, 'usr') : new File(project.liberty.userDir) + protected File getInstallDir(Project project) { + if (project.liberty.wlpDir == null) { + if (project.liberty.install.baseDir == null) { + return new File(project.buildDir, 'wlp') + } else { + return new File(project.liberty.install.baseDir, 'wlp') + } + } else { + return new File(project.liberty.wlpDir) + } + } + + protected File getUserDir(Project project, File installDir) { + return (project.liberty.userDir == null) ? new File(installDir, 'usr') : new File(project.liberty.userDir) } } diff --git a/src/main/groovy/net/wasdev/wlp/gradle/plugins/tasks/InstallLibertyTask.groovy b/src/main/groovy/net/wasdev/wlp/gradle/plugins/tasks/InstallLibertyTask.groovy index 9e8e4f5ac..1145a72f5 100644 --- a/src/main/groovy/net/wasdev/wlp/gradle/plugins/tasks/InstallLibertyTask.groovy +++ b/src/main/groovy/net/wasdev/wlp/gradle/plugins/tasks/InstallLibertyTask.groovy @@ -31,14 +31,21 @@ class InstallLibertyTask extends AbstractTask { private Map buildInstallLibertyMap(Project project) { Map result = new HashMap(); - result.put('licenseCode', project.liberty.install.licenseCode) + if (project.liberty.install.licenseCode != null) { + result.put('licenseCode', project.liberty.install.licenseCode) + } + result.put('version', project.liberty.install.version) if (project.liberty.install.runtimeUrl != null) { result.put('runtimeUrl', project.liberty.install.runtimeUrl) } - result.put('baseDir', project.liberty.install.baseDir) + if (project.liberty.install.baseDir == null) { + result.put('baseDir', project.buildDir) + } else { + result.put('baseDir', project.liberty.install.baseDir) + } if (project.liberty.install.cacheDir != null) { result.put('cacheDir', project.liberty.install.cacheDir)