/* * [MkAuxFiles.java] * * Summary: Create aux files. * * Copyright: (c) 1999-2017 Roedy Green, Canadian Mind Products, http://mindprod.com * * Licence: This software may be copied and used freely for any purpose but military. * http://mindprod.com/contact/nonmil.html * * Requires: JDK 1.8+ * * Created with: JetBrains IntelliJ IDEA IDE http://www.jetbrains.com/idea/ * * Version History: * 1.2 2005-07-29 */ package com.mindprod.zzz; import com.mindprod.common18.Build; import com.mindprod.common18.EIO; import com.mindprod.common18.ST; import com.mindprod.fastcat.FastCat; import com.mindprod.filter.WildcardFilter; import com.mindprod.hunkio.HunkIO; import com.mindprod.prices.AppCat; import java.io.File; import java.io.FilenameFilter; import java.io.IOException; import java.nio.charset.Charset; import java.util.regex.Pattern; import static com.mindprod.prices.AppCat.JWS; import static com.mindprod.prices.Licence.FREE; import static com.mindprod.zzz.CompilerCat.JAVA; import static java.lang.System.*; /** * Create aux files. * * @author Roedy Green, Canadian Mind Products * @version 1.2 2005-07-29 * @since 1999 */ class MkAuxFiles extends ProjectInfo { private static final String IS_COMMAND_LINE_WORDING = "This program can only be used from the command prompt, (or via an command\n" + "line style icon shortcut) e.g. under Windows command.exe or JPSoft\n" + "tcmd.exe, formerly called the DOS box. Just clicking the programs in a\n" + "directory listing will not do anything useful. Just typing the program\n" + "names at the command prompt will not either.\n\n"; private static final String IS_HYBRID_WORDING = "This hybrid program is mainly designed to be used as an Applet in a\n" + "browser but is can also be used from the command prompt, e.g. under\n" + "Windows command.exe or JPSoft tcc.exe, formerly called the DOS box. Just\n" + "clicking the programs in a directory listing will not do anything useful. \n" + "Just typing the program names at the command prompt will not either.\n\n"; private static final String MANUAL_INSTALL_WORDING = "This program requires a manual install! See below.\n\n"; private static final String NEEDS_JDK_WORDING = "You must install the Java JDK to use this program.\n" + "See http://mindprod.com/jgloss/jgloss/jdk.html\n\n"; private static final String NEEDS_JRE_WORDING = "You must install the Java JRE to use this program.\n" + "See http://mindprod.com/jgloss/jgloss/jre.html\n\n"; private static final String PLEASE_RESPOND_WORDING = "I put out an avalanche of free software into the world, and submit PAD\n" + "files to hundreds of distribution sites, but I rarely hear back from\n" + "anyone. What's happening? Does it all just work fine? It is so\n" + "complicated nobody can figure out how to use it and they give up on it?\n" + "It is it useful? Since everyone has the source, do people just fix the\n" + "programs to their liking themselves? Did you have trouble installing? Do\n" + "I presume you know too much? I would be happy to hear from you about your\n" + "experiences, positive or negative and your requests for improvements. A\n" + "one-line email to roedy@mindprod.com would be great.\n"; private static final String USES_TEXT_FILES_WORDING = "This program works with vanilla text files, " + "(e.g. ASCII files or " + "UTF-8\n" + "Unicode files). You will need a text editor to create and " + "view them, not a word\n" + "processor. e.g. notepad, " + "Visual Slick Edit or other suitable text editor\n" + "http://mindprod.com/jgloss/editor.html. You must use a " + "monospaced font\n" + "http://mindprod.com/jgloss/monospacedfonts.html (aka fixed" + " pitch, aka\n" + "programmer font) to view your files, " + "or they won't look properly aligned.\n\n"; private static final String VERSION_HISTORY_CONTINUATION_INDENT = ST.spaces( 16 ); /** * Wildcard Pattern to find find files of form j1x.txt */ private static final FilenameFilter J1XFILTER = new WildcardFilter( "j1?.txt" ); private static final Pattern LINE_SPLITTER = Pattern.compile( "\r\n|\n" ); /** * encoding for writing bat and btm files */ private static final Charset BAT_ENCODING = EIO.WINDOWS1252; /** * Copy constructor * * @param pi Copy constructor to extend class */ @SuppressWarnings( { "SameParameterValue" } ) MkAuxFiles( ProjectInfo pi ) { super( pi ); } /** * build instructions to install JDK * * @return generated text */ private static String buildInstallJDK() { final FastCat sb = new FastCat( 2 ); sb.append( "First install a recent Java JDK or JVM.\n" ); sb.append( "See http://mindprod.com/jgloss/installingjava.html.\n" ); return sb.toString(); } /** * build instructions to install a jar * * @return generated text */ private static String buildInstallZipOnMac() { final FastCat sb = new FastCat( 5 ); sb.append( "Safari will automatically unpack the zip into ~/Downloads (version 10.5)\n" ); sb.append( "[or on the Desktop (version 10.4 and earlier)].\n" ); sb.append( "First install a recent Java JDK or JVM.\n" ); sb.append( "See http://mindprod.com/jgloss/installingjava.html.\n" ); sb.append( "You may optionally move the download tree to a permanent home.\n" ); return sb.toString(); } /** * build instructions to install a jar, raw text, no HTML * * @return generated text */ private static String buildInstallZipOnPC() { final FastCat sb = new FastCat( 3 ); sb.append( "To install, extract the zip download with WinZip\n" ); sb.append( "(or similar unzip utility) into any directory you please,\n" ); sb.append( "often J:\\ -- ticking off the use folder names option.\n" ); return sb.toString(); } /** * generate excuse for why Java might not work on Mac * * @return generated text */ private static String buildMacExcuse() { final FastCat sb = new FastCat( 3 ); sb.append( "I don't have a MacIntosh, just a PC, so I can't test my Java programs for Mac compatibility.\n" ); sb.append( "In theory they should work without problems, but in practice that does not always happen.\n" ); sb.append( "If you have problems please, let me know, preferably " + "with screenshots and complete verbatim error messages.\n" ); return sb.toString(); } /** * build instructions to install jni on Mac * * @return generated text */ private String buildInstallJNIonMac() { final FastCat sb = new FastCat( 3 ); sb.append( "\nThis program uses platform-specific JNI.\n" ); sb.append( "I do not yet have a Mac version of the C/C++ JNI code.\n" ); sb.append( "If you are technically savvy, you could create it yourself.\n\n" ); return sb.toString(); } /** * build instructions to install jni * * @return generated text */ private String buildInstallJNIonPC() { final FastCat sb = new FastCat( 6 ); sb.append( "\nThis program uses JNI which requires an awkward manual installation step.\n" ); sb.append( "Copy " ); sb.append( projectLower ); sb.append( ".32.dll and " ); sb.append( projectLower ); sb.append( ".64.dll to a directory on the path/library.path.\n" + "Type PATH at the command prompt to discover the path directories.\n\n" ); return sb.toString(); } /** * build instructions to install and run a jar * * @return generated text */ String buildRunJarOnMac() { final FastCat sb = new FastCat( 13 ); sb.append( "To run as an application, without parameters, just double click the jar file.\n" ); sb.append( "\n" ); sb.append( "To run as an application with parameters, in bash shell type:\n" ); sb.append( "open Terminal.app\n" ); sb.append( "cd ~/Desktop\n" ); sb.append( "java.exe -ea -jar com/mindprod/" ); sb.append( this.projectLower ); sb.append( "/" ); sb.append( projectLower ); sb.append( ".jar " ); sb.append( "{put any parms here}" ); sb.append( "\n\n" ); sb.append( "adjusting as necessary to account for where the jar file is.\n" ); return sb.toString(); } /** * build instructions to install and run a jar * * @return generated text */ String buildRunJarOnPC() { final FastCat sb = new FastCat( 9 ); sb.append( "To run as an application, type:\n" ); sb.append( "java.exe %JAVA_OPTIONS -ea -jar J:\\com\\mindprod\\" ); sb.append( this.projectLower ); sb.append( "\\" ); sb.append( projectLower ); sb.append( ".jar " ); sb.append( "{put any parms here}" ); sb.append( "\n\n" ); sb.append( "adjusting as necessary to account for where the jar file is.\n" ); return sb.toString(); } /** * generate instructions on what sort of app this is. * * @return generated text */ String buildVersionTextHeader() { final FastCat sb = new FastCat( 37 ); sb.append( projectHumanName ); sb.append( " " ); sb.append( versionString ); sb.append( " build: ", Build.BUILD_NUMBER ); sb.append( " released: ", pcOfficialRELEASE_DATE ); switch ( appCat ) { case DOCUMENTATION: case ASMCOM: case ASMEXE: case CPPUTILITY: case CUTILITY: default: break; case BUNDLE: case JAVA_CLASS_LIBRARY: case JAVA_SNIPPETS: case SERVLET: case APPLET: case APPLICATION: case HYBRID: case JWS: sb.append( " compiled with: Java ", Build.JDK_FULL_VERSION ); if ( jetable ) { sb.append( " Jet ", Build.JET_VERSION, "/", Build.JET_PROFILE_VERSION ); } } // end switch sb.append( "\n\n" ); sb.append( description ); sb.append( ".\n\n" ); sb.append( "Copyright: (c) " ); if ( firstCopyrightYear != Build.THIS_COPYRIGHT_YEAR ) { sb.append( firstCopyrightYear ); sb.append( "-" ); } sb.append( Build.THIS_COPYRIGHT_YEAR ); sb.append( " Canadian Mind Products.\n\n" ); sb.append( appCat.getLongCategoryDescription( isSigned ) ); sb.append( ".\n" ); if ( pcPage == 0 ) { sb.append( "Not distributed." ); } else { sb.append( "Download from: " ); sb.append( "http://mindprod.com/products" ); sb.append( pcPage ); sb.append( ".html#" ); sb.append( projectUpper ); } sb.append( "\n" ); // link to HTML manual on website if local one exists. if ( new File( antJarWebDir, projectLower + ".manual.html" ).exists() ) { sb.append( "View formatted HTML Manual online at: " ); sb.append( "http://mindprod.com/" ); sb.append( appCat.getJarDir() ); sb.append( "/" ); sb.append( projectLower ); sb.append( ".manual.html\n" ); } // link to HTML Applet on website if local one exists. if ( new File( antJarWebDir, projectLower + ".html" ).exists() ) { sb.append( "View HTML to run this program online at: " ); sb.append( "http://mindprod.com/" ); sb.append( appCat.getJarDir() ); sb.append( "/" ); sb.append( projectLower ); sb.append( ".html\n" ); } return sb.toString(); } /** * generate instructions on how to Build * * @return generated text */ String buildVersionTextHowBuild() { final FastCat sb = new FastCat( 10 ); sb.append( "----\n\n" ); sb.append( "Rebuilding:\n\n" ); switch ( appCat ) { case BUNDLE: case DOCUMENTATION: case JAVA_CLASS_LIBRARY: case JAVA_SNIPPETS: case SERVLET: sb.append( "You are pretty much on your own how to use this material.\n" ); break; case APPLET: case APPLICATION: case HYBRID: case JWS: sb.append( "The zip already contains the necessary jar files, so unless you modify\n" ); sb.append( "the program, there is no need to recompile the source or rebuild the jar.\n" ); sb.append( "Configure.java basedir=\"E:/\" in rebuild.xml to the drive where your files are.\n" ); if ( isSigned ) { sb.append( "Configure.java your certificate name with environment SET cert=" + CODE_SIGNING_CERT + "\n" ); sb.append( "Configure.java your certificate password " + "with environment SET jarsignerpassword=sesame\n" ); } sb.append( "Use ANT and rebuild.xml, not build.xml, to recompile and recreate the jar.\n" ); break; case ASMCOM: case ASMEXE: sb.append( "The zip already contains the necessary exe, so unless you modify\n" ); sb.append( "the program, there is no need to recompile the source or re-assemble it..\n" ); sb.append( "Configure.java basedir=\"E:/\" in rebuild.xml " + "to the drive where your files are and tweak rebuild.xml.\n" ); sb.append( "Use ANT and rebuild.xml, not build.xml, to reassemble and link.\n" ); break; case CPPUTILITY: case CUTILITY: sb.append( "The zip already contains the necessary exe, so unless you modify\n" ); sb.append( "the program, there is no need to recompile the source or recompile it.\n" ); sb.append( "Configure.java basedir=\"E:/\" in rebuild.xml " + "to the drive where your files are and tweak rebuild.xml.\n" ); sb.append( "Use ANT and rebuild.xml, not build.xml, to rebuild and link.\n" ); break; } return sb.toString(); } /** * generate notes about the app for version.txt * * @return generated text */ String buildVersionTextNotes() { final FastCat sb = new FastCat( 7 ); sb.append( "----\n\n" ); sb.append( "Notes:\n\n" ); switch ( appCat ) { case BUNDLE: case DOCUMENTATION: case JAVA_CLASS_LIBRARY: case JAVA_SNIPPETS: case SERVLET: sb.append( NEEDS_JDK_WORDING ); sb.append( "You are pretty much on your own how to use this material.\n" ); sb.append( MANUAL_INSTALL_WORDING ); break; case APPLET: case JWS: sb.append( NEEDS_JRE_WORDING ); sb.append( MANUAL_INSTALL_WORDING ); break; case HYBRID: sb.append( NEEDS_JRE_WORDING ); sb.append( IS_HYBRID_WORDING ); sb.append( MANUAL_INSTALL_WORDING ); break; case APPLICATION: sb.append( NEEDS_JRE_WORDING ); sb.append( IS_COMMAND_LINE_WORDING ); sb.append( MANUAL_INSTALL_WORDING ); sb.append( USES_TEXT_FILES_WORDING ); break; case ASMCOM: case ASMEXE: case CPPUTILITY: case CUTILITY: sb.append( IS_COMMAND_LINE_WORDING ); sb.append( MANUAL_INSTALL_WORDING ); sb.append( USES_TEXT_FILES_WORDING ); } sb.append( PLEASE_RESPOND_WORDING ); return sb.toString(); } /** * generate instructions on prerequisites * * @return generated text */ String buildVersionTextPrerequisites() { final FastCat sb = new FastCat( 10 ); sb.append( "----\n\n" ); sb.append( "Prerequisites:\n\n" ); switch ( compilerCat ) { case JAVA: sb.append( "This program runs under any OS that supports Java,\n" ); sb.append( "(e.g." + "W2K/XP/W2003/Vista/W2008/W7-32/W7-64/W8-32/W8-64/Linux/LinuxARM/LinuxX86\n" + "/LinuxX64/Ubuntu/Solaris/SolarisSPARC/SolarisSPARC64/SolarisX86/SolarisX64/OSX/AIX...)\n" + "so long as you have\n" ); sb.append( "<><> Java version " ); sb.append( jdkVersionString ); sb.append( " <><> or later installed (32-bit or 64-bit Java).\n" ); sb.append( "See http://mindprod.com/jgloss/installingjava.html for details.\n" ); break; case ASM: sb.append( "This program runs under Microsoft Windows or DOS only (e.g. Win2K/XP/Vista) " + "in a DOS compatibility box).\n" ); break; case C: case CPP: sb.append( "This program runs under Microsoft Windows from the command line (e.g. Win2K/XP/Vista)\n" ); break; case NONE: sb.append( "Consult the documentation for details.\n" ); break; } return sb.toString(); } /** * generate instructions on how to install and run * * @return generated text */ String buildVersionTxtInstallOnMac() { final FastCat sb = new FastCat( 15 ); sb.append( "----\n\n" ); sb.append( "Installing on a MacIntosh:\n\n" ); switch ( appCat ) { case HYBRID: sb.append( "Use Safari to download source and compiled jar files to run on your own machine as an " + "application or Applet.\n" ); sb.append( buildInstallZipOnMac() ); sb.append( buildMacExcuse() ); if ( usesJni ) { sb.append( buildInstallJNIonMac() ); } sb.append( buildRunJarOnMac() ); break; case APPLET: sb.append( "Use Safari to download source and compiled jar files " + " to run on your own machine as an Applet.\n" ); sb.append( buildInstallZipOnMac() ); sb.append( buildMacExcuse() ); if ( usesJni ) { sb.append( buildInstallJNIonMac() ); } break; case APPLICATION: sb.append( "Use Safari to download source and compiled jar files to run " + "on your own machine as an application.\n" ); sb.append( buildInstallZipOnMac() ); sb.append( buildMacExcuse() ); if ( usesJni ) { sb.append( buildInstallJNIonMac() ); } sb.append( buildRunJarOnMac() ); break; case ASMCOM: case ASMEXE: sb.append( "This assembler program will not run on a Mac.\n" ); break; case JWS: sb.append( "Use Safari to download source and compiled jar files to run on your own machine as a " + "Java Web Start application.\n" ); sb.append( buildInstallZipOnMac() ); sb.append( "\n" ); sb.append( "To run the JWS application, modify the jnlp file to look " + "in the right place for its files, then in a bash shell type:\n" ); sb.append( "open Terminal.app\n" ); sb.append( "cd ~/Desktop\n" ); sb.append( "javaws.exe com/mindprod/" ); sb.append( projectLower ); sb.append( "/" ); sb.append( projectLower ); sb.append( ".jnlp\n\n" ); sb.append( "adjusting as necessary to account for where the jar file is." ); sb.append( buildMacExcuse() ); break; case JAVA_CLASS_LIBRARY: case JAVA_SNIPPETS: sb.append( "Use Safari to download source and compiled jar files " + "to run on your own machine as a part of your own program.\n" ); sb.append( buildInstallZipOnMac() ); sb.append( buildMacExcuse() ); break; case CPPUTILITY: case CUTILITY: sb.append( "Use Safari to download source and executable files " + "to run on your own machine as a standalone utility.\n" ); sb.append( "The EXE files will not work. You will have to recompile, " + "perhaps making minor changes to the source code.\n" ); sb.append( buildInstallZipOnMac() ); break; case DOCUMENTATION: sb.append( "Use Safari to download documentation to view on your own machine.\n" ); sb.append( buildInstallZipOnMac() ); break; case BUNDLE: case SERVLET: sb.append( "Consult the documentation for hints. You are pretty much on your own.\n" ); break; } return sb.toString(); } /** * generate instructions on how to install and run * * @return generated text */ String buildVersionTxtInstallOnPC() { final FastCat sb = new FastCat( 15 ); sb.append( "----\n\n" ); sb.append( "Installing on a PC:\n\n" ); switch ( appCat ) { case APPLET: sb.append( "Download source and compiled jar files to run on your own machine as an Applet.\n" ); sb.append( buildInstallJDK() ); sb.append( buildInstallZipOnPC() ); if ( usesJni ) { sb.append( buildInstallJNIonPC() ); } break; case APPLICATION: sb.append( "Download source and compiled jar files to run " + "on your own machine as an application.\n" ); sb.append( buildInstallJDK() ); sb.append( buildInstallZipOnPC() ); if ( usesJni ) { sb.append( buildInstallJNIonPC() ); } sb.append( buildRunJarOnPC() ); break; case BUNDLE: sb.append( "download bundle to use on your own machine.\n" ); sb.append( buildInstallZipOnPC() ); break; case ASMCOM: case ASMEXE: case CPPUTILITY: case CUTILITY: sb.append( "Download source and executable files to run " + "on your own machine as a standalone utility.\n" ); sb.append( buildInstallZipOnPC() ); break; case DOCUMENTATION: sb.append( "Download documentation to view on your own machine.\n" ); sb.append( buildInstallZipOnPC() ); break; case HYBRID: sb.append( "Download source and compiled jar files to run " + "on your own machine as an application or Applet\n" ); sb.append( buildInstallJDK() ); sb.append( buildInstallZipOnPC() ); if ( usesJni ) { sb.append( buildInstallJNIonPC() ); } sb.append( buildRunJarOnPC() ); break; case JWS: sb.append( "Download source and compiled jar files to run " + "on your own machine as a Java Web Start application.\n" ); sb.append( buildInstallJDK() ); sb.append( buildInstallZipOnPC() ); sb.append( "\n" ); sb.append( "To run the JWS application, modify the jnlp file " + "to look in the right place for its files, then type:\n" ); sb.append( "javaws J:\\com\\mindprod\\" ); sb.append( projectLower ); sb.append( "\\" ); sb.append( projectLower ); sb.append( ".jnlp\n\n" ); sb.append( "adjusting as necessary to account for where the jar file is.\n" ); break; case JAVA_CLASS_LIBRARY: case JAVA_SNIPPETS: sb.append( "Download source and compiled jar files to run " + "on your own machine as a part of your own program.\n" ); sb.append( buildInstallJDK() ); sb.append( buildInstallZipOnPC() ); break; case SERVLET: sb.append( "Download source and compiled jar files to run on your own machine as a Servlet.\n" ); sb.append( buildInstallJDK() ); sb.append( "Configure.java your servlet womb." ); sb.append( buildInstallZipOnPC() ); break; } return sb.toString(); } /** * generate instructions on licencing * * @return generated text */ String buildVersionTxtLicence() { final FastCat sb = new FastCat( 15 ); if ( pcLicence == FREE ) { sb.append( "===> Free <===\n" ); } else { sb.append( "price: $" ); sb.append( pcPrice ); sb.append( " USD\n" ); sb.append( "licencing: " ); sb.append( pcLicence.getShortDesc() ); sb.append( '\n' ); } sb.append( pcLicence.getLongDesc() ); sb.append( '\n' ); sb.append( "May be used freely for any purpose but military.\n" ); sb.append( "For more details on this restriction, see\n" ); sb.append( "http://mindprod.com/contact/nonmil.html\n" ); sb.append( "If you include any Canadian Mind Products code in your own applications,\n" ); sb.append( "your app too must be labelled non-military use only.\n" ); sb.append( "http://mindprod.com/contact/nonmil.html\n" ); switch ( appCat ) { case APPLET: case HYBRID: case APPLICATION: case JAVA_CLASS_LIBRARY: case SERVLET: case JWS: sb.append( "All Java jars and source code are included. If you need the class files or Javadoc, " + "you will have to build them yourself. " + "To streamline the zip downloads, class files and Javadoc have been removed.\n" ); break; case JAVA_SNIPPETS: sb.append( "All Java source code is included.\n" ); break; case ASMCOM: case ASMEXE: sb.append( "All ASM source and EXE files code are included.\n" ); break; case BUNDLE: sb.append( "All source and EXE files code are included.\n" ); break; case CPPUTILITY: sb.append( "All C++ source and EXE files code are included.\n" ); break; case CUTILITY: sb.append( "All C source and EXE files code are included.\n" ); break; case DOCUMENTATION: sb.append( "All documentation files code are included.\n" ); break; } return sb.toString(); } /** * This is the master method to stomp all misc aux related files. */ void mkAllAuxFiles() { mkJ1x(); mkJava(); mkJnlp(); mkMasterDistributionSite(); mkDummyOverviewTxt(); mkRunBat(); // use.txt, version.txt and and versionhistor.txt will be concatenated at build time with freshest components // to create xxxx.use. mkVersionTxt(); mkVersionHistoryTxt(); mkGrabBtm(); } /** * generate dummy manifest.txt. Will soon be regenerated by DESC. */ void mkDummyOverviewTxt() { String contents = ""; save( winAbsoluteProjectDir + "\\" + OVERVIEW_FILE, contents, BAT_ENCODING, false ); } /** * generate the grab.btm file fetch java files from Intelli and build them.. */ void mkGrabBtm() { if ( compilerCat == JAVA ) { final FastCat sb = new FastCat( 30 ); sb.append( "@echo off\n" ); sb.append( "rem Grab.btm\n" ); sb.append( "rem This script was generated by com.mindprod.zzz.MkAuxFiles. D o N o t E d i t .\n" ); // no date. No need to pester Subversion with changes. sb.append( "rem Get Java source from IntelliJ and build it. For Roedy's use only.\n" ); sb.append( "E:\\\n" ); sb.append( "cd ", winAbsoluteProjectDir, "\n" ); sb.append( "untouch -q .\n" ); sb.append( "cd E:\\intellij\\mp\\j", targetVersionString.charAt( 2 ), "\\src\\com\\mindprod\\", projectLower, "\n" ); sb.append( "untouch -q .\n" ); sb.append( "rem no /U=update /UF=relaxed update /E=no error /S=subdirs /T=just totals\n" ); sb.append( "rem copy jovo, not image and sound files"); sb.append( "copy /Q /UF /S *.java ", winAbsoluteProjectDir, "\n" ); sb.append( "cd ", winAbsoluteProjectDir, "\n" ); sb.append( "untouch -q .\n" ); // needs to do dir tree, /r just gets file name not relative name sb.append( "for %i in ( *.java ) if not exist E:\\intellij\\mp\\j", targetVersionString.charAt( 2 ), "\\src\\com\\mindprod\\", projectLower, "\\%i echo %i in project but not Intellij\n" ); sb.append( "ant postzip %1\n" ); sb.append( "rem -30-\n" ); save( winAbsoluteProjectDir + "\\grab.btm", sb.toString(), BAT_ENCODING, true /* overwrite */ ); } } /** * generate j17.txt. */ void mkJ1x() { if ( compilerCat == JAVA ) { final File winAbsoluteProjectDirFile = new File( winAbsoluteProjectDir ); final String shouldExist = "j1" + targetVersionString.charAt( 2 ) + ".txt"; // get rid of old if wrong String[] existings = winAbsoluteProjectDirFile.list( J1XFILTER ); for ( String existing : existings ) { if ( !existing.equals( shouldExist ) ) { final File fileToDelete = new File( winAbsoluteProjectDirFile, existing ); out.println( "deleting old " + EIO.getCanOrAbsPath( fileToDelete ) ); fileToDelete.delete(); } } save( winAbsoluteProjectDir + "\\" + shouldExist, "marker to indicate that Java compiler target version " + targetVersionString + " needed.", BAT_ENCODING, false /* don't bother to overwrite, True if change wording above to refresh. */ ); } } /** * generate the skeleton of the Java program. */ void mkJava() { if ( compilerCat == JAVA && hasMainProg ) { final FastCat sb = new FastCat( 32 ); sb.append( "// dummy skeleton for a new project" ); sb.append( "package " ); sb.append( dotPackageQual ); sb.append( ";\n" ); sb.append( "import java.awt.*;\n" ); sb.append( "import java.awt.event.*;\n" ); sb.append( "import java.awt.image.*;\n" ); sb.append( "import java.io.*;\n" ); sb.append( "import java.net.*;\n" ); sb.append( "import java.text.*;\n" ); sb.append( "import java.util.*;\n" ); sb.append( "import java.util.zip.*;\n" ); sb.append( "import javax.imageio.*;\n" ); sb.append( "import javax.swing.*;\n" ); sb.append( "import javax.swing.event.*;\n" ); sb.append( "import javax.swing.tree.*;\n" ); sb.append( '\n' ); sb.append( "public final class " ); sb.append( mainClassName ); sb.append( '\n' ); sb.append( "{\n" ); sb.append( " /**\n" ); sb.append( " * TEST harness\n" ); sb.append( " *\n" ); sb.append( " * @param args not used\n" ); sb.append( " */\n" ); sb.append( " public static void main ( String[] args )\n" ); sb.append( " {\n" ); sb.append( " }\n" ); sb.append( "}\n" ); save( winAbsoluteProjectDir + "\\" + mainClassName + ".java", sb.toString(), EIO.UTF8, false ); } } /** * Make a skeleton JNLP program to run the JWSP */ void mkJnlp() { if ( runsFromHtml && appCat == JWS ) { final FastCat sb = new FastCat( 100 ); sb.append( "\n" ); sb.append( '\n' ); // sb.append("\n" ); // sb.append( "" ); sb.append( "\n" ); sb.append( "\n" ); sb.append( "" ); sb.append( mainClassName ); sb.append( " " ); sb.append( versionString ); sb.append( ": " ); sb.append( description ); sb.append( "\n" ); sb.append( '\n' ); sb.append( "Canadian Mind Products\n" ); sb.append( "\n" ); sb.append( '\n' ); sb.append( "" ); sb.append( description ); sb.append( "\n" ); sb.append( "" ); sb.append( description ); sb.append( "\n" ); sb.append( "" ); sb.append( description ); sb.append( "\n" ); sb.append( "" ); sb.append( mainClassName ); sb.append( "\n" ); sb.append( "\n" ); sb.append( "\n" ); sb.append( "\n" ); sb.append( '\n' ); sb.append( "\n" ); sb.append( "\n" ); sb.append( "\n" ); sb.append( "\n" ); sb.append( "\n" ); sb.append( '\n' ); sb.append( "\n" ); sb.append( "\n" ); sb.append( '\n' ); sb.append( "\n" ); sb.append( "\n" ); sb.append( "\n" ); sb.append( "\n" ); sb.append( "\n" ); sb.append( '\n' ); sb.append( "\n" ); sb.append( "\n" ); sb.append( "\n" ); sb.append( "\n" ); sb.append( '\n' ); sb.append( "\n" ); sb.append( "\n" ); sb.append( "\n" ); sb.append( "\n" ); sb.append( '\n' ); sb.append( "\n" ); sb.append( "\n" ); // in JNLP sb.append( "\n" ); sb.append( "\n" ); sb.append( '\n' ); sb.append( "\n" ); sb.append( "\n" ); sb.append( '\n' ); sb.append( "\n" ); sb.append( "\n" ); sb.append( "" ); save( winAbsoluteProjectDir + "\\" + projectLower + ".jnlp", sb.toString(), EIO.UTF8, false ); } } /** * create the MasterDistribute.site file pointing to the master URL where this program can be downloaded from. */ void mkMasterDistributionSite() { if ( hasDistributedZip ) { final FastCat sb = new FastCat( 7 ); if ( pcPage == 0 ) { sb.append( "Not distributed\n" ); } else { sb.append( "http://mindprod.com/products" ); sb.append( pcPage ); sb.append( ".html#" ); sb.append( projectUpper ); sb.append( '\n' ); } save( winAbsoluteProjectDir + "\\MasterDistribution.site", sb.toString(), EIO.UTF8, true ); } } /** * generate the run.bat file to run the program as an application. */ void mkRunBat() { if ( compilerCat == JAVA && hasMainProg && appCat != AppCat.JAVA_CLASS_LIBRARY ) { final FastCat sb = new FastCat( 11 ); sb.append( "@echo off\n" ); sb.append( echoFlash( "run.bat: run " + mainClassName + " as an application" ) ); sb.append( "rem This script was generated com.mindprod.zzz.MkAuxFiles. D o N o t E d i t .\n" ); sb.append( cdToWinProjectDir ); sb.append( "rem add any parameters on the tail end of the next line.\n" ); sb.append( "java.exe %JAVA_OPTIONS -ea -jar " ); sb.append( mainJarName ); sb.append( '\n' ); sb.append( '\n' ); sb.append( "rem -30-\n" ); save( winAbsoluteProjectDir + "\\run.bat", sb.toString(), BAT_ENCODING, true ); } } /** * extract version history from Java file to versionhistory.txt file which will be glued to form xxx.use */ void mkVersionHistoryTxt() { switch ( appCat ) { default: // if cannot build, get rid of obsolete one new File( winAbsoluteProjectDir + "\\versionhistory.txt" ).delete(); return; // we can autobuild versionhistory.txt for these types. case APPLET: case ASMCOM: case ASMEXE: case APPLICATION: case CPPUTILITY: case CUTILITY: case HYBRID: case JAVA_CLASS_LIBRARY: case JWS: break; } try { // extract version history from the package comment. final String big = HunkIO.readEntireFile( new File( winAbsoluteProjectDir + "\\" + mainSourceName ) ); int start = big.indexOf( "Version History:" ); if ( start < 0 ) { // checking com.mindprod.version no intellij err.println( winAbsoluteProjectDir + "\\" + mainSourceName + " is missing the Version History: " + "comment." ); return; } start += "Version History:".length(); final int end = big.indexOf( "*/", start ); if ( end < 0 ) { err.println( winAbsoluteProjectDir + "\\" + mainSourceName + " is missing a properly terminated " + "Version History comment." ); return; } // we want to add a blank line between versions, so we must split into lines. final String lines[] = LINE_SPLITTER.split( big.substring( start, end ) ); final FastCat sb = new FastCat( lines.length * 3 + 2 ); sb.append( "\n----\n\nVersion History:\n" ); for ( String line : lines ) { line = ST.trimLeading( line, " *" ); // chop off lead spaces and stars if ( line.length() <= 0 ) { // ignore empty lines, including tail end of Version History line and space before */ continue; } final int dot = line.indexOf( '.' ); switch ( dot ) { case -1: default: // continuation line. sb.append( VERSION_HISTORY_CONTINUATION_INDENT ); sb.append( line ); sb.append( '\n' ); break; case 1: // main line version 1.0 sb.append( "\n " ); sb.append( line ); sb.append( '\n' ); break; case 2: // main line version 11.0 sb.append( '\n' ); sb.append( line ); sb.append( '\n' ); break; } } sb.append( "\n-30-\n" ); save( winAbsoluteProjectDir + "\\versionhistory.txt", sb.toString(), BAT_ENCODING, true /* overwrite */ ); } catch ( IOException e ) { err.println( "Unable to access : " + winAbsoluteProjectDir + "\\" + mainSourceName + " to prepare its versionhistory.txt" ); } } /** * Make the version.txt text file that gives the key facts about the project. The first part of a *.use file. */ void mkVersionTxt() { final FastCat sb = new FastCat( 16 ); sb.append( buildVersionTextHeader() ); sb.append( "\n" ); sb.append( buildVersionTextNotes() ); sb.append( "\n" ); sb.append( buildVersionTxtLicence() ); sb.append( "\n" ); sb.append( buildVersionTextPrerequisites() ); sb.append( "\n" ); sb.append( buildVersionTxtInstallOnPC() ); sb.append( "\n" ); sb.append( buildVersionTxtInstallOnMac() ); sb.append( "\n" ); sb.append( buildVersionTextHowBuild() ); sb.append( "\n" ); sb.append( "----\n\n" ); sb.append( "Use:\n" );// extra \n will be added by ANT concat save( winAbsoluteProjectDir + "\\version.txt", sb.toString(), BAT_ENCODING, true ); } }