Class SimpleGCSBuild


  • public class SimpleGCSBuild
    extends java.lang.Object
    This class is similar to a build script, though it more likely resembles an archive and backup script. It does produce Upgraded Java-Doc Pages.



    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method
      static void build​(String rootGCSDir, Appendable a, String... packages)
      protected static void COPY_TAR​(String[] tarCMD, String tarFile, String gcsDir, Appendable a)
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • build

        public static void build​(java.lang.String rootGCSDir,
                                 java.lang.Appendable a,
                                 java.lang.String... packages)
                          throws java.lang.Exception
        This class is intended to be used from the UNIX command line.
        Parameters:
        rootGCSDir - The root directory on the Google Cloud Server Storage Bucket system where the output code-tar and documentation files will be sent.
        a - This is the text-output parameter. This may be null, and if it is, it shall be ignored - and the build will run in silent mode.
        packages - The list of packages that shall be tar'ed and saved.
        Throws:
        java.lang.Exception
        Code:
        Exact Method Body:
         1
         2
         3
         4
         5
         6
         7
         8
         9
        10
        11
        12
        13
        14
        15
        16
        17
        18
        19
        20
        21
        22
        23
        24
        25
        26
        27
        28
        29
        30
        31
        32
        33
        34
        35
        36
        37
        38
        39
        40
        41
        42
        43
        44
        45
        46
        47
        48
        49
         final String dateStr = StringParse.dateStr();
         final String gcsDir  = rootGCSDir + dateStr + '/';
        
         Stream<String> params1, params2;
         String[] cmd;
         Shell.appendable = NOPRINT.np;
         String tarFile = "code-" + dateStr + ".tar";
        
         // ****************************************************************************************
         // The source code directory
         // ****************************************************************************************
         cmd = new String[] { "-cvf", tarFile, "code/MTG/" };
         COPY_TAR(cmd, tarFile, gcsDir, a);
        
         // ****************************************************************************************
         // Java Doc & Upgrader
         // ****************************************************************************************
         Shell.appendable = a;
         Shell.RM("tempjavadoc/", "-r");
        
         String[] arguments =
         {
             "code.MTG", "-d", "tempjavadoc", "-docfilessubdirs", "-linksource", "-docencoding", "UTF-8",
             "-charset", "UTF-8", "--frames", "--allow-script-in-comments", "-sourcetab", "4"
         };
        
         cmd = new String[packages.length + arguments.length];
        
         for (int i=0; i < cmd.length; i++)
             if (i < packages.length)    cmd[i] = packages[i];
             else                        cmd[i] = arguments[i - packages.length];
        
         // ***** Run Java Doc
         Shell.JAVADOC(cmd);
        
         // ***** Run Java Doc Upgrader
         cmd = new String[] { "tempjavadoc/", "cache/" };
         Torello.HTML.Tools.JavaDoc.Upgrade.main(cmd);
        
         // ***** Copy Upgraded Java Doc Files to Google Cloud Server Storage Buckets
         GSUTIL.CP("tempjavadoc/*", gcsDir + "javadoc/", "-r");
         Shell.RM("tempjavadoc/", "-r");
         GSUTIL.MP(gcsDir + "javadoc/**");
        
         System.out.println(
             "\nView Generated Java Doc Documentation Page Here:\n" +
             gcsDir.replace("gs://", "http://") + "javadoc/index.html" +
             "\n"
         );
        
      • COPY_TAR

        protected static void COPY_TAR​(java.lang.String[] tarCMD,
                                       java.lang.String tarFile,
                                       java.lang.String gcsDir,
                                       java.lang.Appendable a)
                                throws java.io.IOException
        Build the '.tar' file archives for the files specified by the parameters in 'cmd'. This file is then transferred to a Google Cloud Server Storage Bucket, and the local copy is deleted.
        Parameters:
        tarCMD - The arguments that should be passed to Shell.TAR(String[]) so that the appropriate files will be archived / tar'ed.
        tarFile - The 'cmd' parameter to this method will have an output filename for the '.tar' that is to be generated here. This parameter 'tarFile' should be identical to the file-name specified in parameter 'cmd'. This filename is needed because this file is transferred to a Google Cloud Platform Storage Bucket.
        gcsDir - The destination for the '.tar' file.
        a - Text output is sent to this appendable. This parameter may be null, and if it is, there will be no text-output printed.
        Throws:
        java.io.IOException
        Code:
        Exact Method Body:
         1
         2
         3
         4
         5
         6
         7
         8
         9
        10
        11
        12
        13
        14
        15
        16
        17
        18
        19
        20
        21
        22
        23
        24
        25
        26
        27
        28
        29
        30
        31
        32
        33
        34
        35
        36
        37
        38
        39
        40
        41
        42
        43
        44
        45
        46
        47
        48
        49
        50
        51
        52
        53
         if (a != null) a.append(
             C.BYELLOW +
             "********************************************************************************" +
             C.RESET + '\n'
         );
        
         // ****************************************************************************************
         // Run TAR Command
         // ****************************************************************************************
         if (a != null) a.append(C.BCYAN + "tar ");
         OSResponse.PRINT_CMD(tarCMD, a);
         if (a != null) a.append(C.RESET);
         OSResponse res = Shell.TAR(tarCMD);
         if (a != null) a.append("Returned Response Code: " + res.response + '\n');
         if ((res.stdErr.length() > 0) || (res.response != 0))
         {
             if (a != null) a.append
                 ("Error Stream: " + C.BRED + res.stdErr + C.RESET + "\nExiting...\n");
             System.exit(0);
         }
         if (a != null) a.append(C.BGREEN + "TAR FILE SUCCESSFULLY BUILT" + C.RESET + '\n');
        
         // ****************************************************************************************
         // Use GSUTIL to copy TAR to Storage Bucket
         // ****************************************************************************************
         res = GSUTIL.CP(tarFile, gcsDir);
         // NOTE: gsutil uses standard-error for normal-output.  Don't check stdErr!
         if (res.response != 0)
         {
             if (a != null) a.append
                 ("Error Stream: " + C.BRED + res.stdErr + C.RESET + "\nExiting...\n");
             System.exit(0);
         }
         if (a != null) a.append(C.BGREEN + "TAR COPIED TO GCP BUCKET" + C.RESET + '\n');
        
         // ****************************************************************************************
         // Delete local copy of tar file
         // ****************************************************************************************
         res = Shell.RM(tarFile);
         if ((res.stdErr.length() > 0) || (res.response != 0))
         {
             if (a != null) a.append
                 ("Error Stream: " + C.BRED + res.stdErr + C.RESET + "\nExiting...\n");
             System.exit(0);
         }
         if (a != null) a.append(C.BGREEN + "LOCAL COPY DELETED" + C.RESET + '\n');
                
                
         if (a != null) a.append(
             C.BYELLOW +
             "********************************************************************************\n\n" +
             C.RESET + '\n'
         );