Skip to content

Commit

Permalink
Merge branch 'Justoce-gradleclean'
Browse files Browse the repository at this point in the history
  • Loading branch information
rmcmx committed Nov 27, 2015
2 parents bd3a79e + 8971052 commit b91f6af
Show file tree
Hide file tree
Showing 5 changed files with 104 additions and 2 deletions.
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 | 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.
Expand Down Expand Up @@ -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.
```
8 changes: 7 additions & 1 deletion src/main/groovy/net/wasdev/wlp/gradle/plugins/Liberty.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -118,7 +119,12 @@ class Liberty implements Plugin<Project> {
}
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) {
description 'Delete files from some directories from the WebSphere Liberty Profile server'
logging.level = LogLevel.INFO
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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
}


Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -42,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) {
Expand Down Expand Up @@ -77,4 +78,8 @@ class LibertyExtension {
def javaDumpLiberty(Closure closure) {
ConfigureUtil.configure(closure, javaDumpLiberty)
}

def cleanDir(Closure closure) {
ConfigureUtil.configure(closure, cleanDir)
}
}
Original file line number Diff line number Diff line change
@@ -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)
}
}

0 comments on commit b91f6af

Please sign in to comment.