1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   *
13   */
14  
15  package com.liferay.util.ant;
16  
17  import java.io.File;
18  
19  import org.apache.tools.ant.taskdefs.Delete;
20  import org.apache.tools.ant.types.FileSet;
21  
22  /**
23   * <a href="DeleteTask.java.html"><b><i>View Source</i></b></a>
24   *
25   * @author Brian Wing Shun Chan
26   */
27  public class DeleteTask {
28  
29      public static void deleteDirectory(File dir) {
30          Delete delete = new Delete();
31  
32          delete.setProject(AntUtil.getProject());
33          delete.setDir(dir);
34          delete.setFailOnError(false);
35  
36          delete.execute();
37      }
38  
39      public static void deleteDirectory(String dir) {
40          deleteDirectory(new File(dir));
41      }
42  
43      public static void deleteFile(File file) {
44          Delete delete = new Delete();
45  
46          delete.setProject(AntUtil.getProject());
47          delete.setFile(file);
48          delete.setFailOnError(false);
49  
50          delete.execute();
51      }
52  
53      public static void deleteFile(String file) {
54          deleteFile(new File(file));
55      }
56  
57      public static void deleteFiles(File dir, String includes, String excludes) {
58          Delete delete = new Delete();
59  
60          delete.setProject(AntUtil.getProject());
61          delete.setFailOnError(false);
62  
63          FileSet fileSet = new FileSet();
64  
65          fileSet.setDir(dir);
66          fileSet.setIncludes(includes);
67          fileSet.setExcludes(excludes);
68  
69          delete.addFileset(fileSet);
70  
71          delete.execute();
72      }
73  
74      public static void deleteFiles(
75          String dir, String includes, String excludes) {
76  
77          deleteFiles(new File(dir), includes, excludes);
78      }
79  
80  }