001package Torello.Java.Build;
002
003import java.io.File;
004
005import java.util.Arrays;
006import java.util.function.Consumer;
007import java.util.function.Predicate;
008import java.util.stream.Stream;
009
010import Torello.Java.FileNodeException;
011import Torello.Java.Q;
012import Torello.Java.StrCmpr;
013import Torello.Java.UnreachableError;
014import Torello.Java.Verbosity;
015import Torello.Java.StringParse;    // Needed for JavaDoc {@link's}
016import Torello.Java.GSUTIL;         // Needed for JavaDoc {@link's}
017
018import Torello.Java.ReadOnly.ReadOnlyList;
019import Torello.Java.ReadOnly.ReadOnlyArrayList;
020
021import Torello.Java.Additional.Ret2;
022
023import Torello.JavaDoc.Upgrade;
024
025// Needed for a javadoc {@link}
026import Torello.HTML.Tools.Images.UnrecognizedImageExtException;
027
028import java.io.FileNotFoundException;
029import java.io.IOException;
030
031public class Builder
032{
033    // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
034    // A Minor "Optimization" (Hack) - Note that this Field is Package-Visible
035    // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
036    //
037    // This field is set by Stage-5, and then retrieved in Stage-8.  This allows the String[] Array
038    // to avoid being re-computed / re-calculated twice.
039    //
040    // Just stores some GCS-Directories to make the "Make-Public" Command (Stage-8) run a lot
041    // faster when a User has provided a sub-set / list of Packages using their Nick-Names.  
042    // Essentially the "Old Way" to run Stage-8 was to call "Make-Public" on the entire GCS
043    // Directory-Tree for a Project - even when only a small sub-set of files were updated.  Now,
044    // when a small sub-set of files are synchronized, only those files are subjected to the 
045    // GSUTIL.MP Command.  This shaves off 10 seconds on the Partial-Build's.  GSUTIL is a littl
046    // slow.
047
048    String[] stage8GCSDirs = null;
049
050
051
052
053    // ********************************************************************************************
054    // ********************************************************************************************
055    // ********************************************************************************************
056    // ********************************************************************************************
057    // Fields - These Directly Copied from class Config.  Unmodified, same name
058    // ********************************************************************************************
059    // ********************************************************************************************
060    // ********************************************************************************************
061    // ********************************************************************************************
062
063
064
065
066    /**
067     * Used during the JAR-Build (Stage 4).
068     * TO BE EXPLAINED AT A LATER DATE.
069     * @see Config#HOME_DIR
070     */
071    public final String HOME_DIR;
072
073    /**
074     * This {@code String} contains either the absolute, or the relative, path to the on-disk
075     * location of the directory where {@code javadoc} has left its output.
076     * 
077     * <BR /><BR /><B CLASS=JDDescLabel>Validity-Checking:</B>
078     * 
079     * <BR />A Directory-Check <I>is not performed</I> by class {@code Config's}
080     * {@link Config#validate() validate} method.  Often, when the {@code Builder} instance is
081     * constructed, the {@code 'javadoc/'} output directory does not exist as it hasn't yet been
082     * created by the Java-Doc Tool yet.
083     * 
084     * <BR /><BR />{@code 'javadoc'} isn't run / executed until Build-Stage 2.
085     * 
086     * <EMBED CLASS=defs DATA-F=LOCAL_JAVADOC_DIR>
087     * <EMBED CLASS='external-html' DATA-FILE-ID=VALIDITY_NULL>
088     * <EMBED CLASS='external-html' DATA-FILE-ID=DIRECT_COPY>
089     * @see Config#LOCAL_JAVADOC_DIR
090     */
091    public final String LOCAL_JAVADOC_DIR;
092
093    /**
094     * This is a small name-{@code String} for the Project.
095     * 
096     * <BR /><BR /><B CLASS=JDDescLabel>Validity-Checking:</B>
097     * 
098     * <BR />This field's value is checked for validity by a Regular-Expression
099     * {@link Config#projectNameValidator validator} - publicly available in class {@link Config}.
100     * 
101     * <EMBED CLASS=defs DATA-F=PROJECT_NAME>
102     * <EMBED CLASS='external-html' DATA-FILE-ID=VALIDITY_NULL>
103     * <EMBED CLASS='external-html' DATA-FILE-ID=DIRECT_COPY>
104     * @see Config#PROJECT_NAME
105     * @see Config#projectNameValidator
106     */
107    public final String PROJECT_NAME;
108
109    /**
110     * The Project must have a "Version Number".  In this project -
111     * <B STYLE='color: darkred;'>JavaHTML 1.8</B>, at the writing of this JavaDoc Comment the 
112     * "Major Version Number" is {@code '1'}, while the "Minor Version Number" is {@code '8'}.
113     * 
114     * <BR /><BR /><B CLASS=JDDescLabel>Validity-Checking:</B>
115     * 
116     * <BR />This number must be a positive integer, and it is checked for validity by class
117     * {@code Config's} {@link Config#validate() validate} method.
118     * 
119     * <EMBED CLASS='external-html' DATA-F=VERSION_MAJOR_NUMBER DATA-FILE-ID=DIRECT_COPY>
120     * @see #VERSION_MINOR_NUMBER
121     * @see Config#VERSION_MAJOR_NUMBER
122     */
123    public final byte VERSION_MAJOR_NUMBER;
124
125    /**
126     * The Project-Version Minor-Number. 
127     * 
128     * <BR /><BR /><B CLASS=JDDescLabel>Validity-Checking:</B>
129     * 
130     * <BR />This number must be a positive integer, and it is checked for validity by class
131     * {@code Config's} {@link Config#validate() validate} method.
132     * 
133     * <EMBED CLASS='external-html' DATA-F=VERSION_MINOR_NUMBER DATA-FILE-ID=DIRECT_COPY>
134     * @see #VERSION_MAJOR_NUMBER
135     * @see Config#VERSION_MINOR_NUMBER
136     */
137    public final byte VERSION_MINOR_NUMBER;
138
139    /**
140     * This must contain the direct path from the current working directory to the {@code 'javac'}
141     * binary-file.  This {@code String}-Configuration names the executable used by Build-Stage 1.
142     * 
143     * <BR /><BR /><B CLASS=JDDescLabel>Validity-Checking:</B>
144     * 
145     * <BR />This parameter is not checked for validity, but the Java-Compiler Build-Stage Class,
146     * {@link S01_JavaCompiler}, will throw exceptions if this {@code String} doesn't point to a
147     * valid binary or executable file.
148     * 
149     * <EMBED CLASS=defs DATA-F=JAVAC_BIN>
150     * <EMBED CLASS='external-html' DATA-FILE-ID=VALIDITY_NULL>
151     * <EMBED CLASS='external-html' DATA-FILE-ID=DIRECT_COPY>
152     * @see Config#JAVAC_BIN
153     * @see S01_JavaCompiler
154     */
155    public final String JAVAC_BIN;
156
157    /**
158     * This must contain the direct path from the current working directory to the
159     * {@code 'javadoc'} binary-file.  This {@code String}-Configuration names the executable used
160     * by Build-Stage 1.
161     * 
162     * <BR /><BR /><B CLASS=JDDescLabel>Validity-Checking:</B>
163     * 
164     * <BR />This parameter is not checked for validity, but the Javadoc Build-Stage Class,
165     * {@link S02_JavaDoc}, will throw exceptions if this {@code String} doesn't point to a valid
166     * binary or executable file.
167     * 
168     * <EMBED CLASS=defs DATA-F=JAVADOC_BIN>
169     * <EMBED CLASS='external-html' DATA-FILE-ID=VALIDITY_NULL>
170     * <EMBED CLASS='external-html' DATA-FILE-ID=DIRECT_COPY>
171     * @see Config#JAVADOC_BIN
172     * @see S02_JavaDoc
173     */
174    public final String JAVADOC_BIN;
175
176    /**
177     * This Configuration-Field may be used to request that the Build-Tool insert the
178     * {@code 'javac'} Command-Line Switch {@code '--release XX'} to the {@code 'javac'} Command
179     * Invocation.  The release switch asks that the Java-Compiler generate Java Byte-Code that is
180     * that is consistent with the Byte-Code for the JDK-Release {@code 'X'}.
181     * 
182     * <BR /><BR />If {@code 'X'} were passed {@code '11'}, the Java-Compiler would generate Java
183     * Byte-Code that is consistent with the JDK-11 LTS (Released in Year 2018).
184     * 
185     * <BR /><BR />This parameter is not checked for validity, but the Java-Compiler will generate 
186     * error messages (instead of compiling) if the Release-Number isn't valid.  If you are using 
187     * JDK-11, and pass {@code '21'} to this Configuration-Field, {@code 'javac'} will obviously
188     * complain.
189     * 
190     * <BR /><BR />The default value for this field is {@code '-1'}.  Any negative number (or zero)
191     * assigned to this field will implicitly tell the Stage 1 Builder-Class that using a
192     * {@code '--release'} switch is not necessary, and should be left off when compiling
193     * {@code '.java'} Files.
194     * 
195     * <EMBED CLASS=defs DATA-F=JAVA_RELEASE_NUM_SWITCH>
196     * <EMBED CLASS='external-html' DATA-FILE-ID=DIRECT_COPY>
197     * @see Config#JAVA_RELEASE_NUM_SWITCH
198     * @see S01_JavaCompiler
199     */
200    public final byte JAVA_RELEASE_NUM_SWITCH;
201
202    /**
203     * Currently this is an unused Configuration-Field.  It is not checked for validity.
204     * When this class is constructed, this field is automatically assigned to the value of the 
205     * field {@link Config#JAVADOC_VER}.
206     * 
207     * @see Config#JAVADOC_VER
208     * @see S02_JavaDoc
209     */
210    public final byte JAVADOC_VER;
211
212    /**
213     * Contains {@code FAVICON} Image File-Name, to be used by the Stage 3 Build-Class 
214     * {@link S03_Upgrade}.  When this Configuration-Field is non-null, the Upgrade-Stage will copy
215     * favicon file into the {@link #LOCAL_JAVADOC_DIR}.
216     * 
217     * <BR /><BR />This Configuration-Field may be null - <I>which is the default value assigned to
218     * {@link Config#FAVICON}</I>.  When it is, no favicon file is copied to the root
219     * {@code 'javadoc/'} directory.
220     * 
221     * <BR /><BR /><B CLASS=JDDescLabel>Validity-Checking:</B>
222     * 
223     * <BR />This {@code String}-Field, when non-null, is checked whether or not it points to an
224     * actual Image-File, that both exists and is accessible on the File-System.  Class
225     * {@link Config Config's} {@link Config#validate() validate} method will throw a 
226     * {@code FileNotFoundException} if this check fails.
227     * 
228     * <BR /><BR />If class {@link Torello.HTML.Tools.Images.IF#guessOrThrow(String) IF} is unable
229     * to properly guess the Image-Type based on its File-Name, then an
230     * {@link UnrecognizedImageExtException} is thrown by the validator method.
231     * 
232     * <EMBED CLASS=defs DATA-F=FAVICON>
233     * <EMBED CLASS='external-html' DATA-FILE-ID=DIRECT_COPY>
234     * @see Config#FAVICON
235     * @see S03_Upgrade
236     */
237    public final String FAVICON;
238
239    /**
240     * This class specifies the Root Source-Code Directory containing all {@code '.java'}
241     * Files, {@code '.class'} Files, and any configurations needed for the build.  The 
242     * Stage 4 Builder-Class {@link S04_TarJar} invokes the OS Command {@code 'tar'} around this
243     * directory to create a Project Backup-File.
244     * 
245     * <BR /><BR />The name given the Project Tar-Backup File will just be the {@code String}
246     * provided to {@link #PROJECT_NAME}, followed by the {@link #VERSION_MAJOR_NUMBER} and 
247     * {@link #VERSION_MINOR_NUMBER}.
248     * 
249     * <BR /><BR /><B CLASS=JDDescLabel>Validity-Checking:</B>
250     * 
251     * <BR />This {@code String}-Field may not be null, or {@code NullPointerException} throws.
252     * Furthermore the {@code Config} {@link Config#validate() validate} method will ensure that
253     * this {@code String} points to a valid and accessible File-System Directory-Name.
254     * 
255     * <BR /><BR />If this isn't a valid directory, a {@code FileNotFoundException} will throw.
256     * Keep in mind that {@code FileNotFoundException} is a Java Checked-Exception which inherits
257     * {@code IOException}.
258     * 
259     * <BR /><BR /><B CLASS=JDDescLabel>Configuration-Field Use:</B>
260     * 
261     * <BR />This field is very simply used in the Stage 4 Build-Class {@link S04_TarJar} as
262     * follows.  The following code snippet was copied on March 4th, 2024:
263     * 
264     * <BR /><DIV CLASS=SNIP>{@code 
265     * // Shell-Constructor Parameters used:
266     * // (outputAppendable, commandStrAppendable, standardOutput, errorOutput)
267     * 
268     * Shell shell = new Shell(SB_TAR, new BiAppendable(SB_TAR, System.out), null, null);
269     * 
270     * // JavaHTML-1.x.tar.gz
271     * CHECK(
272     *     shell.COMMAND(
273     *         "tar",
274     *         new String[] { "-cvzf", builder.TAR_FILE, builder.TAR_SOURCE_DIR }
275     * ));
276     * }</DIV>
277     * 
278     * <EMBED CLASS=defs DATA-F=TAR_SOURCE_DIR>
279     * <EMBED CLASS='external-html' DATA-FILE-ID=DIRECT_COPY>
280     * @see Config#TAR_SOURCE_DIR
281     * @see #TAR_FILE
282     * @see S04_TarJar
283     * @see S06_SyncTarJar
284     */
285    public final String TAR_SOURCE_DIR;
286
287    /**
288     * This parameter is used by all four Build-Stages that involve Google Cloud Server / Platform.
289     * This parameter may, indeed, remain null and if or when it is, Build-Stages that pertain to
290     * GCS Storage-Buckets will not be performed.  These stages include 5 through 8.
291     * 
292     * <BR /><BR />This Configuration-Field is not checked for Validity.  If it is non-null, but
293     * points to / indicates a Google Storage Bucket that isn't valid or isn't writeable, any and 
294     * all GCP Synchronization Stages will throw exceptions and exit.
295     * 
296     * <BR /><BR />By default, this field is assigned null.
297     * 
298     * <BR /><BR /><B CLASS=JDDescLabel>Amazon S3 &amp; MSFT Azure Storage:</B>
299     * 
300     * <BR />There is currently no Build-Implementation that can capably synchronize the Build 
301     * Java-Doc or Archive-File output with {@code 'Amazon S3'}.  {@code 'S3'} is simply AWS'
302     * implementation of Network Based Storage, just like GCP Storage.
303     * 
304     * <BR /><BR />The concept is, certainly, on the "To Do" List, but will not be implemented in
305     * the immediate future.
306     * 
307     * <EMBED CLASS=defs DATA-F=GCS_DIR_DEV>
308     * <EMBED CLASS='external-html' DATA-FILE-ID=DIRECT_COPY>
309     * @see Config#GCS_DIR_DEV
310     * @see #GCS_DIR_RELEASE
311     * @see Config#GCS_DIR_RELEASE
312     * @see S05_SyncJavaDoc
313     * @see S06_SyncTarJar
314     * @see S07_SyncLogs
315     */
316    public final String GCS_DIR_DEV;
317
318    /**
319     * This Configuration Field is nearly identical in function to {@link #GCS_DIR_DEV}, but 
320     * specifies a Storage-Bucket &amp; Directory Location for a "Full Release Version" of the same
321     * Project's Documentation-HTML &amp; Jar-Files.
322     * 
323     * <BR /><BR />This Configuration-Field, by default is assigned null, and may remain null at 
324     * the time that a {@code Builder}-Class instance is constructed.  When this configuration is
325     * null, it is silently ignored.  If null, the Upgrade Cloud Storage-Bucket Synchronization
326     * Stage for the Release-Directory isn't applied, and becomes "unavailable".
327     * 
328     * <BR /><BR />In this project, <B>Java-HTML</B>, the "Full-Release" Storage-Bucket &amp;
329     * Web-Address URL ({@link #GCS_DIR_RELEASE}) is {@code 'javahtml.torello.directory'}.
330     * 
331     * <BR /><BR />The Developer Storage-Bucket Web-Address ({@link #GCS_DIR_DEV}) is
332     * {@code 'developer.torello.directory/JavaHTML/Version'} (followed by the Major &amp; Minor
333     * Version Release Numbers).
334     * 
335     * <BR /><BR />Having two separate output bucket-directories for copying the Java-Doc Output 
336     * and Jar-Distribution allows for having a separate URL for daily Project Software
337     * Development, and a GCS directory which is updated less frequently for released, CI/CD
338     * Distribution.
339     * 
340     * <EMBED CLASS=defs DATA-F=GCS_DIR_RELEASE>
341     * <EMBED CLASS='external-html' DATA-FILE-ID=DIRECT_COPY>
342     * @see Config#GCS_DIR_RELEASE
343     * @see #GCS_DIR_DEV
344     * @see Config#GCS_DIR_DEV
345     * @see S05_SyncJavaDoc
346     * @see S06_SyncTarJar
347     * @see S07_SyncLogs
348     */
349    public final String GCS_DIR_RELEASE;
350
351    /**
352     * When using GCP Storage-Buckets for hosting / serving Web &amp; HTTP Content, Google provides
353     * an option to assign "Bucket-Level" or "Object-Level" access permissions.  When an entire
354     * Storage-Bucket has been made public, there is no need to make each HTML-File that resides
355     * inside the bucket public.  However, if "Object-Level" access permissions have been
356     * configured, then each HTML-File also needs to be made public, or Web-Browsers will not be 
357     * able to see the HTML-Files.
358     * 
359     * <BR /><BR />If you have opted for "Bucket-Level" permissions (everything in your bucket is
360     * publicly readable), then calling {@link GSUTIL} function
361     * {@link GSUTIL#MP(Iterable, String...) Make Public} will actually cause this builder to throw
362     * an exception.  Therefore this boolean should be used to inform the builder whether or not
363     * the javadoc HTML Files are already public, as per the GCP Storage-Bucket settings.
364     * 
365     * <BR /><BR />The Storage-Bucket directory to which the "Make Public" operations are precisely
366     * the directories listed in {@link #GCS_DIR_DEV} and {@link #GCS_DIR_RELEASE}.  As per the
367     * User's selected target-build CLI Option, Java-Doc HTML-Files are copied to only one of these
368     * two bucket directories.
369     * 
370     * <BR /><BR /><B CLASS=JDDescLabel>Assigning this Field:</B>
371     * 
372     * <BR />This is how the value for this field is computed:
373     * 
374     * <DIV CLASS=SNIP>{@code
375     * this.RUN_MAKE_PUBLIC = this.cli.toReleaseOrDeveloper
376     *     ? config.RUN_MAKE_PUBLIC_RELEASE
377     *     : config.RUN_MAKE_PUBLIC_DEV;
378     * }</DIV>
379     * 
380     * @see Config#RUN_MAKE_PUBLIC_DEV
381     * @see Config#RUN_MAKE_PUBLIC_RELEASE
382     * @see #GCS_DIR_DEV
383     * @see #GCS_DIR_RELEASE
384     */
385    public final boolean RUN_MAKE_PUBLIC;
386
387    /**
388     * This Project {@code '.tar'} File that is created out of the Project Root Directory can be
389     * automatically copied to a safe location in a Storage-Bucket so that Project-Files are 
390     * automatically backed up every time they are compiled and documented.
391     * 
392     * <BR /><BR />This Configuration-Field should contain the name of a valid Google Cloud Storage
393     * Bucket Directory-Name.  When this field is non-null, Build-Stage 6 ({@link S06_SyncTarJar})
394     * will automatically copy the Project-Backup {@code '.tar'} File to the directory structure
395     * indicated by this field.
396     * 
397     * <BR /><BR />Note, first, that this field may be null.  If it is null, then the Stage 6
398     * Synchronization Effort to backup the Project-Files will simply be skipped.
399     * 
400     * <BR /><BR />Also, note that the file is actually copied to a sub-directory whose name is 
401     * created using today's date - the Year, Month &amp; Day - of the running / execution of the 
402     * Build Command.
403     * 
404     * <BR /><BR />This field <I>is not checked for validity</I>.  If a non-null but erroneous
405     * Google Cloud Storage-Bucket Directory-Name is provided (or one that exists, but is not 
406     * writeable) - then the Tar-Synchronization Build-Stage (Stage 6) will fail and throw an
407     * exception.
408     * 
409     * <BR /><BR /><B CLASS=JDDescLabel>Visibility:</B>
410     * 
411     * <BR />If this feature is used, it's usually a good idea to make sure that the directory 
412     * provided to this field is <B STYLE='color: red;'><I>not publicly visible to
413     * <CODE>'AllUsers'</CODE></I></B> - otherwise everybody will be capable of downloading the
414     * entirety of your development work.
415     * 
416     * <BR /><BR /><B CLASS=JDDescLabel>Full-Path Directory-Name:</B>
417     * 
418     * <BR />Also, as mentioned above, the backup mechanism actually copies the archive to  a
419     * subdirectory of the form:
420     * 
421     * <BR /><BR /><SPAN CLASS=JDFileDirName>
422     * gs://Some.GCP.Bucket/BACKUP_TAR_FILE_GCS_DIR/2024/03 - March/2024-03-05-JavaHTML-1.8.tar.gz
423     * </SPAN>
424     * 
425     * <BR />Notice that only the date is included in the file-name.  The actual system-time for
426     * this  file is not included!  This means that no more than one backup-file (the last file
427     * created  on any given Calendar-Day) will actually remain in the directory.  A file backed up
428     * at 3:00 PM will be overwritten if another backup is copied at 5:00 PM on the same day.
429     * 
430     * <BR /><BR />This has turned out to be extremely valuable - as it has meant that all changes
431     * made over the course of a single day's work (&amp; typing) are saved - <I>while intermediate
432     * modifications are clobbered / overwritten whenever another Build is executed - on the same 
433     * work-day as the previously executed build</I>.
434     * 
435     * <BR /><BR /><B CLASS=JDDescLabel>Configuration-Field Use:</B>
436     * 
437     * <BR />The Stage 6 Builder-Class {@link S06_SyncTarJar} utilizes this field as follows:
438     * 
439     * <BR /><DIV CLASS=SNIP>{@code
440     * final String CODE_DRIVE_BACKUP_FILE = (builder.BACKUP_TAR_FILE_GCS_DIR == null)
441     * 
442     *     ? null 
443     *     :   builder.BACKUP_TAR_FILE_GCS_DIR +
444     *         StringParse.ymDateStr('/', true) + '/' +
445     *         StringParse.dateStr('-') + '-' + builder.TAR_FILE;
446     * 
447     * // Portion of Code Block Omitted
448     * 
449     * // Drive backup page
450     * if (CODE_DRIVE_BACKUP_FILE != null)
451     * {
452     *     osr = gsutil.CP(builder.TAR_FILE, CODE_DRIVE_BACKUP_FILE);
453     *     Util.HALT_ON_ERROR(osr);
454     *     sw.println();
455     * }
456     * }</DIV>
457     * 
458     * <BR /><BR />For a better understanding, please see:
459     * 
460     * <BR /><BR /><UL CLASS=JDUL>
461     * <LI><B>{@link StringParse#ymDateStr(char, boolean)}</B></LI>
462     * <LI><B>{@link StringParse#dateStr(char)}</B></LI>
463     * <LI><B>{@link GSUTIL#CP(String, String, String[])}</B></LI>
464     * <LI><B>{@link Util#HALT_ON_ERROR(OSResponse)}</B></LI>
465     * </UL>
466     * 
467     * <EMBED CLASS=defs DATA-F=BACKUP_TAR_FILE_GCS_DIR>
468     * <EMBED CLASS='external-html' DATA-FILE-ID=DIRECT_COPY>
469     * @see Config#BACKUP_TAR_FILE_GCS_DIR
470     * @see S06_SyncTarJar
471     */
472    public final String BACKUP_TAR_FILE_GCS_DIR;
473
474    /**
475     * In Java-HTML there are a few Upgrade-Stage (Stage 3) processes that need to be executed 
476     * before the actual {@link Upgrade#upgrade() upgrade} can run.  All of the processes currently
477     * in the {@code 'preUpgraderScript'} are on a general "To Do List" for being moved into the 
478     * actual Upgrade-API.
479     * 
480     * <BR /><BR />This Configuration-Field may be null, and if it is, it is ignored.  The Stage 3
481     * Build-Class {@link S03_Upgrade} simply runs the following code, below.  This snippet was
482     * block-copied directly from {@code 'S03_Upgrade.upgrade'}.
483     * 
484     * <BR /><DIV CLASS=SNIP>{@code
485     * builder.timers.startStage03();
486     * 
487     * Printing.startStep(3);
488     * 
489     * // This is used as a Log-File Collector
490     * StringBuilder sb = new StringBuilder();
491     * 
492     * // Check if there is a User-Provided "Pre-Upgrade Script", if so, then run it.
493     * if (builder.preUpgraderScript != null) builder.preUpgraderScript.accept(builder, sb);
494     * 
495     * sb.append("... Note to Console about Starting Build ...");
496     * 
497     * // And now start the actual Upgrade
498     * Stats result = builder.upgrader.upgrade(); 
499     * }</DIV>
500     * 
501     * <BR /><BR />Clearly, a validity check on this Configuration-Field isn't possible.
502     * 
503     * <EMBED CLASS=defs DATA-F=preUpgraderScript>
504     * <EMBED CLASS='external-html' DATA-FILE-ID=DIRECT_COPY>
505     * @see Config#preUpgraderScript
506     * @see #postUpgraderScript
507     * @see Config#postUpgraderScript
508     * @see S03_Upgrade
509     */
510    public final UpgradeProcessor preUpgraderScript;
511
512    /**
513     * This functions identically to the {@link #preUpgraderScript}, but is executed immediately
514     * after Class {@link S03_Upgrade} has run to completion.
515     * 
516     * <BR /><BR />This field may be null, and if it is it will be silently ignored.  No validity
517     * checks are executed for this Configuration-Field.
518     * 
519     * <EMBED CLASS=defs DATA-F=postUpgraderScript>
520     * <EMBED CLASS='external-html' DATA-FILE-ID=DIRECT_COPY>
521     * @see Config#postUpgraderScript
522     * @see #preUpgraderScript
523     * @see Config#preUpgraderScript
524     * @see S03_Upgrade
525     */
526    public final UpgradeProcessor postUpgraderScript;
527
528
529
530
531    // ********************************************************************************************
532    // ********************************************************************************************
533    // ********************************************************************************************
534    // ********************************************************************************************
535    // Fields - Composite stuff & Modified Stuff
536    // ********************************************************************************************
537    // ********************************************************************************************
538    // ********************************************************************************************
539    // ********************************************************************************************
540
541
542
543
544    /**
545     * Setting values for this {@code String[]}-Array allows a user to provide extra or additional
546     * Command-Line switches to the Java-Compiler if it is invoked.
547     * 
548     * <BR /><BR /><B CLASS=JDDescLabel>Validity Checking:</B>
549     * 
550     * <BR />No validity checks are done for the contents of these {@code 'javac'} "Extra
551     * Switches".  However, if any faulty or erroneous switch elements in the User-Provided
552     * {@code String[]}-Array are provided, then the Stage 1 Build-Class {@link S01_JavaCompiler}
553     * will likely through exceptions when if it is invoked.
554     * 
555     * <BR /><BR /><B CLASS=JDDescLabel>Copying {@link Config#extraSwitchesJAVAC}:</B>
556     * 
557     * <BR />The following is how this field is copied from the contents of class {@code Config}
558     * (a User-Provided class):
559     * 
560     * <BR /><DIV CLASS=SNIP>{@code
561     * // Config.extraSwitchesJAVAC     ==> String[]
562     * // Builder.extraSwitchesJAVAC    ==> ReadOnlyList<String>
563     * 
564     * this.extraSwitchesJAVAC =
565     *     ((config.extraSwitchesJAVAC == null) || (config.extraSwitchesJAVAC.length == 0))
566     *          ? null
567     *          : ReadOnlyList.of(config.extraSwitchesJAVAC);
568     * }</DIV>
569     * 
570     * @see Config#extraSwitchesJAVAC
571     * @see ReadOnlyList
572     * @see S01_JavaCompiler
573     */
574    public final ReadOnlyList<String> extraSwitchesJAVAC;
575
576    /**
577     * Setting values for this {@code String[]}-Array allows a user to provide extra or additional
578     * Command-Line switches to the {@code 'javadoc'} Tool if it is invoked.
579     * 
580     * <BR /><BR /><B CLASS=JDDescLabel>Validity Checking:</B>
581     * 
582     * <BR />No validity checks are done for the contents of these {@code 'javadoc'} "Extra
583     * Switches".  However, if any faulty or erroneous switch elements in the User-Provided
584     * {@code String[]}-Array are provided, then the Stage 2 Build-Class {@link S02_JavaDoc}
585     * will likely through exceptions when if it is invoked.
586     * 
587     * <BR /><BR /><B CLASS=JDDescLabel>Copying {@link Config#extraSwitchesJAVADOC}:</B>
588     * 
589     * <BR />The following is how this field is copied from contents of User-Provided class
590     * {@link Config}:
591     * 
592     * <BR /><DIV CLASS=SNIP>{@code
593     * // Config.extraSwitchesJAVADOC     ==> String[]
594     * // Builder.extraSwitchesJAVADOC    ==> ReadOnlyList<String>
595     * 
596     * this.extraSwitchesJAVADOC =
597     *     ((config.extraSwitchesJAVADOC == null) || (config.extraSwitchesJAVADOC.length == 0))
598     *          ? null
599     *          : ReadOnlyList.of(config.extraSwitchesJAVADOC);
600     * }</DIV>
601     * 
602     * @see Config#extraSwitchesJAVADOC
603     * @see ReadOnlyList
604     * @see S02_JavaDoc
605     */
606    public final ReadOnlyList<String> extraSwitchesJAVADOC;
607
608    /**
609     * This is the {@link Upgrade} instance that was passed to the class {@link Config} Field
610     * {@link Config#upgrader}.
611     * 
612     * @see Config#upgrader
613     * @see S03_Upgrade
614     */
615    public final Upgrade upgrader;
616
617    /**
618     * The Computed File-Name for the Project-Wide {@code '.tar'} Backup-File.
619     * 
620     * <BR /><BR />This Configuration-Field is computed using other fields, and cannot be
621     * "supplied" by the User.  Below is the code used to generate this File-Name / Field.
622     * 
623     * <BR /><DIV CLASS=SNIP>{@code
624     * // For Java-HTML, this would be, (for example) - "1.8"
625     * final String NUM = VERSION_MAJOR_NUMBER + "." + VERSION_MINOR_NUMBER;
626     * 
627     * // For Project "JavaHTML", this would be "JavaHTML-1.8.tar.gz"
628     * this.TAR_FILE = this.PROJECT_NAME + "-" + NUM + ".tar.gz";
629     * }</DIV>
630     * 
631     * @see #PROJECT_NAME
632     * @see #VERSION_MAJOR_NUMBER
633     * @see #VERSION_MINOR_NUMBER
634     * @see S04_TarJar
635     * @see S06_SyncTarJar
636     */
637    public final String TAR_FILE;
638
639    /**
640     * The Computed File-Name for the Project's Distribution {@code '.jar'} File.
641     * 
642     * <BR /><BR />This Configuration-Field is computed using other fields, and cannot be
643     * "supplied" by the User.  Below is the code used to generate this File-Name / Field.
644     * 
645     * <BR /><DIV CLASS=SNIP>{@code
646     * // For Java-HTML, this would be, (for example) - "1.8"
647     * final String NUM = VERSION_MAJOR_NUMBER + "." + VERSION_MINOR_NUMBER;
648     * 
649     * // For Project "JavaHTML", this would be "JavaHTML-1.8.jar"
650     * this.JAR_FILE = this.PROJECT_NAME + "-" + NUM + ".jar";
651     * }</DIV>
652     * 
653     * @see #PROJECT_NAME
654     * @see #VERSION_MAJOR_NUMBER
655     * @see #VERSION_MINOR_NUMBER
656     * @see S04_TarJar
657     * @see S06_SyncTarJar
658     */
659    public final String JAR_FILE;
660
661    /**
662     * The Computed File-Name for the Project's Javadoc Documentation {@code '.tar.gz'} File.
663     * 
664     * <BR /><BR />This Configuration-Field is computed using other fields, and cannot be
665     * "supplied" by the User.  Below is the code used to generate this File-Name / Field.
666     * 
667     * <BR /><DIV CLASS=SNIP>{@code
668     * // For Java-HTML, this would be, (for example) - "1.8"
669     * final String NUM = VERSION_MAJOR_NUMBER + "." + VERSION_MINOR_NUMBER;
670     * 
671     * // For Project "JavaHTML", this would be "JavaHTML-javadoc-1.8.tar"
672     * this.JAVADOC_TAR_FILE = this.PROJECT_NAME + "-javadoc-" + NUM + ".tar";
673     * }</DIV>
674     * 
675     * @see #PROJECT_NAME
676     * @see #VERSION_MAJOR_NUMBER
677     * @see #VERSION_MINOR_NUMBER
678     * @see S04_TarJar
679     * @see S06_SyncTarJar
680     */
681    public final String JAVADOC_TAR_FILE;
682
683    /**
684     * This is an auto-generated field, that utilizes the {@link Config}-Class Field
685     * {@link Config#JAR_FILE_MOVE_DIR}.  When this field is non-null, the {@code '.jar'} File that
686     * is generated by the Stage 4 Build-Class {@link S04_TarJar} is copied to the directory
687     * specified.
688     * 
689     * <BR /><DIV CLASS=SNIP>{@code
690     * this.JAR_FILE_NAME = (config.JAR_FILE_MOVE_DIR != null)
691     *     ? (config.JAR_FILE_MOVE_DIR + this.PROJECT_NAME + ".jar")
692     *     : null;
693     * }</DIV>
694     * 
695     * @see Config#JAR_FILE_MOVE_DIR
696     * @see S04_TarJar
697     * @see S06_SyncTarJar
698     */
699    public final String JAR_FILE_NAME;
700
701    /**
702     * This is the classpath that is passed to the Stage 1 Build-Class {@link S01_JavaCompiler}.
703     * 
704     * <BR /><BR />This field's value is computed and assigned by a package-only visible
705     * initializer method in class {@link Config}.
706     * 
707     * @see S01_JavaCompiler
708     */
709    public final String CLASS_PATH_STR;
710
711    /**
712     * The helps the Build-Logic decide whether to use the Java-Compiler Switch {@code -Xlint:all}.
713     * The default behavior is that the Java-Compiler will be invoked using that switch for all
714     * {@code '.java'} Files that are being compiled.
715     * 
716     * <BR /><BR />The default behavior assigned in Configuration-Class {@link Config} can easily
717     * be changed by reassigning the necessary value to field {@link Config#USE_XLINT_SWITCH}. When
718     * this field is reassiged a new {@code boolean}, any invocation of the {@code Builder}'s 
719     * Java-Compiler Stage will check whether to use the {@code -Xlint:all}, based on this field's
720     * value.
721     * 
722     * <BR /><BR />On top of {@code Config.USE_XLINT_SWITCH}, a user has the option of passing the
723     * Command-Line Wwitch {@code -TXL} when invoking the Java-Compiler Build-Stage which, in
724     * effect, toggles whatever value was set by the original {@link Config#USE_XLINT_SWITCH}
725     * setting.  (This may be done when invoking {@code 'Builder'} from the CLI).
726     * 
727     * <BR /><BR />This may be more clearly seen in the code used to assign this field's value:
728     * 
729     * <BR /><DIV CLASS=SNIP>{@code
730     * this.USE_XLINT_SWITCH = this.cli.OVERRIDE_TOGGLE_USE_XLINT_SWITCH
731     *     ? (! config.USE_XLINT_SWITCH)
732     *     : config.USE_XLINT_SWITCH;
733     * }</DIV>
734     * 
735     * @see Config#USE_XLINT_SWITCH
736     * @see CLI#OVERRIDE_TOGGLE_USE_XLINT_SWITCH
737     * @see S01_JavaCompiler
738     */
739    public final boolean USE_XLINT_SWITCH;
740
741    /**
742     * The helps the Build-Logic decide whether to use the Java-Compiler Switch
743     * {@code -Xdiags:verbose}.  The default behavior is that the Java-Compiler will be invoked
744     * using that switch for all {@code '.java'} Files that are being compiled.
745     * 
746     * <BR /><BR />The default behavior assigned in Configuration-Class {@link Config} can easily
747     * be changed by reassigning the necessary value to field {@link Config#USE_XDIAGS_SWITCH}.
748     * When this field is reassiged a new {@code boolean}, any invocation of the {@code Builder}'s
749     * Java-Compiler Stage will check whether to use the {@code -Xdiags:verbose}, based on this
750     * field's value.
751     * 
752     * <BR /><BR />On top of {@code Config.USE_XDIAGS_SWITCH}, a user has the option of passing the
753     * Command-Line Wwitch {@code -TXL} when invoking the Java-Compiler Build-Stage which, in
754     * effect, toggles whatever value was set by the original {@link Config#USE_XDIAGS_SWITCH}
755     * setting.  (This may be done when invoking {@code 'Builder'} from the CLI).
756     * 
757     * <BR /><BR />This may be more clearly seen in the code used to assign this field's value:
758     * 
759     * <BR /><DIV CLASS=SNIP>{@code
760     * this.USE_XDIAGS_SWITCH = this.cli.OVERRIDE_TOGGLE_USE_XDIAGS_SWITCH
761     *     ? (! config.USE_XDIAGS_SWITCH)
762     *     : config.USE_XDIAGS_SWITCH;
763     * }</DIV>
764     * 
765     * @see Config#USE_XDIAGS_SWITCH
766     * @see CLI#OVERRIDE_TOGGLE_USE_XDIAGS_SWITCH
767     * @see S01_JavaCompiler
768     */
769    public final boolean USE_XDIAGS_SWITCH;
770
771    /**
772     * Requests that the {@code --frames} switch, which by default is passed to the Stage 2
773     * Build-Class {@link S02_JavaDoc} be omitted.
774     * 
775     * <BR /><BR />By default, this Configuration-Field is assigned {@code FALSE}, which means that
776     * the {@code --frames} switch, <I>by default, s passed to the {@code javadoc} stage</I>.
777     * 
778     * <BR /><BR />Make sure to remember that after the JDK 11 Release, the {@code --frames} switch
779     * was fully deprecated and removed from the tool.  In such cases, make sure to assign
780     * {@code TRUE} to the field {@link Config#NO_JAVADOC_FRAMES_SWITCH}, or the Stage 2
781     * Build-Class will throw an exception.
782     * 
783     * <EMBED CLASS=defs DATA-F=NO_JAVADOC_FRAMES_SWITCH>
784     * <EMBED CLASS='external-html' DATA-FILE-ID=DIRECT_COPY>
785     * @see Config#NO_JAVADOC_FRAMES_SWITCH
786     * @see S02_JavaDoc
787     */
788    public final boolean NO_JAVADOC_FRAMES_SWITCH;
789
790    /**
791     * This Configuration is largely copied, directly, from the User-Provided {@link Config} class
792     * instance received.  This Configuration-Field simply contains the list of packages that 
793     * comprise the Java Project being built, compiled, documented &amp; sychronized.
794     * 
795     * <BR /><BR />Class {@link Config}-Field {@link Config#packageList} contains a User-Provided
796     * list of packages, as instances of {@link BuildPackage}.
797     * 
798     * <BR /><BR />There isn't any validation done on the input array, other than that it must be 
799     * non-null, and contain at least Java Package.
800     * 
801     * <BR /><BR /><B CLASS=JDDescLabel>Quick Build Note:</B>
802     * 
803     * <BR />The option to eliminate certain packages when doing a build is provided by class 
804     * {@link BuildPackage}.  The {@code BuildPackage} Static-Flag
805     * {@link BuildPackage#QUICKER_BUILD_SKIP} lets a user convey that, during development time, 
806     * the compilation and documentation stages can skip certain packages altogether.
807     * 
808     * <BR /><BR />Note that if class {@link CLI} has specified its {@link CLI#QUICKER_BUILD}
809     * field, then and only then, are packages designed as {@link BuildPackage#skipIfQuickerBuild}
810     * actually removed.
811     * 
812     * <BR /><BR /><B CLASS=JDDescLabel>Under Development Note:</B>
813     * 
814     * <BR />The option to eliminate certain packages because they are still under development is 
815     * an option also provided by the class {@link BuildPackage} (via the
816     * {@link BuildPackage#EARLY_DEVELOPMENT EARLY_DEVELOPMENT} flag, and by the
817     * {@link BuildPackage#earlyDevelopment earlyDevelopment} field),
818     * <B STYLE='color: red;'><I>and by the class</I></B> {@link CLI} (via the 
819     * {@link CLI#INCLUDE_EARLY_DEV_PACKAGES INCLUDE_EARLY_DEV_PACKAGES} field).
820     * 
821     * <BR /><BR ><B CLASS=JDDescLabel>Assigning this Field:</B>
822     * 
823     * <BR />This field's reference/value is assigned in this class constructor as in the code
824     * included below.  The value is generated by the class / method:
825     * {@link Packages#packagesInThisBuild(CLI, BuildPackage[]) packagesInThisBuild}.
826     * 
827     * <BR /><DIV CLASS=SNIP>{@code
828     * // This eliminates any packages that are irrelevant, as per the specifications
829     * // by the User at the Command-Line Interface 'argv' parameter.
830     * // 
831     * // The included packages are in:    "Ret2.a"
832     * // The eliminated packages are in:  "Ret2.b"
833     * 
834     * Ret2<ReadOnlyList<BuildPackage>, ReadOnlyList<BuildPackage>> ret2 =
835     *     Packages.packagesInThisBuild(this.cli, config.packageList);
836     * 
837     * // This is used in S01_JavaCompiler, S02_JavaDoc and S04_TarJar
838     * this.packageList = ret2.a;
839     * }</DIV>
840     * 
841     * @see Packages#packagesInThisBuild(CLI, BuildPackage[])
842     * @see Config#packageList
843     * @see CLI#QUICKER_BUILD
844     * @see BuildPackage#QUICKER_BUILD_SKIP
845     * @see BuildPackage#skipIfQuickerBuild
846     */
847    public final ReadOnlyList<BuildPackage> packageList;
848
849    /**
850     * Additional &amp; Miscellaneous Files that must be incorporated into the Project's
851     * {@code '.jar'} File.
852     * 
853     * <BR /><BR />This Configuration-Field's value is computed by using package-private 
854     * initializer code, as follows:
855     * 
856     * <BR /><DIV CLASS=SNIP>{@code
857     * this.jarIncludes = (config.jarIncludes != null)
858     *     ? config.jarIncludes.getAllDesriptors()
859     *     : null;
860     * }</DIV>
861     * 
862     * @see Config#jarIncludes
863     * @see S04_TarJar
864     */
865    public final ReadOnlyList<JarInclude.Descriptor> jarIncludes;
866
867    /**
868     * This is generated by parsing the Command-Line Arguments passed to this class constructor.
869     * 
870     * Class {@link CLI}'s constructor accepts an {@code 'argv'} parameter, which should have been
871     * obtained from an invocation of any {@code public static void main} method.
872     */
873    public final CLI cli;
874
875
876    // These are Package-Private, the user cannot use these.
877    // They are useless outside of this pacage anyway.
878
879    final Logs      logs;
880    final Timers    timers;
881
882    // The new thing - this will be fixed and updated - slowly.
883    // For now, the "default" thing is being instantiated.
884
885    final AbstractCloudSync<?> cloudSync = AbstractGSUTILCloudSync.getImpl();
886
887
888
889    // ********************************************************************************************
890    // ********************************************************************************************
891    // ********************************************************************************************
892    // ********************************************************************************************
893    // Constructor
894    // ********************************************************************************************
895    // ********************************************************************************************
896    // ********************************************************************************************
897    // ********************************************************************************************
898
899
900
901
902    /**
903     * Run this class constructor, and afterwards the {@link #build()} method can be invoked.
904     * 
905     * @param config Any instance of class {@code Config}
906     * 
907     * @param argv Any {@code String[]}-Array instance that has been obtained from any invocation
908     * of a {@code public static void main} method.
909     * 
910     * @throws FileNotFoundException Throw by the class {@link Config}
911     * {@link Config#validate() validate} method if there are problems with the user's provided
912     * configurations.
913     */
914    public Builder(Config config, String... argv) throws FileNotFoundException, IOException
915    {
916        config.validate();
917
918
919        // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
920        // Fields that are directly copied from "Config"
921        // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
922
923        this.HOME_DIR                   = config.HOME_DIR;
924        this.LOCAL_JAVADOC_DIR          = config.LOCAL_JAVADOC_DIR;
925        this.PROJECT_NAME               = config.PROJECT_NAME;
926        this.VERSION_MAJOR_NUMBER       = config.VERSION_MAJOR_NUMBER;
927        this.VERSION_MINOR_NUMBER       = config.VERSION_MINOR_NUMBER;
928        this.JAVAC_BIN                  = config.JAVAC_BIN;
929        this.JAVADOC_BIN                = config.JAVADOC_BIN;
930        this.JAVA_RELEASE_NUM_SWITCH    = config.JAVA_RELEASE_NUM_SWITCH;
931        this.JAVADOC_VER                = config.JAVADOC_VER;
932        this.FAVICON                    = config.FAVICON;
933        this.TAR_SOURCE_DIR             = config.TAR_SOURCE_DIR;
934        this.GCS_DIR_DEV                = config.GCS_DIR_DEV;
935        this.GCS_DIR_RELEASE            = config.GCS_DIR_RELEASE;
936        this.BACKUP_TAR_FILE_GCS_DIR    = config.BACKUP_TAR_FILE_GCS_DIR;
937        this.NO_JAVADOC_FRAMES_SWITCH   = config.NO_JAVADOC_FRAMES_SWITCH;
938        this.preUpgraderScript          = config.preUpgraderScript;
939        this.postUpgraderScript         = config.postUpgraderScript;
940
941
942        // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
943        // Package-Private, Internally-Used Fields (not useful to user)
944        // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
945
946        // These two are declared "Package-Private" - everything else is public
947        this.logs   = new Logs(config.LOG_DIR);
948        this.timers = new Timers();
949
950
951        // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
952        // Slightly Modified, but Copied Fields
953        // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
954
955        this.extraSwitchesJAVAC =
956            ((config.extraSwitchesJAVAC == null) || (config.extraSwitchesJAVAC.length == 0))
957                ? null
958                : ReadOnlyList.of(config.extraSwitchesJAVAC);
959
960        this.extraSwitchesJAVADOC =
961            ((config.extraSwitchesJAVADOC == null) || (config.extraSwitchesJAVADOC.length == 0))
962                ? null
963                : ReadOnlyList.of(config.extraSwitchesJAVADOC);
964
965        this.jarIncludes = (config.jarIncludes != null)
966            ? config.jarIncludes.getAllDesriptors()
967            : null;
968
969
970        // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
971        // Composite / Composed Config-Fields
972        // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
973
974        final String NUM = VERSION_MAJOR_NUMBER + "." + VERSION_MINOR_NUMBER;
975
976        this.TAR_FILE           = this.PROJECT_NAME + "-" + NUM + ".tar.gz";
977        this.JAR_FILE           = this.PROJECT_NAME + "-" + NUM + ".jar";
978        this.JAVADOC_TAR_FILE   = this.PROJECT_NAME + "-javadoc-" + NUM + ".tar";
979
980        this.JAR_FILE_NAME = (config.JAR_FILE_MOVE_DIR != null)
981            ? (config.JAR_FILE_MOVE_DIR + this.PROJECT_NAME + ".jar")
982            : null;
983
984
985        // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
986        // REQUIRES THE COMMAND-LINE / CLI (this.cli) INPUT-DATA TO ASSIGN THESE FIELDS
987        // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
988
989        // This is public, and it is needed by the next two fields, so it's constructed before them
990        this.cli = new CLI(config.GCS_DIR_DEV, config.GCS_DIR_RELEASE, config.packageList, argv);
991
992        this.RUN_MAKE_PUBLIC = this.cli.toReleaseOrDeveloper
993            ? config.RUN_MAKE_PUBLIC_RELEASE
994            : config.RUN_MAKE_PUBLIC_DEV;
995
996        this.CLASS_PATH_STR = config.classPathStr(this.cli.INCLUDE_JAR_IN_CP, this.JAR_FILE_NAME);
997
998        this.USE_XLINT_SWITCH = this.cli.OVERRIDE_TOGGLE_USE_XLINT_SWITCH
999            ? (! config.USE_XLINT_SWITCH)
1000            : config.USE_XLINT_SWITCH;
1001
1002        this.USE_XDIAGS_SWITCH = this.cli.OVERRIDE_TOGGLE_USE_XDIAGS_SWITCH
1003            ? (! config.USE_XDIAGS_SWITCH)
1004            : config.USE_XDIAGS_SWITCH;
1005
1006
1007        // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
1008        // Class Upgrade Itself
1009        // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
1010
1011        final Upgrade tempUpgrader =
1012            config.upgrader.setLogFile(config.LOG_DIR + Logs.S03_UPGRADER);
1013
1014        this.upgrader = (this.cli.userSpecifiedPackages == null)
1015            ? tempUpgrader 
1016            : tempUpgrader.setPackageList(this.cli.userSpecifiedPackages);
1017
1018
1019        // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
1020        // Build Package List
1021        // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
1022        // 
1023        // This eliminates any packages that are irrelevant, as per the specifications
1024        // by the User at the Command-Line Interface 'argv' parameter.
1025        // 
1026        // The included packages are in:    "Ret2.a"
1027        // The eliminated packages are in:  "Ret2.b"
1028
1029        Ret2<ReadOnlyList<BuildPackage>, ReadOnlyList<BuildPackage>> ret2 =
1030            Packages.packagesInThisBuild(this.cli, config.packageList);
1031
1032        // This is used in S01_JavaCompiler, S02_JavaDoc and S04_TarJar
1033        this.packageList = ret2.a;
1034
1035        // The JavaDoc Upgrader will use this "Eliminated List" in the class
1036        // GenerateOverviewFrame
1037
1038        Torello.JavaDoc.EXPORT_PORTAL.Upgrade$registerEliminatedBuildPackages
1039            (this.upgrader, ret2.b);
1040
1041        // I thought this wasn't allowed?!?!  Oh well...  I'm not going to argue about this at the
1042        // moment.  Since 'this' isn't fully initialized yet, why is it letting me pass this as a
1043        // parameter??  was there ever a rule against passing 'this' inside of a constructor?
1044
1045        this.cloudSync.registerBuilder(this);
1046    }
1047
1048
1049
1050
1051    // ********************************************************************************************
1052    // ********************************************************************************************
1053    // ********************************************************************************************
1054    // ********************************************************************************************
1055    // Build "Main" Method
1056    // ********************************************************************************************
1057    // ********************************************************************************************
1058    // ********************************************************************************************
1059    // ********************************************************************************************
1060
1061
1062
1063
1064    /**
1065     * Runs the build.  Uses all configurations that were passed to this class constructor.
1066     * @throws IOException There are many, many wonderful opportunities for this exception to throw
1067     */
1068    public void build() throws IOException
1069    {
1070        // Timers.start[0] is how the "Total Timer Count" is computed.  So 'touch it', and things
1071        // can start counting right from here.
1072
1073        this.timers.touch();
1074
1075        // Pushing it out to JavaHTML shouldn't happen all the time, only once in a while
1076        if (this.cli.toReleaseOrDeveloper) if (! Q.YN("Are You Sure?")) System.exit(0);
1077
1078        switch (cli.MENU_CHOICE)
1079        {
1080            // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
1081            // COMPILER STEP
1082            // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
1083
1084            case "1"    :   S01_JavaCompiler.compile(this);
1085                            break;
1086
1087
1088            // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
1089            // MAIN STEPS
1090            // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
1091
1092            case "2"    :   S02_JavaDoc.javaDoc(this);      break;
1093            case "3"    :   S03_Upgrade.upgrade(this);      break;
1094            case "4"    :   S04_TarJar.compress(this);      break;
1095            case "5"    :   S05_SyncJavaDoc.sync(this);     break;
1096            case "6"    :   S06_SyncTarJar.sync(this);      break;
1097            case "7"    :   S07_SyncLogs.sync(this);        break;
1098            case "8"    :   S08_SetMaxAge.set(this);        break;
1099
1100
1101            // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
1102            // COMPOSITE STEPS - Complete Build's  (composed from the 8 steps above)
1103            // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
1104
1105            // [Standard Build] - Steps #2 - #7
1106            case "cb1"  :   S02_JavaDoc.javaDoc(this);
1107                            S03_Upgrade.upgrade(this);
1108                            S04_TarJar.compress(this);
1109                            S05_SyncJavaDoc.sync(this);
1110                            S06_SyncTarJar.sync(this);
1111                            S07_SyncLogs.sync(this);
1112                            break;
1113
1114            // [Standard Build, Set Max-Age] - Steps #2 - #8
1115            case "cb2" :    S02_JavaDoc.javaDoc(this);
1116                            S03_Upgrade.upgrade(this);
1117                            S04_TarJar.compress(this);
1118                            S05_SyncJavaDoc.sync(this);
1119                            S06_SyncTarJar.sync(this);
1120                            S07_SyncLogs.sync(this);
1121                            S08_SetMaxAge.set(this);
1122                            break;
1123
1124            // [Standard Build] - Steps #2 - #7
1125            case "cb3" :    S02_JavaDoc.javaDoc(this);
1126                            S03_Upgrade.upgrade(this);
1127                            S04_TarJar.compress(this);
1128                            S05_SyncJavaDoc.sync(this);
1129                            S06_SyncTarJar.sync(this);
1130                            S07_SyncLogs.sync(this);
1131                            break;
1132
1133
1134            // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
1135            // COMPOSITE STEPS - Debug-Build's  (composed from the 8 steps above)
1136            // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
1137
1138            // [Build Only, No GCS Copying] - Steps #2, #3
1139            case "pb1"  :   S02_JavaDoc.javaDoc(this);
1140                            S03_Upgrade.upgrade(this);
1141                            break;
1142
1143            // [Build, Copy Docs Only, Set Max-Age] - Steps #2, #3, #5, #8
1144            case "pb2"  :   S02_JavaDoc.javaDoc(this);
1145                            S03_Upgrade.upgrade(this);
1146                            S05_SyncJavaDoc.syncPart(this);
1147                            S08_SetMaxAge.set(this);
1148                            break;
1149
1150
1151            // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
1152            // Run one of the special cases
1153            // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
1154
1155            // Links-Checker Steps #2, #3
1156            case "lc"   :   if (1 == 1) throw new Torello.Java.ToDoException();
1157                            S02_JavaDoc.javaDoc(this);
1158                            // S03_Upgrade.upgradeWLC(U, ES, OS);
1159                            break;
1160
1161
1162            // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
1163            // DEFAULT - PRINT HELP AND EXIT
1164            // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
1165
1166            default :   throw new UnreachableError();
1167        }
1168
1169        this.timers.PRINT_TIMES();
1170    }
1171}