| UpToDateTask.java |
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.Project;
20 import org.apache.tools.ant.taskdefs.UpToDate;
21
22 /**
23 * <a href="UpToDateTask.java.html"><b><i>View Source</i></b></a>
24 *
25 * @author Brian Wing Shun Chan
26 */
27 public class UpToDateTask {
28
29 public static boolean isUpToDate(File source, File target) {
30 if (!source.exists() || !target.exists()) {
31 return false;
32 }
33
34 Project project = AntUtil.getProject();
35
36 UpToDate upToDate = new UpToDate();
37
38 upToDate.setProject(project);
39 upToDate.setProperty("uptodate");
40 upToDate.setSrcfile(source);
41 upToDate.setTargetFile(target);
42
43 upToDate.execute();
44
45 if (project.getProperty("uptodate") != null) {
46 return true;
47 }
48 else {
49 return false;
50 }
51 }
52
53 public static boolean isUpToDate(String source, String target) {
54 return isUpToDate(new File(source), new File(target));
55 }
56
57 }