1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
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  }