001
014
015 package com.liferay.util.ant;
016
017 import java.io.File;
018
019 import org.apache.tools.ant.taskdefs.Delete;
020 import org.apache.tools.ant.types.FileSet;
021
022
025 public class DeleteTask {
026
027 public static void deleteDirectory(File dir) {
028 Delete delete = new Delete();
029
030 delete.setProject(AntUtil.getProject());
031 delete.setDir(dir);
032 delete.setFailOnError(false);
033
034 delete.execute();
035 }
036
037 public static void deleteDirectory(String dir) {
038 deleteDirectory(new File(dir));
039 }
040
041 public static void deleteFile(File file) {
042 Delete delete = new Delete();
043
044 delete.setProject(AntUtil.getProject());
045 delete.setFile(file);
046 delete.setFailOnError(false);
047
048 delete.execute();
049 }
050
051 public static void deleteFile(String file) {
052 deleteFile(new File(file));
053 }
054
055 public static void deleteFiles(File dir, String includes, String excludes) {
056 Delete delete = new Delete();
057
058 delete.setProject(AntUtil.getProject());
059 delete.setFailOnError(false);
060
061 FileSet fileSet = new FileSet();
062
063 fileSet.setDir(dir);
064 fileSet.setIncludes(includes);
065 fileSet.setExcludes(excludes);
066
067 delete.addFileset(fileSet);
068
069 delete.execute();
070 }
071
072 public static void deleteFiles(
073 String dir, String includes, String excludes) {
074
075 deleteFiles(new File(dir), includes, excludes);
076 }
077
078 }