001package Torello.Java.Build;
002
003import Torello.Java.UnreachableError;
004
005import java.io.IOException;
006
007/**
008 * <EMBED CLASS='external-html' DATA-FILE-ID=RUN_BUILD>
009 * @see BuilderRecord
010 * @see Config
011 */
012@Torello.JavaDoc.StaticFunctional
013public class RunBuild
014{
015    // No need, Static-Functional
016    private RunBuild() { }
017
018    /**
019     * Runs the build.  Accepts ana instance of {@link BuilderRecord} in order to utilize the
020     * configurations needed to actually do a build.
021     * 
022     * @param brec Requires the instance of {@link BuilderRecord} that was generated by class
023     * {@link Config} method {@link Config#createBuilder(String[])}.
024     * 
025     * @throws IOException There are many, many wonderful opportunities for this exception to throw
026     */
027    public static void run(BuilderRecord brec) throws IOException
028    {
029        // Timers.start[0] is how the "Total Timer Count" is computed.  So 'touch it', and things
030        // can start counting right from here.
031
032        brec.timers.touch();
033
034        if (brec.cli.compositeStep_RunStage2to4_OptionSelected)
035        {
036            S02_JavaDoc.javaDoc(brec);
037            S03_Upgrade.upgrade(brec);
038            S04_TarJar.compress(brec);
039        }
040
041        else if (brec.cli.sor.MENU_CHOICE.startsWith("cb"))
042        {
043            S02_JavaDoc.javaDoc(brec);
044            S03_Upgrade.upgrade(brec);
045            S04_TarJar.compress(brec);
046            S05_SyncJavaDoc.sync(brec);
047            S06_SyncTarJar.sync(brec);
048            S07_SyncLogs.sync(brec);
049
050            if (brec.cli.sma_NoBrowserCache_OptionSelected) S08_SetMaxAge.set(brec);
051        }
052
053        else if (brec.cli.sor.MENU_CHOICE.startsWith("pb"))
054        {
055            S02_JavaDoc.javaDoc(brec);
056            S03_Upgrade.upgrade(brec);
057
058            if (brec.cli.partialWithSync_OptionSelected)
059            {
060                // NOTE: If the list, below, is "non-null", it is (I think, 99.9%) guaranteed to be
061                //       "Non-Empty", however, If you erase either of these lines, you are going to
062                //      go back and change the whole thing (again), so just leave it alone, PLEASE.
063
064                boolean packagesWereSpecified = 
065                        (brec.cli.sor.userProvidedNickNames != null)        // Sufficient
066                    &&  (brec.cli.sor.userProvidedNickNames.size() > 0);    // Just to Remember
067
068                if (packagesWereSpecified)  S05_SyncJavaDoc.syncPart(brec);
069                else                        S05_SyncJavaDoc.sync(brec);
070            }
071
072            if (brec.cli.sma_NoBrowserCache_OptionSelected) S08_SetMaxAge.set(brec);
073        }
074
075        else switch (brec.cli.sor.MENU_CHOICE)
076        {
077            case "1"    :   S01_JavaCompiler.compile(brec); break;
078            case "2"    :   S02_JavaDoc.javaDoc(brec);      break;
079            case "3"    :   S03_Upgrade.upgrade(brec);      break;
080            case "4"    :   S04_TarJar.compress(brec);      break;
081            case "5"    :   S05_SyncJavaDoc.sync(brec);     break;
082            case "6"    :   S06_SyncTarJar.sync(brec);      break;
083            case "7"    :   S07_SyncLogs.sync(brec);        break;
084            case "8"    :   S08_SetMaxAge.set(brec);        break;
085
086            // This works great, but has a minor bug which is not going to be fixed until the
087            // CSS Project has completed.  In the mean time there is a very wonderfully worded
088            // "ToDoException" that shall throw instead.
089            // 
090            // Though this is an "invaluable tool" for cleaning up the docs, CSS is an even neater
091            // idea that has to be completed, first.  I have checked my broken links many times,
092            // and all of the links in my core-libraries are working.  Java-Doc Pages that are
093            // created from Torello.Java.Buil (and even Torello.CSS) likely have a broken 
094            // internal link somewhere in them.
095
096            case "lc"   :   if (1 == 1) throw new Torello.Java.ToDoException();
097                            S02_JavaDoc.javaDoc(brec);
098
099                            // I don't even have a 'WLC' method in Stage-03 Upgrade anymore!
100                            // S03_Upgrade.upgradeWLC(U, ES, OS);
101
102                            break;
103
104            default     :   throw new UnreachableError();
105        }
106
107        brec.timers.PRINT_TIMES();
108    }
109}