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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122 | package Torello.Java.Build;
import Torello.JavaDoc.Upgrade;
import Torello.JavaDoc.Stats;
import Torello.JavaDoc.Messager.AssertFail;
import Torello.Java.FileRW;
import static Torello.Java.C.BRED;
import static Torello.Java.C.BRED_BKGND;
import static Torello.Java.C.BYELLOW;
import static Torello.Java.C.RESET;
import java.io.File;
import java.io.IOException;
/**
* This is the third Build-Stage, and it runs the Java-Doc {@link Upgrade Upgrader-Tool}
*
* <EMBED CLASS=external-html DATA-FILE-ID=STAGE_PRIVATE_NOTE>
* <EMBED CLASS='external-html' DATA-FILE-ID=S03_UPGRADE>
*/
@Torello.JavaDoc.StaticFunctional
public class S03_Upgrade
{
// Completely irrelevant, and the 'private' modifier keeps it off of JavaDoc
private S03_Upgrade() { }
public static void upgrade(final BuilderRecord brec) throws IOException
{
brec.timers.startStage03();
Printing.startStep(3);
StringBuilder sb = new StringBuilder();
// *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
// User-Provided Pre-Upgrader Script
// *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
if (brec.preUpgraderScript != null) TRY_CATCH(
() -> brec.preUpgraderScript.accept(brec, sb),
"User-Provided Pre-Upgrader Script has Failed"
);
// *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
// Main JDU
// *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
sb.append(
'\n' +
"*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***\n" +
"Invoking Upgrader.upgrade(). Log Content Will not be available here.\n" +
"*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***\n" +
'\n'
);
Stats result = brec.upgrader.upgrade();
if (result == null)
{
System.err.println(BRED + "THERE WERE ERRORS, EXITING." + RESET);
System.exit(1);
}
if (brec.FAVICON != null)
try
{ FileRW.copyFile(brec.FAVICON, brec.LOCAL_JAVADOC_DIR, false); }
catch (IOException ioe)
{
System.err.println(
"Unable to copy Favicon File: [" + brec.FAVICON + "] to javadoc output " +
"directory:\n" +
BYELLOW + brec.LOCAL_JAVADOC_DIR + RESET + '\n' +
"Skipping Favicon..."
);
}
// *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
// User-Provided Post-Upgrader Script
// *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
if (brec.postUpgraderScript != null) TRY_CATCH(
() -> brec.postUpgraderScript.accept(brec, sb),
"User-Provided Post-Upgrader Script has Failed"
);
// *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
// Write Logs & Exit
// *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
brec.logs.write_S03_LOGS(sb.toString());
brec.timers.endStage03();
}
@FunctionalInterface
private static interface ThrowingRunnable
{ void run() throws IOException; }
private static void TRY_CATCH(final ThrowingRunnable r, final String msg)
throws IOException
{
try
{ r.run(); }
catch (AssertFail af)
{
System.err.println(
BRED_BKGND + ' ' + msg + ' ' + RESET + '\n' +
"Exiting...\n"
);
System.exit(-1);
}
}
}
|