From 603273c9a6169f6670629e8d23a2de994f63da2d Mon Sep 17 00:00:00 2001 From: Justoce Date: Fri, 27 Nov 2015 09:10:48 -0600 Subject: [PATCH 1/3] Clean Task 1. Add ability to clean some directories 2. Add a new closure "cleanDir" 3. It solves issue "https://github.com/WASdev/ci.gradle/issues/35" --- .../wasdev/wlp/gradle/plugins/Liberty.groovy | 6 ++++ .../plugins/extensions/CleanExtension.groovy | 26 ++++++++++++++ .../extensions/LibertyExtension.groovy | 5 +++ .../wlp/gradle/plugins/tasks/CleanTask.groovy | 35 +++++++++++++++++++ 4 files changed, 72 insertions(+) create mode 100644 src/main/groovy/net/wasdev/wlp/gradle/plugins/extensions/CleanExtension.groovy create mode 100644 src/main/groovy/net/wasdev/wlp/gradle/plugins/tasks/CleanTask.groovy diff --git a/src/main/groovy/net/wasdev/wlp/gradle/plugins/Liberty.groovy b/src/main/groovy/net/wasdev/wlp/gradle/plugins/Liberty.groovy index 442e25124..b099f344f 100644 --- a/src/main/groovy/net/wasdev/wlp/gradle/plugins/Liberty.groovy +++ b/src/main/groovy/net/wasdev/wlp/gradle/plugins/Liberty.groovy @@ -32,6 +32,7 @@ import net.wasdev.wlp.gradle.plugins.tasks.UndeployTask import net.wasdev.wlp.gradle.plugins.tasks.InstallFeatureTask import net.wasdev.wlp.gradle.plugins.tasks.InstallLibertyTask import net.wasdev.wlp.gradle.plugins.tasks.UninstallFeatureTask +import net.wasdev.wlp.gradle.plugins.tasks.CleanTask import org.gradle.api.logging.LogLevel @@ -120,6 +121,11 @@ class Liberty implements Plugin { description 'Uninstall a feature from the WebSphere Liberty Profile server' logging.level = LogLevel.INFO } + + project.task('cleanDirs', type: CleanTask) { + description 'Delete files from some directories from the WebSphere Liberty Profile server' + logging.level = LogLevel.INFO + } } } diff --git a/src/main/groovy/net/wasdev/wlp/gradle/plugins/extensions/CleanExtension.groovy b/src/main/groovy/net/wasdev/wlp/gradle/plugins/extensions/CleanExtension.groovy new file mode 100644 index 000000000..3b8258574 --- /dev/null +++ b/src/main/groovy/net/wasdev/wlp/gradle/plugins/extensions/CleanExtension.groovy @@ -0,0 +1,26 @@ +/** + * (C) Copyright IBM Corporation 2015. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package net.wasdev.wlp.gradle.plugins.extensions + +class CleanExtension{ + + boolean logs = true + boolean workarea = true + boolean dropins = false + boolean apps = false +} + + diff --git a/src/main/groovy/net/wasdev/wlp/gradle/plugins/extensions/LibertyExtension.groovy b/src/main/groovy/net/wasdev/wlp/gradle/plugins/extensions/LibertyExtension.groovy index 86a83da77..56a582c08 100644 --- a/src/main/groovy/net/wasdev/wlp/gradle/plugins/extensions/LibertyExtension.groovy +++ b/src/main/groovy/net/wasdev/wlp/gradle/plugins/extensions/LibertyExtension.groovy @@ -33,6 +33,7 @@ class LibertyExtension { FeatureExtension features = new FeatureExtension() UninstallFeatureExtension uninstallfeatures = new UninstallFeatureExtension() InstallExtension install = new InstallExtension() + CleanExtension cleanDir = new CleanExtension() DeployExtension deploy = new DeployExtension() UndeployExtension undeploy = new UndeployExtension() @@ -77,4 +78,8 @@ class LibertyExtension { def javaDumpLiberty(Closure closure) { ConfigureUtil.configure(closure, javaDumpLiberty) } + + def cleanDir(Closure closure) { + ConfigureUtil.configure(closure, cleanDir) + } } diff --git a/src/main/groovy/net/wasdev/wlp/gradle/plugins/tasks/CleanTask.groovy b/src/main/groovy/net/wasdev/wlp/gradle/plugins/tasks/CleanTask.groovy new file mode 100644 index 000000000..bb2b86af1 --- /dev/null +++ b/src/main/groovy/net/wasdev/wlp/gradle/plugins/tasks/CleanTask.groovy @@ -0,0 +1,35 @@ +/** + * (C) Copyright IBM Corporation 2015. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package net.wasdev.wlp.gradle.plugins.tasks + +import org.gradle.api.tasks.TaskAction + +class CleanTask extends AbstractTask { + + @TaskAction + void installFeature() { + def params = buildLibertyMap(project); + params.put('logs', project.liberty.cleanDir.logs) + params.put('workarea', project.liberty.cleanDir.workarea) + params.put('dropins', project.liberty.cleanDir.dropins) + params.put('apps', project.liberty.cleanDir.apps) + params.remove('timeout') + project.ant.taskdef(name: 'cleanDir', + classname: 'net.wasdev.wlp.ant.CleanTask', + classpath: project.buildscript.configurations.classpath.asPath) + project.ant.cleanDir(params) + } +} \ No newline at end of file From e944e93bb54a3b509582e9bd64ac6982797ba7d5 Mon Sep 17 00:00:00 2001 From: Justoce Date: Fri, 27 Nov 2015 09:14:57 -0600 Subject: [PATCH 2/3] README 1. Update Documentation --- README.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/README.md b/README.md index 358c52c0d..cef171f4e 100644 --- a/README.md +++ b/README.md @@ -105,6 +105,7 @@ The plugin will have made the following tasks available to your project: | undeploy | Removes an application from the WebSphere Liberty Profile server. | | installFeature | Installs a new feature in the WebSphere Liberty Profile server. | | uninstallFeature | Uninstall a feature in the WebSphere Liberty Profile server. | +| cleanDir | Delete files from some directories in the WebSphere Liberty Profile server. | ###Extension properties The Liberty Gradle Plugin has some properties defined in the `Liberty` closure which will let you customize the different tasks. @@ -460,3 +461,32 @@ liberty { } } ``` +### clean task +The `clean` task deletes every file in the `${wlp_output_dir}/logs`, `${wlp_output_dir}/workarea`, `${wlp_user_dir}/dropins` or `${wlp_user_dir}/apps`. + +####**Properties**. + +| Attribute | Description | Required | +| --------- | ------------ | ----------| +| logs |Delete all the files in the `${wlp_output_dir}/logs` directory. The default value is `true`. | No | +| workarea |Delete all the files in the `${wlp_output_dir}/workarea` directory. The default value is `true`. | No | +| dropins |Delete all the files in the `${wlp_user_dir}/dropins` directory. The default value is `false`. | No | +| apps |Delete all the files in the `${wlp_user_dir}/apps` directory. The default value is `false`. | No | + +The following example removes every app deployed to the `${userDir}/dropins` and every file in the `${wlp_output_dir}/workarea` and `${wlp_output_dir}/logs` directories: + + +```groovy +apply plugin: 'liberty' + +liberty { + wlpDir = "c:/wlp" + serverName = 'Server' + + cleanDir { + dropins = true + } +} +``` +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 From 89710520cd1faf3b2c42e8c9e301fbf0618dee44 Mon Sep 17 00:00:00 2001 From: Raquel Maldonado Date: Fri, 27 Nov 2015 12:55:40 -0600 Subject: [PATCH 3/3] Minor updates --- README.md | 2 +- src/main/groovy/net/wasdev/wlp/gradle/plugins/Liberty.groovy | 2 +- .../wlp/gradle/plugins/extensions/LibertyExtension.groovy | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index cef171f4e..9a58bac15 100644 --- a/README.md +++ b/README.md @@ -105,7 +105,7 @@ The plugin will have made the following tasks available to your project: | undeploy | Removes an application from the WebSphere Liberty Profile server. | | installFeature | Installs a new feature in the WebSphere Liberty Profile server. | | uninstallFeature | Uninstall a feature in the WebSphere Liberty Profile server. | -| cleanDir | Delete files from some directories in the WebSphere Liberty Profile server. | +| cleanDir | Deletes files from some directories in the WebSphere Liberty Profile server. | ###Extension properties The Liberty Gradle Plugin has some properties defined in the `Liberty` closure which will let you customize the different tasks. diff --git a/src/main/groovy/net/wasdev/wlp/gradle/plugins/Liberty.groovy b/src/main/groovy/net/wasdev/wlp/gradle/plugins/Liberty.groovy index b099f344f..e35286101 100644 --- a/src/main/groovy/net/wasdev/wlp/gradle/plugins/Liberty.groovy +++ b/src/main/groovy/net/wasdev/wlp/gradle/plugins/Liberty.groovy @@ -119,7 +119,7 @@ class Liberty implements Plugin { } project.task('uninstallFeature', type: UninstallFeatureTask) { description 'Uninstall a feature from the WebSphere Liberty Profile server' - logging.level = LogLevel.INFO + logging.level = LogLevel.INFO } project.task('cleanDirs', type: CleanTask) { diff --git a/src/main/groovy/net/wasdev/wlp/gradle/plugins/extensions/LibertyExtension.groovy b/src/main/groovy/net/wasdev/wlp/gradle/plugins/extensions/LibertyExtension.groovy index 56a582c08..c923d3c1d 100644 --- a/src/main/groovy/net/wasdev/wlp/gradle/plugins/extensions/LibertyExtension.groovy +++ b/src/main/groovy/net/wasdev/wlp/gradle/plugins/extensions/LibertyExtension.groovy @@ -43,7 +43,7 @@ class LibertyExtension { PackageAndDumpExtension javaDumpLiberty = new PackageAndDumpExtension() def uninstallfeatures(Closure closure) { - ConfigureUtil.configure(closure, uninstallfeatures) + ConfigureUtil.configure(closure, uninstallfeatures) } def features(Closure closure) {