author | jjh |
Wed, 15 Aug 2012 13:48:46 -0700 | |
changeset 13631 | dc1212c348f9 |
parent 12085 | ce2780cb121f |
child 26268 | 620556167c08 |
permissions | -rw-r--r-- |
12085
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
1 |
/* |
13631
dc1212c348f9
7191449: update copyright year to match last edit in jdk8 langtools repository
jjh
parents:
12085
diff
changeset
|
2 |
* Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. |
12085
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
4 |
* |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. Oracle designates this |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
8 |
* particular file as subject to the "Classpath" exception as provided |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
10 |
* |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
15 |
* accompanied this code). |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
16 |
* |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
17 |
* You should have received a copy of the GNU General Public License version |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
20 |
* |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
22 |
* or visit www.oracle.com if you need additional information or have any |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
23 |
* questions. |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
24 |
*/ |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
25 |
|
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
26 |
package anttasks; |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
27 |
|
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
28 |
import genstubs.GenStubs; |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
29 |
|
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
30 |
import java.io.*; |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
31 |
import java.util.*; |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
32 |
|
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
33 |
import org.apache.tools.ant.BuildException; |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
34 |
import org.apache.tools.ant.DirectoryScanner; |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
35 |
import org.apache.tools.ant.taskdefs.MatchingTask; |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
36 |
import org.apache.tools.ant.types.Path; |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
37 |
import org.apache.tools.ant.types.Reference; |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
38 |
|
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
39 |
/** |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
40 |
* Files are specified with an implicit fileset, using srcdir as a base directory. |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
41 |
* The set of files to be included is specified with an includes attribute or |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
42 |
* nested <includes> set. However, unlike a normal fileset, an empty includes attribute |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
43 |
* means "no files" instead of "all files". The Ant task also accepts "fork=true" and |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
44 |
* classpath attribute or nested <classpath> element to run GenStubs in a separate VM |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
45 |
* with the specified path. This is likely necessary if a JDK 7 parser is required to read the |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
46 |
* JDK 7 input files. |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
47 |
*/ |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
48 |
public class GenStubsTask extends MatchingTask { |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
49 |
private File srcDir; |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
50 |
private File destDir; |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
51 |
private boolean fork; |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
52 |
private Path classpath; |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
53 |
private String includes; |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
54 |
|
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
55 |
public void setSrcDir(File dir) { |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
56 |
this.srcDir = dir; |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
57 |
} |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
58 |
|
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
59 |
public void setDestDir(File dir) { |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
60 |
this.destDir = dir; |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
61 |
} |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
62 |
|
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
63 |
public void setFork(boolean v) { |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
64 |
this.fork = v; |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
65 |
} |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
66 |
|
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
67 |
public void setClasspath(Path cp) { |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
68 |
if (classpath == null) |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
69 |
classpath = cp; |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
70 |
else |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
71 |
classpath.append(cp); |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
72 |
} |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
73 |
|
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
74 |
public Path createClasspath() { |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
75 |
if (classpath == null) { |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
76 |
classpath = new Path(getProject()); |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
77 |
} |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
78 |
return classpath.createPath(); |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
79 |
} |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
80 |
|
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
81 |
public void setClasspathRef(Reference r) { |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
82 |
createClasspath().setRefid(r); |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
83 |
} |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
84 |
|
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
85 |
public void setIncludes(String includes) { |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
86 |
super.setIncludes(includes); |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
87 |
this.includes = includes; |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
88 |
} |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
89 |
|
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
90 |
@Override |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
91 |
public void execute() { |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
92 |
if (includes != null && includes.trim().isEmpty()) |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
93 |
return; |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
94 |
|
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
95 |
DirectoryScanner s = getDirectoryScanner(srcDir); |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
96 |
String[] files = s.getIncludedFiles(); |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
97 |
// System.err.println("Ant.execute: srcDir " + srcDir); |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
98 |
// System.err.println("Ant.execute: destDir " + destDir); |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
99 |
// System.err.println("Ant.execute: files " + Arrays.asList(files)); |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
100 |
|
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
101 |
files = filter(srcDir, destDir, files); |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
102 |
if (files.length == 0) |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
103 |
return; |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
104 |
System.out.println("Generating " + files.length + " stub files to " + destDir); |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
105 |
|
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
106 |
List<String> classNames = new ArrayList<String>(); |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
107 |
for (String file: files) { |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
108 |
classNames.add(file.replaceAll(".java$", "").replace('/', '.')); |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
109 |
} |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
110 |
|
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
111 |
if (!fork) { |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
112 |
GenStubs m = new GenStubs(); |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
113 |
boolean ok = m.run(srcDir.getPath(), destDir, classNames); |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
114 |
if (!ok) |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
115 |
throw new BuildException("genstubs failed"); |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
116 |
} else { |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
117 |
List<String> cmd = new ArrayList<String>(); |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
118 |
String java_home = System.getProperty("java.home"); |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
119 |
cmd.add(new File(new File(java_home, "bin"), "java").getPath()); |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
120 |
if (classpath != null) |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
121 |
cmd.add("-Xbootclasspath/p:" + classpath); |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
122 |
cmd.add(GenStubs.class.getName()); |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
123 |
cmd.add("-sourcepath"); |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
124 |
cmd.add(srcDir.getPath()); |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
125 |
cmd.add("-s"); |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
126 |
cmd.add(destDir.getPath()); |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
127 |
cmd.addAll(classNames); |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
128 |
//System.err.println("GenStubs exec " + cmd); |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
129 |
ProcessBuilder pb = new ProcessBuilder(cmd); |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
130 |
pb.redirectErrorStream(true); |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
131 |
try { |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
132 |
Process p = pb.start(); |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
133 |
BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream())); |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
134 |
try { |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
135 |
String line; |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
136 |
while ((line = in.readLine()) != null) |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
137 |
System.out.println(line); |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
138 |
} finally { |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
139 |
in.close(); |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
140 |
} |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
141 |
int rc = p.waitFor(); |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
142 |
if (rc != 0) |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
143 |
throw new BuildException("genstubs failed"); |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
144 |
} catch (IOException e) { |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
145 |
throw new BuildException("genstubs failed", e); |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
146 |
} catch (InterruptedException e) { |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
147 |
throw new BuildException("genstubs failed", e); |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
148 |
} |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
149 |
} |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
150 |
} |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
151 |
|
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
152 |
String[] filter(File srcDir, File destDir, String[] files) { |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
153 |
List<String> results = new ArrayList<String>(); |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
154 |
for (String f: files) { |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
155 |
long srcTime = new File(srcDir, f).lastModified(); |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
156 |
long destTime = new File(destDir, f).lastModified(); |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
157 |
if (srcTime > destTime) |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
158 |
results.add(f); |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
159 |
} |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
160 |
return results.toArray(new String[results.size()]); |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
161 |
} |
ce2780cb121f
7150579: Moved ant code into a separate package, anttasks.
ohrstrom
parents:
diff
changeset
|
162 |
} |