001package Torello.Java.Build;
002
003import static Torello.Java.C.BGREEN;
004import static Torello.Java.C.RESET;
005
006import java.util.Arrays;
007import java.util.Objects;
008import java.util.function.Consumer;
009import java.util.function.Predicate;
010import java.util.stream.Stream;
011
012import Torello.Java.FileNodeException;
013import Torello.Java.FileRW;
014import Torello.Java.Q;
015import Torello.Java.StrCmpr;
016import Torello.Java.UnreachableError;
017import Torello.Java.Verbosity;
018import Torello.Java.StringParse;    // Needed for JavaDoc {@link's}
019import Torello.Java.GSUTIL;         // Needed for JavaDoc {@link's}
020
021import Torello.Java.ReadOnly.ReadOnlyList;
022import Torello.Java.ReadOnly.ReadOnlyArrayList;
023
024import Torello.Java.Additional.Ret2;
025import Torello.Java.Additional.ByRef;
026
027import Torello.JavaDoc.Upgrade;
028
029// Needed for a javadoc {@link}
030import Torello.HTML.Tools.Images.UnrecognizedImageExtException;
031
032import java.io.FileNotFoundException;
033import java.io.IOException;
034import java.io.File;
035import java.util.Objects;
036
037/**
038 * This class contains all configurations that are needed to run a build.  This class contains no
039 * publicly exposed methods.  Rather this is strictly a constant "Record Class" that is extremely
040 * similar to the JDK 21+ LTS Records.  There are a few of non-public Package-Private fields inside
041 * this class.  All fields which ar adorned with the {@code public}-Modifier are also declared as
042 * {code 'final'}.
043 * 
044 * <BR /><BR /><H2 CLASS=JDBanner>
045 * Internally-Used Class: The exposed API here is not needed to the End-User.
046 * </H2>
047 * 
048 * <I CLASS=JDBanner>This class is generated, internally, as a Configuration-Class to be passed
049 * to the 8 Build-Stages which are executed by this Build-Tool.  The contents of this class have
050 * been thoroughly documented and explained, <SPAN STYLE='color: red;'>solely for the purpose of
051 * explaining, exactly, the steps this Tool is taking during a Build!</SPAN>
052 * 
053 * <BR /><BR />This class is not declared Package-Private in order to facilitate providing a more 
054 * detailed explanation of what this Build-Tool entails, and not because it is important to the
055 * End-User when running a build.
056 * </I>
057 * 
058 * <BR /><B CLASS=JDDescLabel>Generating an Instance:</B>
059 * 
060 * <BR />An instance of this class may be generated by making a call to the class {@link Config}
061 * method {@link Config#createBuilder(String[])}.
062 * 
063 * <BR /><BR />The Data-Contents of this class are created based on data from the following
064 * sources:
065 * 
066 * <BR /><BR /><UL CLASS=JDUL>
067 * 
068 * <LI> <B>{@link Config} Instance</B>.  Performing a Build with this Tool requires that the user
069 *      provide an instance of class {@link Config}, which should contain all of the needed 
070 *      Configurations to compile, document, archive and synchronize the generated archive files
071 *      and {@code '.html'}-Files to some Cloud-Storage System.
072 *      <BR /><BR /></LI>
073 * 
074 * <LI> <B>{@code String[]} Instance</B>.  This {@code BuilderRecord} also requires the actual
075 *      Command-Line Switches that the "User's End User" has provided at the Command-Line.  This
076 *      is, actually, just the Java-Provided {@code String[]}-Array that has been passed at the
077 *      Command-Line Terminal-Shell Window to the User's {@code public static void main} method.
078 *      </LI>
079 * 
080 * </UL>
081 * 
082 * <BR /><BR /><B CLASS=JDDescLabel>Checking this Record's Contents anyway:</B>
083 * 
084 * <BR />Though there should be no need to actually monitor the values assigned to the
085 * {@code public} fields in this class, most of them have been declared {@code public}.  This is
086 * made possible, because they are also {@code 'final'} and cannot be changed.  Retrieving the
087 * instance of this class that is ultimately used by the {@link RunBuild#run(BuilderRecord)}
088 * method is relatively easy.
089 * 
090 * <BR /><BR />Here are the simple steps needed to actually perform a Build, using this Tool,
091 * <B><I STYLE='color: red;'>once the appropriate settings have been assigned to an instance of
092 * class {@link Config}!</I></B>.
093 * 
094 * <DIV CLASS=EXAMPLE>{@code
095 * Config config = new Config();
096 * 
097 * // Perform as many assignments to the Configuration-Fields as is necessary!
098 * // Below are just a few lines that are used to build the Java-HTML JAR.
099 * 
100 * config.LOCAL_JAVADOC_DIR        = "javadoc/";
101 * config.PROJECT_NAME             = "JavaHTML";
102 * config.VERSION_MAJOR_NUMBER     = 1;
103 * config.VERSION_MINOR_NUMBER     = 8;
104 * config.JAVA_RELEASE_NUM_SWITCH  = 11;
105 * 
106 * // NOTE: 'argv' is obtained from the method's header, which should be as follows:
107 * // ==>   public static void main(String[] argv)
108 * 
109 * BuilderRecord rec = config.createBuilder(argv);
110 * 
111 * // HERE: You may review the settings that have been applied using the Command-Line
112 * //       Input retrieved from "The User's User" by simply inspecting the fields present
113 * /        in the BuilderRecord instance that was returned from "Config.createBuilder"
114 * 
115 * RunBuild.run(rec);
116 * }</DIV>
117 * 
118 * @see CLI
119 * @see Config
120 * @see Config#createBuilder(String[])
121 * @see RunBuild
122 * @see RunBuild#run(BuilderRecord)
123 */
124public class BuilderRecord
125{
126    public static final String BUILDER_RECORD_LOG_FILENAME = "Builder-Record.log.sb";
127
128
129    // ********************************************************************************************
130    // ********************************************************************************************
131    // ********************************************************************************************
132    // ********************************************************************************************
133    // Fields - Package-Private
134    // ********************************************************************************************
135    // ********************************************************************************************
136    // ********************************************************************************************
137    // ********************************************************************************************
138
139
140
141
142    // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
143    // Package-Private, the user cannot use these - They are useless outside of this package
144    // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
145    // 
146    // These are assigned inside this class' construtor.  They serve no purpose to the end user,
147    // and furthermore, they contain stateful-non-constant information, and therefore cannot be
148    // exposed to the public API.
149
150    final Logs      logs;
151    final Timers    timers;
152
153
154    // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
155    // A Minor "Optimization" (Hack) - Note that this Field is Package-Visible
156    // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
157    //
158    // This field is set by Stage-5, and then retrieved in Stage-8.  This allows the String[] Array
159    // to avoid being re-computed / re-calculated twice.
160    //
161    // Just stores some GCS-Directories to make the "Make-Public" Command (Stage-8) run a lot
162    // faster when a User has provided a sub-set / list of Packages using their Nick-Names.  
163    // Essentially the "Old Way" to run Stage-8 was to call "Make-Public" on the entire GCS
164    // Directory-Tree for a Project - even when only a small sub-set of files were updated.  Now,
165    // when a small sub-set of files are synchronized, only those files are subjected to the 
166    // GSUTIL.MP Command.  This shaves off 10 seconds on the Partial-Build's.  GSUTIL is a littl
167    // slow.
168
169    String[] stage8GCSDirs = null;
170
171
172
173
174    // ********************************************************************************************
175    // ********************************************************************************************
176    // ********************************************************************************************
177    // ********************************************************************************************
178    // Fields - User-Visible / Public-Fields
179    // ********************************************************************************************
180    // ********************************************************************************************
181    // ********************************************************************************************
182    // ********************************************************************************************
183
184
185
186
187    /**
188     * Used during the JAR-Build (Stage 4).
189     * TO BE EXPLAINED AT A LATER DATE.
190     * @see Config#HOME_DIR
191     */
192    public final String HOME_DIR;
193
194    /**
195     * This {@code String} contains either the absolute, or the relative, path to the on-disk
196     * location of the directory where {@code javadoc} has left its output.
197     * 
198     * <BR /><BR /><B CLASS=JDDescLabel>Validity-Checking:</B>
199     * 
200     * <BR />A Directory-Check <I>is not performed</I> by class {@code Config's}
201     * {@link Config#validate() validate} method.  Often, when the {@code Builder} instance is
202     * constructed, the {@code 'javadoc/'} output directory does not exist as it hasn't yet been
203     * created by the Java-Doc Tool yet.
204     * 
205     * <BR /><BR />{@code 'javadoc'} isn't run / executed until Build-Stage 2.
206     * 
207     * <EMBED CLASS=defs DATA-F=LOCAL_JAVADOC_DIR>
208     * <EMBED CLASS='external-html' DATA-FILE-ID=VALIDITY_NULL>
209     * <EMBED CLASS='external-html' DATA-FILE-ID=DIRECT_COPY>
210     * @see Config#LOCAL_JAVADOC_DIR
211     */
212    public final String LOCAL_JAVADOC_DIR;
213
214    /**
215     * This is a small name-{@code String} for the Project.
216     * 
217     * <BR /><BR /><B CLASS=JDDescLabel>Validity-Checking:</B>
218     * 
219     * <BR />This field's value is checked for validity by a Regular-Expression
220     * {@link Config#projectNameValidator validator} - publicly available in class {@link Config}.
221     * 
222     * <EMBED CLASS=defs DATA-F=PROJECT_NAME>
223     * <EMBED CLASS='external-html' DATA-FILE-ID=VALIDITY_NULL>
224     * <EMBED CLASS='external-html' DATA-FILE-ID=DIRECT_COPY>
225     * @see Config#PROJECT_NAME
226     * @see Config#projectNameValidator
227     */
228    public final String PROJECT_NAME;
229
230    /**
231     * The Project must have a "Version Number".  In this project -
232     * <B STYLE='color: darkred;'>JavaHTML 1.8</B>, at the writing of this JavaDoc Comment the 
233     * "Major Version Number" is {@code '1'}, while the "Minor Version Number" is {@code '8'}.
234     * 
235     * <BR /><BR /><B CLASS=JDDescLabel>Validity-Checking:</B>
236     * 
237     * <BR />This number must be a positive integer, and it is checked for validity by class
238     * {@code Config's} {@link Config#validate() validate} method.
239     * 
240     * <EMBED CLASS='external-html' DATA-F=VERSION_MAJOR_NUMBER DATA-FILE-ID=DIRECT_COPY>
241     * @see #VERSION_MINOR_NUMBER
242     * @see Config#VERSION_MAJOR_NUMBER
243     */
244    public final byte VERSION_MAJOR_NUMBER;
245
246    /**
247     * The Project-Version Minor-Number. 
248     * 
249     * <BR /><BR /><B CLASS=JDDescLabel>Validity-Checking:</B>
250     * 
251     * <BR />This number must be a positive integer, and it is checked for validity by class
252     * {@code Config's} {@link Config#validate() validate} method.
253     * 
254     * <EMBED CLASS='external-html' DATA-F=VERSION_MINOR_NUMBER DATA-FILE-ID=DIRECT_COPY>
255     * @see #VERSION_MAJOR_NUMBER
256     * @see Config#VERSION_MINOR_NUMBER
257     */
258    public final byte VERSION_MINOR_NUMBER;
259
260    /**
261     * This must contain the direct path from the current working directory to the {@code 'javac'}
262     * binary-file.  This {@code String}-Configuration names the executable used by Build-Stage 1.
263     * 
264     * <BR /><BR /><B CLASS=JDDescLabel>Validity-Checking:</B>
265     * 
266     * <BR />This parameter is not checked for validity, but the Java-Compiler Build-Stage Class,
267     * {@link S01_JavaCompiler}, will throw exceptions if this {@code String} doesn't point to a
268     * valid binary or executable file.
269     * 
270     * <EMBED CLASS=defs DATA-F=JAVAC_BIN>
271     * <EMBED CLASS='external-html' DATA-FILE-ID=VALIDITY_NULL>
272     * <EMBED CLASS='external-html' DATA-FILE-ID=DIRECT_COPY>
273     * @see Config#JAVAC_BIN
274     * @see S01_JavaCompiler
275     */
276    public final String JAVAC_BIN;
277
278    /**
279     * This must contain the direct path from the current working directory to the
280     * {@code 'javadoc'} binary-file.  This {@code String}-Configuration names the executable used
281     * by Build-Stage 1.
282     * 
283     * <BR /><BR /><B CLASS=JDDescLabel>Validity-Checking:</B>
284     * 
285     * <BR />This parameter is not checked for validity, but the Javadoc Build-Stage Class,
286     * {@link S02_JavaDoc}, will throw exceptions if this {@code String} doesn't point to a valid
287     * binary or executable file.
288     * 
289     * <EMBED CLASS=defs DATA-F=JAVADOC_BIN>
290     * <EMBED CLASS='external-html' DATA-FILE-ID=VALIDITY_NULL>
291     * <EMBED CLASS='external-html' DATA-FILE-ID=DIRECT_COPY>
292     * @see Config#JAVADOC_BIN
293     * @see S02_JavaDoc
294     */
295    public final String JAVADOC_BIN;
296
297    /**
298     * This Configuration-Field may be used to request that the Build-Tool insert the
299     * {@code 'javac'} Command-Line Switch {@code '--release XX'} to the {@code 'javac'} Command
300     * Invocation.  The release switch asks that the Java-Compiler generate Java Byte-Code that is
301     * that is consistent with the Byte-Code for the JDK-Release {@code 'X'}.
302     * 
303     * <BR /><BR />If {@code 'X'} were passed {@code '11'}, the Java-Compiler would generate Java
304     * Byte-Code that is consistent with the JDK-11 LTS (Released in Year 2018).
305     * 
306     * <BR /><BR />This parameter is not checked for validity, but the Java-Compiler will generate 
307     * error messages (instead of compiling) if the Release-Number isn't valid.  If you are using 
308     * JDK-11, and pass {@code '21'} to this Configuration-Field, {@code 'javac'} will obviously
309     * complain.
310     * 
311     * <BR /><BR />The default value for this field is {@code '-1'}.  Any negative number (or zero)
312     * assigned to this field will implicitly tell the Stage 1 Builder-Class that using a
313     * {@code '--release'} switch is not necessary, and should be left off when compiling
314     * {@code '.java'} Files.
315     * 
316     * <EMBED CLASS=defs DATA-F=JAVA_RELEASE_NUM_SWITCH>
317     * <EMBED CLASS='external-html' DATA-FILE-ID=DIRECT_COPY>
318     * @see Config#JAVA_RELEASE_NUM_SWITCH
319     * @see S01_JavaCompiler
320     */
321    public final byte JAVA_RELEASE_NUM_SWITCH;
322
323    /**
324     * Currently this is an unused Configuration-Field.  It is not checked for validity.
325     * When this class is constructed, this field is automatically assigned to the value of the 
326     * field {@link Config#JAVADOC_VER}.
327     * 
328     * @see Config#JAVADOC_VER
329     * @see S02_JavaDoc
330     */
331    public final byte JAVADOC_VER;
332
333    /**
334     * Contains {@code FAVICON} Image File-Name, to be used by the Stage 3 Build-Class 
335     * {@link S03_Upgrade}.  When this Configuration-Field is non-null, the Upgrade-Stage will copy
336     * favicon file into the {@link #LOCAL_JAVADOC_DIR}.
337     * 
338     * <BR /><BR />This Configuration-Field may be null - <I>which is the default value assigned to
339     * {@link Config#FAVICON}</I>.  When it is, no favicon file is copied to the root
340     * {@code 'javadoc/'} directory.
341     * 
342     * <BR /><BR /><B CLASS=JDDescLabel>Validity-Checking:</B>
343     * 
344     * <BR />This {@code String}-Field, when non-null, is checked whether or not it points to an
345     * actual Image-File, that both exists and is accessible on the File-System.  Class
346     * {@link Config Config's} {@link Config#validate() validate} method will throw a 
347     * {@code FileNotFoundException} if this check fails.
348     * 
349     * <BR /><BR />If class {@link Torello.HTML.Tools.Images.IF#guessOrThrow(String) IF} is unable
350     * to properly guess the Image-Type based on its File-Name, then an
351     * {@link UnrecognizedImageExtException} is thrown by the validator method.
352     * 
353     * <EMBED CLASS=defs DATA-F=FAVICON>
354     * <EMBED CLASS='external-html' DATA-FILE-ID=DIRECT_COPY>
355     * @see Config#FAVICON
356     * @see S03_Upgrade
357     */
358    public final String FAVICON;
359
360    /**
361     * This class specifies the Root Source-Code Directory containing all {@code '.java'}
362     * Files, {@code '.class'} Files, and any configurations needed for the build.  The 
363     * Stage 4 Builder-Class {@link S04_TarJar} invokes the OS Command {@code 'tar'} around this
364     * directory to create a Project Backup-File.
365     * 
366     * <BR /><BR />The name given the Project Tar-Backup File will just be the {@code String}
367     * provided to {@link #PROJECT_NAME}, followed by the {@link #VERSION_MAJOR_NUMBER} and 
368     * {@link #VERSION_MINOR_NUMBER}.
369     * 
370     * <BR /><BR /><B CLASS=JDDescLabel>Validity-Checking:</B>
371     * 
372     * <BR />This {@code String}-Field may not be null, or {@code NullPointerException} throws.
373     * Furthermore the {@code Config} {@link Config#validate() validate} method will ensure that
374     * this {@code String} points to a valid and accessible File-System Directory-Name.
375     * 
376     * <BR /><BR />If this isn't a valid directory, a {@code FileNotFoundException} will throw.
377     * Keep in mind that {@code FileNotFoundException} is a Java Checked-Exception which inherits
378     * {@code IOException}.
379     * 
380     * <BR /><BR /><B CLASS=JDDescLabel>Configuration-Field Use:</B>
381     * 
382     * <BR />This field is very simply used in the Stage 4 Build-Class {@link S04_TarJar} as
383     * follows.  The following code snippet was copied on March 4th, 2024:
384     * 
385     * <BR /><DIV CLASS=SNIP>{@code 
386     * // Shell-Constructor Parameters used:
387     * // (outputAppendable, commandStrAppendable, standardOutput, errorOutput)
388     * 
389     * Shell shell = new Shell(SB_TAR, new BiAppendable(SB_TAR, System.out), null, null);
390     * 
391     * // JavaHTML-1.x.tar.gz
392     * CHECK(
393     *     shell.COMMAND(
394     *         "tar",
395     *         new String[] { "-cvzf", builder.TAR_FILE, builder.TAR_SOURCE_DIR }
396     * ));
397     * }</DIV>
398     * 
399     * <EMBED CLASS=defs DATA-F=TAR_SOURCE_DIR>
400     * <EMBED CLASS='external-html' DATA-FILE-ID=DIRECT_COPY>
401     * @see Config#TAR_SOURCE_DIR
402     * @see #TAR_FILE
403     * @see S04_TarJar
404     * @see S06_SyncTarJar
405     */
406    public final String TAR_SOURCE_DIR;
407
408    /**
409     * In Java-HTML there are a few Upgrade-Stage (Stage 3) processes that need to be executed 
410     * before the actual {@link Upgrade#upgrade() upgrade} can run.  All of the processes currently
411     * in the {@code 'preUpgraderScript'} are on a general "To Do List" for being moved into the 
412     * actual Upgrade-API.
413     * 
414     * <BR /><BR />This Configuration-Field may be null, and if it is, it is ignored.  The Stage 3
415     * Build-Class {@link S03_Upgrade} simply runs the following code, below.  This snippet was
416     * block-copied directly from {@code 'S03_Upgrade.upgrade'}.
417     * 
418     * <BR /><DIV CLASS=SNIP>{@code
419     * builder.timers.startStage03();
420     * 
421     * Printing.startStep(3);
422     * 
423     * // This is used as a Log-File Collector
424     * StringBuilder sb = new StringBuilder();
425     * 
426     * // Check if there is a User-Provided "Pre-Upgrade Script", if so, then run it.
427     * if (builder.preUpgraderScript != null) builder.preUpgraderScript.accept(builder, sb);
428     * 
429     * sb.append("... Note to Console about Starting Build ...");
430     * 
431     * // And now start the actual Upgrade
432     * Stats result = builder.upgrader.upgrade(); 
433     * }</DIV>
434     * 
435     * <BR /><BR />Clearly, a validity check on this Configuration-Field isn't possible.
436     * 
437     * <EMBED CLASS=defs DATA-F=preUpgraderScript>
438     * <EMBED CLASS='external-html' DATA-FILE-ID=DIRECT_COPY>
439     * @see Config#preUpgraderScript
440     * @see #postUpgraderScript
441     * @see Config#postUpgraderScript
442     * @see S03_Upgrade
443     */
444    public final UpgradeProcessor preUpgraderScript;
445
446    /**
447     * This functions identically to the {@link #preUpgraderScript}, but is executed immediately
448     * after Class {@link S03_Upgrade} has run to completion.
449     * 
450     * <BR /><BR />This field may be null, and if it is it will be silently ignored.  No validity
451     * checks are executed for this Configuration-Field.
452     * 
453     * <EMBED CLASS=defs DATA-F=postUpgraderScript>
454     * <EMBED CLASS='external-html' DATA-FILE-ID=DIRECT_COPY>
455     * @see Config#postUpgraderScript
456     * @see #preUpgraderScript
457     * @see Config#preUpgraderScript
458     * @see S03_Upgrade
459     */
460    public final UpgradeProcessor postUpgraderScript;
461
462
463
464
465    // ********************************************************************************************
466    // ********************************************************************************************
467    // ********************************************************************************************
468    // ********************************************************************************************
469    // Fields - Composite stuff & Modified Stuff
470    // ********************************************************************************************
471    // ********************************************************************************************
472    // ********************************************************************************************
473    // ********************************************************************************************
474
475
476
477
478    /**
479     * Setting values for this {@code String[]}-Array allows a user to provide extra or additional
480     * Command-Line switches to the Java-Compiler if it is invoked.
481     * 
482     * <BR /><BR /><B CLASS=JDDescLabel>Validity Checking:</B>
483     * 
484     * <BR />No validity checks are done for the contents of these {@code 'javac'} "Extra
485     * Switches".  However, if any faulty or erroneous switch elements in the User-Provided
486     * {@code String[]}-Array are provided, then the Stage 1 Build-Class {@link S01_JavaCompiler}
487     * will likely through exceptions when if it is invoked.
488     * 
489     * <BR /><BR /><B CLASS=JDDescLabel>Copying {@link Config#extraSwitchesJAVAC}:</B>
490     * 
491     * <BR />The following is how this field is copied from the contents of class {@code Config}
492     * (a User-Provided class):
493     * 
494     * <BR /><DIV CLASS=SNIP>{@code
495     * // Config.extraSwitchesJAVAC     ==> String[]
496     * // Builder.extraSwitchesJAVAC    ==> ReadOnlyList<String>
497     * 
498     * this.extraSwitchesJAVAC =
499     *     ((config.extraSwitchesJAVAC == null) || (config.extraSwitchesJAVAC.length == 0))
500     *          ? null
501     *          : ReadOnlyList.of(config.extraSwitchesJAVAC);
502     * }</DIV>
503     * 
504     * @see Config#extraSwitchesJAVAC
505     * @see ReadOnlyList
506     * @see S01_JavaCompiler
507     */
508    public final ReadOnlyList<String> extraSwitchesJAVAC;
509
510    /**
511     * Setting values for this {@code String[]}-Array allows a user to provide extra or additional
512     * Command-Line switches to the {@code 'javadoc'} Tool if it is invoked.
513     * 
514     * <BR /><BR /><B CLASS=JDDescLabel>Validity Checking:</B>
515     * 
516     * <BR />No validity checks are done for the contents of these {@code 'javadoc'} "Extra
517     * Switches".  However, if any faulty or erroneous switch elements in the User-Provided
518     * {@code String[]}-Array are provided, then the Stage 2 Build-Class {@link S02_JavaDoc}
519     * will likely through exceptions when if it is invoked.
520     * 
521     * <BR /><BR /><B CLASS=JDDescLabel>Copying {@link Config#extraSwitchesJAVADOC}:</B>
522     * 
523     * <BR />The following is how this field is copied from contents of User-Provided class
524     * {@link Config}:
525     * 
526     * <BR /><DIV CLASS=SNIP>{@code
527     * // Config.extraSwitchesJAVADOC     ==> String[]
528     * // Builder.extraSwitchesJAVADOC    ==> ReadOnlyList<String>
529     * 
530     * this.extraSwitchesJAVADOC =
531     *     ((config.extraSwitchesJAVADOC == null) || (config.extraSwitchesJAVADOC.length == 0))
532     *          ? null
533     *          : ReadOnlyList.of(config.extraSwitchesJAVADOC);
534     * }</DIV>
535     * 
536     * @see Config#extraSwitchesJAVADOC
537     * @see ReadOnlyList
538     * @see S02_JavaDoc
539     */
540    public final ReadOnlyList<String> extraSwitchesJAVADOC;
541
542    /**
543     * This is the {@link Upgrade} instance that was passed to the class {@link Config} Field
544     * {@link Config#upgrader}.
545     * 
546     * @see Config#upgrader
547     * @see S03_Upgrade
548     */
549    public final Upgrade upgrader;
550
551    /**
552     * The Computed File-Name for the Project-Wide {@code '.tar'} Backup-File.
553     * 
554     * <BR /><BR />This Configuration-Field is computed using other fields, and cannot be
555     * "supplied" by the User.  Below is the code used to generate this File-Name / Field.
556     * 
557     * <BR /><DIV CLASS=SNIP>{@code
558     * // For Java-HTML, this would be, (for example) - "1.8"
559     * final String NUM = VERSION_MAJOR_NUMBER + "." + VERSION_MINOR_NUMBER;
560     * 
561     * // For Project "JavaHTML", this would be "JavaHTML-1.8.tar.gz"
562     * this.TAR_FILE = this.PROJECT_NAME + "-" + NUM + ".tar.gz";
563     * }</DIV>
564     * 
565     * @see #PROJECT_NAME
566     * @see #VERSION_MAJOR_NUMBER
567     * @see #VERSION_MINOR_NUMBER
568     * @see S04_TarJar
569     * @see S06_SyncTarJar
570     */
571    public final String TAR_FILE;
572
573    /**
574     * The Computed File-Name for the Project's Distribution {@code '.jar'} File.
575     * 
576     * <BR /><BR />This Configuration-Field is computed using other fields, and cannot be
577     * "supplied" by the User.  Below is the code used to generate this File-Name / Field.
578     * 
579     * <BR /><DIV CLASS=SNIP>{@code
580     * // For Java-HTML, this would be, (for example) - "1.8"
581     * final String NUM = VERSION_MAJOR_NUMBER + "." + VERSION_MINOR_NUMBER;
582     * 
583     * // For Project "JavaHTML", this would be "JavaHTML-1.8.jar"
584     * this.JAR_FILE = this.PROJECT_NAME + "-" + NUM + ".jar";
585     * }</DIV>
586     * 
587     * @see #PROJECT_NAME
588     * @see #VERSION_MAJOR_NUMBER
589     * @see #VERSION_MINOR_NUMBER
590     * @see S04_TarJar
591     * @see S06_SyncTarJar
592     */
593    public final String JAR_FILE;
594
595    /**
596     * The Computed File-Name for the Project's Javadoc Documentation {@code '.tar.gz'} File.
597     * 
598     * <BR /><BR />This Configuration-Field is computed using other fields, and cannot be
599     * "supplied" by the User.  Below is the code used to generate this File-Name / Field.
600     * 
601     * <BR /><DIV CLASS=SNIP>{@code
602     * // For Java-HTML, this would be, (for example) - "1.8"
603     * final String NUM = VERSION_MAJOR_NUMBER + "." + VERSION_MINOR_NUMBER;
604     * 
605     * // For Project "JavaHTML", this would be "JavaHTML-javadoc-1.8.tar"
606     * this.JAVADOC_TAR_FILE = this.PROJECT_NAME + "-javadoc-" + NUM + ".tar";
607     * }</DIV>
608     * 
609     * @see #PROJECT_NAME
610     * @see #VERSION_MAJOR_NUMBER
611     * @see #VERSION_MINOR_NUMBER
612     * @see S04_TarJar
613     * @see S06_SyncTarJar
614     */
615    public final String JAVADOC_TAR_FILE;
616
617    /**
618     * This is an auto-generated field, that utilizes the {@link Config}-Class Field
619     * {@link Config#JAR_FILE_MOVE_DIR}.  When this field is non-null, the {@code '.jar'} File that
620     * is generated by the Stage 4 Build-Class {@link S04_TarJar} is copied to the directory
621     * specified.
622     * 
623     * <BR /><DIV CLASS=SNIP>{@code
624     * this.JAR_FILE_NAME = (config.JAR_FILE_MOVE_DIR != null)
625     *     ? (config.JAR_FILE_MOVE_DIR + this.PROJECT_NAME + ".jar")
626     *     : null;
627     * }</DIV>
628     * 
629     * @see Config#JAR_FILE_MOVE_DIR
630     * @see S04_TarJar
631     * @see S06_SyncTarJar
632     */
633    public final String JAR_FILE_NAME;
634
635    /**
636     * This is the classpath that is passed to the Stage 1 Build-Class {@link S01_JavaCompiler}.
637     * 
638     * <BR /><BR />This field's value is computed and assigned by a package-only visible
639     * initializer method in class {@link Config}.
640     * 
641     * @see S01_JavaCompiler
642     */
643    public final String CLASS_PATH_STR;
644
645    /**
646     * The helps the Build-Logic decide whether to use the Java-Compiler Switch {@code -Xlint:all}.
647     * The default behavior is that the Java-Compiler will be invoked using that switch for all
648     * {@code '.java'} Files that are being compiled.
649     * 
650     * <BR /><BR />The default behavior assigned in Configuration-Class {@link Config} can easily
651     * be changed by reassigning the necessary value to field {@link Config#USE_XLINT_SWITCH}. When
652     * this field is reassiged a new {@code boolean}, any invocation of the {@code Builder}'s 
653     * Java-Compiler Stage will check whether to use the {@code -Xlint:all}, based on this field's
654     * value.
655     * 
656     * <BR /><BR />On top of {@code Config.USE_XLINT_SWITCH}, a user has the option of passing the
657     * Command-Line Wwitch {@code -TXL} when invoking the Java-Compiler Build-Stage which, in
658     * effect, toggles whatever value was set by the original {@link Config#USE_XLINT_SWITCH}
659     * setting.  (This may be done when invoking {@code 'Builder'} from the CLI).
660     * 
661     * <BR /><BR />This may be more clearly seen in the code used to assign this field's value:
662     * 
663     * <BR /><DIV CLASS=SNIP>{@code
664     * this.USE_XLINT_SWITCH = this.cli.aor.OVERRIDE_TOGGLE_USE_XLINT_SWITCH
665     *     ? (! config.USE_XLINT_SWITCH)
666     *     : config.USE_XLINT_SWITCH;
667     * }</DIV>
668     * 
669     * @see Config#USE_XLINT_SWITCH
670     * @see AuxiliaryOptRecord#OVERRIDE_TOGGLE_USE_XLINT_SWITCH
671     * @see S01_JavaCompiler
672     */
673    public final boolean USE_XLINT_SWITCH;
674
675    /**
676     * The helps the Build-Logic decide whether to use the Java-Compiler Switch
677     * {@code -Xdiags:verbose}.  The default behavior is that the Java-Compiler will be invoked
678     * using that switch for all {@code '.java'} Files that are being compiled.
679     * 
680     * <BR /><BR />The default behavior assigned in Configuration-Class {@link Config} can easily
681     * be changed by reassigning the necessary value to field {@link Config#USE_XDIAGS_SWITCH}.
682     * When this field is reassiged a new {@code boolean}, any invocation of the {@code Builder}'s
683     * Java-Compiler Stage will check whether to use the {@code -Xdiags:verbose}, based on this
684     * field's value.
685     * 
686     * <BR /><BR />On top of {@code Config.USE_XDIAGS_SWITCH}, a user has the option of passing the
687     * Command-Line Wwitch {@code -TXL} when invoking the Java-Compiler Build-Stage which, in
688     * effect, toggles whatever value was set by the original {@link Config#USE_XDIAGS_SWITCH}
689     * setting.  (This may be done when invoking {@code 'Builder'} from the CLI).
690     * 
691     * <BR /><BR />This may be more clearly seen in the code used to assign this field's value:
692     * 
693     * <BR /><DIV CLASS=SNIP>{@code
694     * this.USE_XDIAGS_SWITCH = this.cli.aor.OVERRIDE_TOGGLE_USE_XDIAGS_SWITCH
695     *     ? (! config.USE_XDIAGS_SWITCH)
696     *     : config.USE_XDIAGS_SWITCH;
697     * }</DIV>
698     * 
699     * @see Config#USE_XDIAGS_SWITCH
700     * @see AuxiliaryOptRecord#OVERRIDE_TOGGLE_USE_XDIAGS_SWITCH
701     * @see S01_JavaCompiler
702     */
703    public final boolean USE_XDIAGS_SWITCH;
704
705    /**
706     * Requests that the {@code --frames} switch, which by default is passed to the Stage 2
707     * Build-Class {@link S02_JavaDoc} be omitted.
708     * 
709     * <BR /><BR />By default, this Configuration-Field is assigned {@code FALSE}, which means that
710     * the {@code --frames} switch, <I>by default, s passed to the {@code javadoc} stage</I>.
711     * 
712     * <BR /><BR />Make sure to remember that after the JDK 11 Release, the {@code --frames} switch
713     * was fully deprecated and removed from the tool.  In such cases, make sure to assign
714     * {@code TRUE} to the field {@link Config#NO_JAVADOC_FRAMES_SWITCH}, or the Stage 2
715     * Build-Class will throw an exception.
716     * 
717     * <EMBED CLASS=defs DATA-F=NO_JAVADOC_FRAMES_SWITCH>
718     * <EMBED CLASS='external-html' DATA-FILE-ID=DIRECT_COPY>
719     * @see Config#NO_JAVADOC_FRAMES_SWITCH
720     * @see S02_JavaDoc
721     */
722    public final boolean NO_JAVADOC_FRAMES_SWITCH;
723
724    /**
725     * This Configuration is largely copied, directly, from the User-Provided {@link Config} class
726     * instance received.  This Configuration-Field simply contains the list of packages that 
727     * comprise the Java Project being built, compiled, documented &amp; sychronized.
728     * 
729     * <BR /><BR />Class {@link Config}-Field {@link Config#packageList} contains a User-Provided
730     * list of packages, as instances of {@link BuildPackage}.
731     * 
732     * <BR /><BR />There isn't any validation done on the input array, other than that it must be 
733     * non-null, and contain at least Java Package.
734     * 
735     * <BR /><BR /><B CLASS=JDDescLabel>Quick Build Note:</B>
736     * 
737     * <BR />The option to eliminate certain packages when doing a build is provided by class 
738     * {@link BuildPackage}.  The {@code BuildPackage} Static-Flag
739     * {@link BuildPackage#QUICKER_BUILD_SKIP} lets a user convey that, during development time, 
740     * the compilation and documentation stages can skip certain packages altogether.
741     * 
742     * <BR /><BR />Note that if class {@link CLI} has specified its {@link CLI#QUICKER_BUILD}
743     * field, then and only then, are packages designed as {@link BuildPackage#skipIfQuickerBuild}
744     * actually removed.
745     * 
746     * <BR /><BR /><B CLASS=JDDescLabel>Under Development Note:</B>
747     * 
748     * <BR />The option to eliminate certain packages because they are still under development is 
749     * an option also provided by the class {@link BuildPackage} (via the
750     * {@link BuildPackage#EARLY_DEVELOPMENT EARLY_DEVELOPMENT} flag, and by the
751     * {@link BuildPackage#earlyDevelopment earlyDevelopment} field),
752     * <B STYLE='color: red;'><I>and by the class</I></B> {@link CLI} (via the 
753     * {@link AuxiliaryOptRecord#INCLUDE_EARLY_DEV_PACKAGES_SWITCH
754     * INCLUDE_EARLY_DEV_PACKAGES_SWITCH} field).
755     * 
756     * <BR /><BR ><B CLASS=JDDescLabel>Assigning this Field:</B>
757     * 
758     * <BR />This field's reference/value is assigned in this class constructor as in the code
759     * included below.  The value is generated by the class / method:
760     * {@link Packages#packagesInThisBuild(CLI, BuildPackage[]) packagesInThisBuild}.
761     * 
762     * <BR /><DIV CLASS=SNIP>{@code
763     * // This eliminates any packages that are irrelevant, as per the specifications
764     * // by the User at the Command-Line Interface 'argv' parameter.
765     * // 
766     * // The included packages are in:    "Ret2.a"
767     * // The eliminated packages are in:  "Ret2.b"
768     * 
769     * Ret2<ReadOnlyList<BuildPackage>, ReadOnlyList<BuildPackage>> ret2 =
770     *     Packages.packagesInThisBuild(this.cli, config.packageList);
771     * 
772     * // This is used in S01_JavaCompiler, S02_JavaDoc and S04_TarJar
773     * this.packageList = ret2.a;
774     * }</DIV>
775     * 
776     * @see Packages#packagesInThisBuild(CLI, BuildPackage[])
777     * @see Config#packageList
778     * @see CLI#QUICKER_BUILD
779     * @see BuildPackage#QUICKER_BUILD_SKIP
780     * @see BuildPackage#skipIfQuickerBuild
781     */
782    public final ReadOnlyList<BuildPackage> packageList;
783
784    /**
785     * Additional &amp; Miscellaneous Files that must be incorporated into the Project's
786     * {@code '.jar'} File.
787     * 
788     * <BR /><BR />This Configuration-Field's value is computed by using package-private 
789     * initializer code, as follows:
790     * 
791     * <BR /><DIV CLASS=SNIP>{@code
792     * this.jarIncludes = (config.jarIncludes != null)
793     *     ? config.jarIncludes.getAllDesriptors()
794     *     : null;
795     * }</DIV>
796     * 
797     * @see Config#jarIncludes
798     * @see S04_TarJar
799     */
800    public final ReadOnlyList<JarInclude.Descriptor> jarIncludes;
801
802    /**
803     * This is generated by parsing the Command-Line Arguments passed to this class constructor.
804     * 
805     * Class {@link CLI}'s constructor accepts an {@code 'argv'} parameter, which should have been
806     * obtained from an invocation of any {@code public static void main} method.
807     */
808    public final CLI cli;
809
810    /**
811     * Multiple Cloud-Synchronization Options may be presented within the User-Provided class
812     * {@link Config} instance.  This instance is to be populated, at configuration time, by 
813     * simply invoking that class' {@link Config#addCloudSync(CloudSync)} method.
814     * 
815     * <BR /><BR />Once a {@code Config} instance is creaed, it is likely next to be used to parse
816     * "The User's User" Command-Line Terminal-Shell Menu-Input.  Specificaly, the logic that
817     * processes the CLI Switches executes, and it is at that point that one of the (possibly
818     * multiple) Cloud Storage-Buckets or Storage-Systems are selected.
819     * 
820     * <BR /><BR />This field should contain a reference to the {@link CloudSync} instance that
821     * was chosen at the Command-Line.
822     */
823    public final CloudSync cloudSync;
824
825
826
827    // ********************************************************************************************
828    // ********************************************************************************************
829    // ********************************************************************************************
830    // ********************************************************************************************
831    // Package-Private Constructor
832    // ********************************************************************************************
833    // ********************************************************************************************
834    // ********************************************************************************************
835    // ********************************************************************************************
836
837
838
839
840    /**
841     * Run this class constructor, and afterwards the {@link #build()} method can be invoked.
842     * 
843     * @param config Any instance of class {@code Config}
844     * 
845     * @param argv Any {@code String[]}-Array instance that has been obtained from any invocation
846     * of a {@code public static void main} method.
847     * 
848     * @throws FileNotFoundException Throw by the class {@link Config}
849     * {@link Config#validate() validate} method if there are problems with the user's provided
850     * configurations.
851     */
852    BuilderRecord(Config config, String... argv) throws FileNotFoundException, IOException
853    {
854        Objects.requireNonNull(config);
855        config.validate();
856
857
858        // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
859        // Initialize the BuilderRecord Log
860        // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
861
862        final StringBuilder dataRecLogSB = new StringBuilder();
863
864        dataRecLogSB.append(
865            Printing.DATA_REC_LOG_LINES +
866            "String[] argv:\n" + 
867            Printing.DATA_REC_LOG_LINES + '\n' +
868            BGREEN + String.join(", ", argv) + RESET + "\n\n" +
869            
870            Printing.DATA_REC_LOG_LINES +
871            "Config:\n" + 
872            Printing.DATA_REC_LOG_LINES + '\n' +
873            config.toString() + "\n\n"
874        );
875
876
877        // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
878        // Fields that are directly copied from "Config"
879        // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
880
881        this.HOME_DIR                   = config.HOME_DIR;
882        this.LOCAL_JAVADOC_DIR          = config.LOCAL_JAVADOC_DIR;
883        this.PROJECT_NAME               = config.PROJECT_NAME;
884        this.VERSION_MAJOR_NUMBER       = config.VERSION_MAJOR_NUMBER;
885        this.VERSION_MINOR_NUMBER       = config.VERSION_MINOR_NUMBER;
886        this.JAVAC_BIN                  = config.JAVAC_BIN;
887        this.JAVADOC_BIN                = config.JAVADOC_BIN;
888        this.JAVA_RELEASE_NUM_SWITCH    = config.JAVA_RELEASE_NUM_SWITCH;
889        this.JAVADOC_VER                = config.JAVADOC_VER;
890        this.FAVICON                    = config.FAVICON;
891        this.TAR_SOURCE_DIR             = config.TAR_SOURCE_DIR;
892        this.NO_JAVADOC_FRAMES_SWITCH   = config.NO_JAVADOC_FRAMES_SWITCH;
893        this.preUpgraderScript          = config.preUpgraderScript;
894        this.postUpgraderScript         = config.postUpgraderScript;
895
896
897        // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
898        // Package-Private, Internally-Used Fields (not useful to user)
899        // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
900
901        // These two are declared "Package-Private" - everything else is public
902        this.logs           = new Logs(config.LOG_DIR);
903        this.timers         = new Timers();
904
905
906        // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
907        // Slightly Modified, but Copied Fields
908        // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
909
910        this.extraSwitchesJAVAC =
911            ((config.extraSwitchesJAVAC == null) || (config.extraSwitchesJAVAC.length == 0))
912                ? null
913                : ReadOnlyList.of(config.extraSwitchesJAVAC);
914
915        this.extraSwitchesJAVADOC =
916            ((config.extraSwitchesJAVADOC == null) || (config.extraSwitchesJAVADOC.length == 0))
917                ? null
918                : ReadOnlyList.of(config.extraSwitchesJAVADOC);
919
920        this.jarIncludes = (config.jarIncludes != null)
921            ? config.jarIncludes.getAllDesriptors()
922            : null;
923
924
925        // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
926        // Composite / Composed Config-Fields
927        // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
928
929        final String NUM = VERSION_MAJOR_NUMBER + "." + VERSION_MINOR_NUMBER;
930
931        this.TAR_FILE           = this.PROJECT_NAME + "-" + NUM + ".tar.gz";
932        this.JAR_FILE           = this.PROJECT_NAME + "-" + NUM + ".jar";
933        this.JAVADOC_TAR_FILE   = this.PROJECT_NAME + "-javadoc-" + NUM + ".tar";
934
935        this.JAR_FILE_NAME = (config.JAR_FILE_MOVE_DIR != null)
936            ? (config.JAR_FILE_MOVE_DIR + this.PROJECT_NAME + ".jar")
937            : null;
938
939
940        // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
941        // REQUIRES THE COMMAND-LINE / CLI (this.cli) INPUT-DATA TO ASSIGN THESE FIELDS
942        // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
943        // 
944        // This is a "Pass By Reference", so that the Constructor can also return a value.  The
945        // value (reference, actually) returned "into" the ByRef is the CloudSync insstance that is
946        // associated with the Command-Line Option that the user selected at the Command Line.
947
948        @SuppressWarnings("rawtypes")
949        ByRef<CloudSync> selectedCloudSync = new ByRef<>(null);
950
951        // This is public, and it is needed by the next two fields, so it's constructed before them
952        this.cli = new CLI(
953            config.cloudSyncListBuilder.build(),
954            new ReadOnlyArrayList<>(config.packageList),
955            argv,
956            selectedCloudSync,
957            dataRecLogSB
958        );
959
960
961        // This is also recently added, but it is very simple.  The above "pass by reference" 
962        // actually retrieves / extracts the selected "CloudSync" from the Constructor.
963
964        this.cloudSync = selectedCloudSync.f;
965
966        this.CLASS_PATH_STR =
967            config.classPathStr(this.cli.aor.INCLUDE_JAR_IN_CP_SWITCH, this.JAR_FILE_NAME);
968
969        this.USE_XLINT_SWITCH = this.cli.aor.OVERRIDE_TOGGLE_USE_XLINT_SWITCH
970            ? (! config.USE_XLINT_SWITCH)
971            : config.USE_XLINT_SWITCH;
972
973        this.USE_XDIAGS_SWITCH = this.cli.aor.OVERRIDE_TOGGLE_USE_XDIAGS_SWITCH
974            ? (! config.USE_XDIAGS_SWITCH)
975            : config.USE_XDIAGS_SWITCH;
976
977
978        // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
979        // Class Upgrade Itself
980        // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
981
982        final Upgrade tempUpgrader =
983            config.upgrader.setLogFile(config.LOG_DIR + Logs.S03_UPGRADER);
984
985        /*
986        System.out.println(
987            "this.cli.sor.userSpecifiedPackages: " +
988            this.cli.sor.userSpecifiedPackages
989        );
990        */
991
992        this.upgrader = (this.cli.sor.userSpecifiedPackages == null)
993            ? tempUpgrader 
994            : tempUpgrader.setPackageList(this.cli.sor.userSpecifiedPackages);
995
996
997        // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
998        // Build Package List
999        // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
1000        // 
1001        // This eliminates any packages that are irrelevant, as per the specifications
1002        // by the User at the Command-Line Interface 'argv' parameter.  If you want to see the
1003        // heuristic for what is in the included-list and what is in the eliminated-list, please
1004        // review the notes inside of class 'Packages'.
1005        // 
1006        // It is not completely trivial because of the 'Quick-Build' and the 'Under-development'
1007        // BuildPackage Flags.
1008        // 
1009        // The included packages are in:    "Ret2.a"
1010        // The eliminated packages are in:  "Ret2.b"
1011
1012        Ret2<ReadOnlyList<BuildPackage>, ReadOnlyList<BuildPackage>> ret2 =
1013            Packages.packagesInThisBuild(this.cli, config.packageList);
1014
1015        // This is used in S01_JavaCompiler, S02_JavaDoc and S04_TarJar
1016        this.packageList = ret2.a;
1017
1018
1019        // The JavaDoc Upgrader will use this "Eliminated List" in the class
1020        // GenerateOverviewFrame. 
1021
1022        Torello.JavaDoc.EXPORT_PORTAL.Upgrade$registerEliminatedBuildPackages
1023            (this.upgrader, ret2.b);
1024
1025
1026        // NOTE: this.cloudSync is null when, for example, the user passes "-1" at the CLI.  Since
1027        //       the "-1" command-switch doesn't involve any synchronization at all, it doesn't
1028        //       even bother to figure out which CloudSync instance the user selected.  In fact the
1029        //       user didn't select any of them in such cases  (Build Options #1 through #4).
1030        // 
1031        // Note that every one of the exported fields inside of abstract-class "CloudSync" are
1032        // declared public & final - except the Package-Private Builder-Instance reference. 
1033
1034        if (this.cloudSync != null) this.cloudSync.brec = this;
1035
1036
1037        // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
1038        // Data-Records Output-Log
1039        // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
1040
1041        dataRecLogSB.append(
1042            Printing.DATA_REC_LOG_LINES +
1043            "CLI:\n" + 
1044            Printing.DATA_REC_LOG_LINES + '\n' +
1045            this.cli.toString() + "\n\n"
1046        );
1047
1048        final String dataRecLog = dataRecLogSB.toString();
1049
1050        FileRW.writeFile(
1051            dataRecLog,
1052            config.LOG_DIR + File.separator + BUILDER_RECORD_LOG_FILENAME + ".txt"
1053        );
1054
1055        final String dataRecLogHTML =
1056            Torello.Java.C.toHTML(dataRecLog, true, false, "Build Record-Contents Log");
1057
1058        FileRW.writeFile(
1059            dataRecLogHTML,
1060            config.LOG_DIR + File.separator + BUILDER_RECORD_LOG_FILENAME + ".html"
1061        );
1062    }
1063}