|
9 | 9 | import java.util.concurrent.TimeUnit; |
10 | 10 |
|
11 | 11 | import com.sandwich.util.ExceptionUtils; |
12 | | -import com.sandwich.util.io.FileAction; |
| 12 | +import com.sandwich.util.io.ForEachFileAction; |
13 | 13 | import com.sandwich.util.io.StreamUtils; |
14 | 14 |
|
15 | | -public class FileCompilerAction implements FileAction { |
| 15 | +public class FileCompilerAction extends ForEachFileAction { |
16 | 16 |
|
17 | 17 | private final String destinationPath; |
18 | 18 | private final String[] classPaths; |
19 | 19 | private CompilationListener compilationListener; |
20 | 20 | private final long timeout; |
21 | 21 | public static final CompilationListener LOGGING_HANDLER = new CompilationFailureLogger(); |
22 | 22 |
|
23 | | - public FileCompilerAction(File destinationPath, CompilationListener errorHandler, String...classPaths){ |
24 | | - this(destinationPath, errorHandler, 1000, classPaths); |
| 23 | + public FileCompilerAction(File destination, CompilationListener errorHandler, String...classPaths){ |
| 24 | + this(destination, errorHandler, 1000, classPaths); |
25 | 25 | } |
26 | 26 |
|
27 | | - public FileCompilerAction(File destinationPath, |
| 27 | + public FileCompilerAction(File destination, |
28 | 28 | CompilationListener errorHandler, long timeout, String[] classPaths) { |
29 | | - if(destinationPath == null){ |
| 29 | + if(destination == null){ |
30 | 30 | throw new IllegalArgumentException("the destination path is required"); |
31 | 31 | } |
32 | | - this.destinationPath = destinationPath.getAbsolutePath(); |
| 32 | + this.destinationPath = destination.getAbsolutePath(); |
33 | 33 | this.classPaths = classPaths; |
34 | 34 | this.compilationListener = errorHandler == null ? LOGGING_HANDLER : errorHandler; |
35 | 35 | this.timeout = timeout; |
36 | 36 | } |
37 | 37 |
|
38 | | - public void sourceToDestination(File src, File bin) throws IOException { |
| 38 | + public void onFile(File src) throws IOException { |
39 | 39 | String fileName = src.getName(); |
40 | 40 | if (CompilerConfig.isSourceFile(fileName)) { |
41 | 41 | String[] command = CompilerConfig.getCompilationCommand(src, destinationPath, getClasspath()); |
|
0 commit comments