1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73 | package Torello.Java.Build;
import static Torello.Java.C.BRED;
import static Torello.Java.C.RESET;
import Torello.Java.FileNode;
import Torello.Java.RTC;
import Torello.Java.Shell;
import Torello.Java.OSResponse;
import Torello.Java.ReadOnly.ReadOnlyList;
import java.util.stream.Stream;
import java.io.File;
import java.io.IOException;
// All this SINGLE-METHOD-CLASS even does is load the contents of a single
// My/Java/Package/data-files/, and invokes 'javac' on each and every '.java'
// file that is found / identified within that sub-directory-tree.
class CompileDataFilesBuilders
{
static void compile(
final BuildPackage bp,
final ReadOnlyList<String> additionalCompilerArgs,
final String JAVAC_BIN
)
throws IOException
{
System.out.println();
Stream.Builder<String> javacB = Stream.builder();
if (additionalCompilerArgs != null)
for (String arg : additionalCompilerArgs) javacB.accept(arg);
final String dataFilesDirName =
bp.pkgRootDirectory + "data-files" + File.separator;
final FileNode fn = FileNode
.createRoot(dataFilesDirName)
.loadTree(-1, FileNode.JAVA_FILES, null);
final int numJavaFiles = fn.countJustFiles();
if (numJavaFiles == 0)
{
System.out.println("No '.java' Files Found");
return;
}
// Places all '.java' Files from the directory tree into the
// Stream 'javacB'
fn.flattenJustFiles(RTC.FULLPATH_STREAM_BUILDER(javacB));
final Shell shell = new Shell(System.out, System.out, null, null);
final OSResponse r = (JAVAC_BIN == null)
? shell.JAVAC(javacB.build().toArray(String[]::new))
: null;
if (r.response != 0)
{
System.out.println
(BRED + "\nERROR CODE: " + r.response + '\n' + RESET);
System.exit(-1);
}
}
}
|