clean.md

February 20, 2020 ยท View on GitHub

cleanDirs task

The cleanDirs task deletes server specific files including:

  • Applications in the apps folder
  • Applications in the dropins folder
  • Server log files
  • Server workarea files

Note that the cleanDirs task is different from the clean task from the Java plugin. cleanDirs cleans the server directories whereas clean removes the build directory. If a server is running during a clean, some files may remain and require a second clean. Adding a clean dependsOn 'libertyStop' to your build.gradle file can help prevent this. The Liberty cleanDirs task automatically depends on the libertyStop task.

If you use Java 8 on Windows, note that using the clean task after installFeatures or libertyDev may show an error trying to delete some jars in the build directory. If this happens, run gradle --stop to stop the Gradle daemon and then try again. To avoid the error, use the --no-daemon option on all of your Gradle commands.

dependsOn

cleanDirs depends on libertyStop to ensure a successful clean.

Properties

See the Liberty server configuration properties for common server configuration.

The cleanDirs task uses a cleanDir block to define task specific behavior. The following properties can be defined in the cleanDir extension.

AttributeTypeSinceDescriptionRequired
appsboolean1.0Delete all the files in the ${wlp_user_dir}/servers/<server name>/apps directory. The default value is false.No
dropinsboolean1.0Delete all the files in the ${wlp_user_dir}/servers/<server name>/dropins directory. The default value is false.No
logsboolean1.0Delete all the files in the ${wlp_output_dir}/<server name>/logs directory. The default value is true.No
workareaboolean1.0Delete all the files in the ${wlp_output_dir}/<server name>/workarea directory. The default value is true.No

Examples

The following example removes every app deployed to the server's dropins folder as well as the server's workarea and logs files.

apply plugin: 'liberty'

liberty {

    server {
        name = 'server'

        cleanDir {
            dropins = true
        }
    }
}

Note: If you want to clean files from the server's workarea and logs folders, the server needs to be stopped.