diff --git a/script/appleUtils.py b/script/appleUtils.py index ff2a747..337d695 100644 --- a/script/appleUtils.py +++ b/script/appleUtils.py @@ -371,7 +371,6 @@ def buildPListInfoStatic(destFile, args, jreTarGzFile): f = open(destFile, 'wb') writeln(f, 0, '') -# writeln(f, 0, '') writeln(f, 0, '') writeln(f, 1, '') @@ -423,20 +422,20 @@ def buildPListInfoStatic(destFile, args, jreTarGzFile): writeln(f, 3, '' + aStr + '') writeln(f, 2, '') - # JVM configuration - writeln(f, 2, 'Java') - writeln(f, 2, '') - - classPathStr = '$JAVAROOT/' + deployJreDist.getAppLauncherFileName() - - tupList = [] - tupList.append(('ClassPath', classPathStr)) - - for (key, val) in tupList: - writeln(f, 3, '' + key + '') - writeln(f, 3, '' + str(val) + '') - - writeln(f, 2, '') +# # ClassPath: AppLauncher +# writeln(f, 2, 'Java') +# writeln(f, 2, '') +# +# classPathStr = '$JAVAROOT/' + deployJreDist.getAppLauncherFileName() +# +# tupList = [] +# tupList.append(('ClassPath', classPathStr)) +# +# for (key, val) in tupList: +# writeln(f, 3, '' + key + '') +# writeln(f, 3, '' + str(val) + '') +# +# writeln(f, 2, '') writeln(f, 1, '') writeln(f, 0, '') diff --git a/script/buildDist.py b/script/buildDist.py index 2d1e4f6..25aac07 100755 --- a/script/buildDist.py +++ b/script/buildDist.py @@ -185,7 +185,7 @@ if __name__ == "__main__": parser.add_argument('-version', default='0.0.1', help='The version of the application.') parser.add_argument('-mainClass', help='Application main entry point.') parser.add_argument('-appArgs', help='Application arguments. Note that this argument must ALWAYS be the last specified!', nargs=argparse.REMAINDER, default=[]) - parser.add_argument('-dataCode', '-dc', help='A list of supporting folders for the application.', nargs='+', default=[]) + parser.add_argument('-dataCode', '-dc', help='A list of supporting files or folders for the application. All items will be copied to the data folder. Symbolic links will not be presereved.', nargs='+', default=[]) parser.add_argument('-javaCode', '-jc', help='A folder which contains the Java build.') parser.add_argument('-jreVersion', dest='jreVerSpec', help='JRE version to utilize. This should be either 1 or 2 values where each value should be something like 1.7 or 1.8 or 1.8.0_34. ' + 'If 2 values are specified than the second value must be later than the first value. Any static build will be built with the latest allowable JRE.' @@ -301,16 +301,36 @@ if __name__ == "__main__": deltaCodePath = os.path.join(deltaPath, "code") deltaDataPath = os.path.join(deltaPath, "data") + # Ensure the user does not specify the top level data folder so that a ~/data/data folder is not inadvertently created + if len(args.dataCode) == 1 and args.dataCode[0].rstrip('/').endswith('data'): + srcPath = args.dataCode[0].rstrip('/') + print(' [ERROR] The specified dataCode path will result in a data folder inside another data folder. Refusing action. Please specify the individual data files/folders.') + print(' Consider using:') + print(' -dataCode ' + srcPath + '/*') + print(' instead of:') + print(' -dataCode ' + args.dataCode[0] + '\n') + shutil.rmtree(buildPath) + exit(-1) + # Copy the dataCode to the delta location os.makedirs(deltaDataPath) - for aPath in args.dataCode: - srcPath = aPath - if os.path.isdir(srcPath) == False: - print(' [ERROR] The dataCode path does not exist. Path: ' + srcPath + '\n') + for aSrcPath in args.dataCode: + if os.path.exists(aSrcPath) == False: + print(' [ERROR] The dataCode path does not exist. Path: ' + aSrcPath + '\n') + shutil.rmtree(buildPath) + exit(-1) + elif os.path.isfile(aSrcPath): + dstPath = os.path.join(deltaDataPath, os.path.basename(aSrcPath)) + shutil.copy(aSrcPath, dstPath) + continue + elif os.path.isdir(aSrcPath): + aSrcPath = aSrcPath.rstrip('/') + dstPath = os.path.join(deltaDataPath, os.path.basename(aSrcPath)) + shutil.copytree(aSrcPath, dstPath, symlinks=False) + else: + print(' [ERROR] The dataCode path is not a valid file or folder. Path: ' + aSrcPath + '\n') shutil.rmtree(buildPath) exit(-1) - dstPath = os.path.join(deltaDataPath, os.path.basename(aPath)) - shutil.copytree(srcPath, dstPath, symlinks=False) # Build the java component of the distribution if args.javaCode != None: diff --git a/src/distMaker/DistApp.java b/src/distMaker/DistApp.java index 5e36544..290441f 100644 --- a/src/distMaker/DistApp.java +++ b/src/distMaker/DistApp.java @@ -12,7 +12,7 @@ import distMaker.utils.Version; public class DistApp { /** The DistMaker version is defined here. */ - public static final Version version = new PlainVersion(0, 48, 0); + public static final Version version = new PlainVersion(0, 49, 0); /** * Main entry point that will print out the version of DistMaker to stdout. diff --git a/src/distMaker/DistMakerEngine.java b/src/distMaker/DistMakerEngine.java index 53914d5..54f91b2 100644 --- a/src/distMaker/DistMakerEngine.java +++ b/src/distMaker/DistMakerEngine.java @@ -63,7 +63,7 @@ public class DistMakerEngine /** * Method that will notify the user that updates are being checked for */ - public void checkForUpdates(UpdateCheckListener listener) + public void checkForUpdates(UpdateCheckListener aListener) { FullTaskPanel taskPanel; File installPath; @@ -99,7 +99,7 @@ public class DistMakerEngine taskPanel.setVisible(true); // Launch the actual checking of updates in a separate worker thread - Runnable tmpRunnable = () -> checkForUpdatesWorker(taskPanel, listener); + Runnable tmpRunnable = () -> checkForUpdatesWorker(taskPanel, aListener); ThreadUtil.launchRunnable(tmpRunnable, "thread-checkForUpdates"); } @@ -255,7 +255,7 @@ public class DistMakerEngine *

* This method will be called via reflection. */ - private void checkForUpdatesWorker(FullTaskPanel aTask, UpdateCheckListener listener) + private void checkForUpdatesWorker(FullTaskPanel aTask, UpdateCheckListener aListener) { List fullList; AppRelease chosenItem; @@ -281,7 +281,7 @@ public class DistMakerEngine } // a successful test has been done, so notify the listener - listener.checkForNewVersionsPerformed(); + aListener.checkForNewVersionsPerformed(); // In case there is only the current version, don't show the update selection panel. // Just show a short message that everything is up to date, and abort. diff --git a/src/distMaker/UpdateCheckListener.java b/src/distMaker/UpdateCheckListener.java index 73d02c4..0c90abd 100644 --- a/src/distMaker/UpdateCheckListener.java +++ b/src/distMaker/UpdateCheckListener.java @@ -1,6 +1,5 @@ package distMaker; - /** * lets any interested party know that a check for for updates has been done * @@ -8,5 +7,20 @@ package distMaker; */ public interface UpdateCheckListener { - void checkForNewVersionsPerformed(); + /** + * UpdateCheckListener that does nothing. Use this (immutable) instance if you do not care about notifications. + */ + public final static UpdateCheckListener None = new UpdateCheckListener() + { + @Override + public void checkForNewVersionsPerformed() + { + ; // Nothing to do + } + }; + + /** + * Notify the listener that an update check has been performed. + */ + void checkForNewVersionsPerformed(); } diff --git a/src/distMaker/platform/AppleUtils.java b/src/distMaker/platform/AppleUtils.java index fe79848..57c2ae1 100644 --- a/src/distMaker/platform/AppleUtils.java +++ b/src/distMaker/platform/AppleUtils.java @@ -3,7 +3,6 @@ package distMaker.platform; import java.io.*; import java.util.ArrayList; import java.util.List; -import java.util.regex.Matcher; import java.util.regex.Pattern; import javax.xml.parsers.DocumentBuilder; @@ -111,62 +110,72 @@ public class AppleUtils */ public static void updateAppLauncher(AppLauncherRelease aRelease, File pFile) { - List inputList; - String evalStr, tmpStr; - String prevKeyValue; - boolean isFound; + // Note the JavaAppLauncher executable appears to no longer support specifying the class path + // Thus there is nothing to update as the AppLauncherRelease is implicitly loaded by it being in + // the path /Contents/Java/ folder. + // + // Be aware of one big caveat - if there are multiple AppLauncher jars in the implicit location it + // is not clear which one will be selected! + // + // Change made as of 2018Apr11 + return; - // Bail if the pFile is not writable - if (pFile.setWritable(true) == false) - throw new ErrorDM("The pFile is not writeable: " + pFile); - - // Define the regex we will be searching for - String regex = "(.*?)"; - Pattern tmpPattern = Pattern.compile(regex); - - // Process our input - inputList = new ArrayList<>(); - try (BufferedReader br = MiscUtils.openFileAsBufferedReader(pFile)) - { - // Read the lines - isFound = false; - prevKeyValue = ""; - while (true) - { - evalStr = br.readLine(); - if (evalStr == null) - break; - - // Keep track of the last key element - tmpStr = evalStr.trim(); - if (tmpStr.startsWith("") == true && tmpStr.endsWith("") == true) - prevKeyValue = tmpStr.substring(5, tmpStr.length() - 6).trim(); - - // The AppLauncher is specified just after the key element with the value: ClassPath - if (prevKeyValue.equals("ClassPath") == true && tmpPattern.matcher(evalStr).find() == true) - { - // Perform the replacement - String repStr = "$JAVAROOT/" + PlatformUtils.getAppLauncherFileName(aRelease.getVersion()) + ""; - repStr = Matcher.quoteReplacement(repStr); - evalStr = tmpPattern.matcher(evalStr).replaceFirst(repStr); - - isFound = true; - } - - inputList.add(evalStr); - } - } - catch(IOException aExp) - { - throw new ErrorDM(aExp, "Failed while processing the pFile: " + pFile); - } - - // Fail if there was no update performed - if (isFound == false) - throw new ErrorDM("[" + pFile + "] The pFile does not specify a 'ClassPath' section."); - - // Write the pFile - MiscUtils.writeDoc(pFile, inputList); +// List inputList; +// String evalStr, tmpStr; +// String prevKeyValue; +// boolean isFound; +// +// // Bail if the pFile is not writable +// if (pFile.setWritable(true) == false) +// throw new ErrorDM("The pFile is not writeable: " + pFile); +// +// // Define the regex we will be searching for +// String regex = "(.*?)"; +// Pattern tmpPattern = Pattern.compile(regex); +// +// // Process our input +// inputList = new ArrayList<>(); +// try (BufferedReader br = MiscUtils.openFileAsBufferedReader(pFile)) +// { +// // Read the lines +// isFound = false; +// prevKeyValue = ""; +// while (true) +// { +// evalStr = br.readLine(); +// if (evalStr == null) +// break; +// +// // Keep track of the last key element +// tmpStr = evalStr.trim(); +// if (tmpStr.startsWith("") == true && tmpStr.endsWith("") == true) +// prevKeyValue = tmpStr.substring(5, tmpStr.length() - 6).trim(); +// +// // The AppLauncher is specified just after the key element with the value: ClassPath +// if (prevKeyValue.equals("ClassPath") == true && tmpPattern.matcher(evalStr).find() == true) +// { +// // Perform the replacement +// String repStr = "$JAVAROOT/" + PlatformUtils.getAppLauncherFileName(aRelease.getVersion()) + ""; +// repStr = Matcher.quoteReplacement(repStr); +// evalStr = tmpPattern.matcher(evalStr).replaceFirst(repStr); +// +// isFound = true; +// } +// +// inputList.add(evalStr); +// } +// } +// catch(IOException aExp) +// { +// throw new ErrorDM(aExp, "Failed while processing the pFile: " + pFile); +// } +// +// // Fail if there was no update performed +// if (isFound == false) +// throw new ErrorDM("[" + pFile + "] The pFile does not specify a 'ClassPath' section."); +// +// // Write the pFile +// MiscUtils.writeDoc(pFile, inputList); } /** diff --git a/src/distMaker/utils/DeployUtils.java b/src/distMaker/utils/DeployUtils.java index acc1416..26565d7 100644 --- a/src/distMaker/utils/DeployUtils.java +++ b/src/distMaker/utils/DeployUtils.java @@ -86,19 +86,12 @@ public final class DeployUtils { @Override public void actionPerformed(ActionEvent e) { - UpdateCheckListener listener = new UpdateCheckListener() { - @Override - public void checkForNewVersionsPerformed() - { - //autoUpdateCheckSettings.updateAutoCheckWithCurrentTime(); - } - }; if(DistUtils.isDevelopersEnvironment()) { JOptionPane.showMessageDialog(parentFrame, "Cannot update tool in a developer environment."); } else if (dme == null) { JOptionPane.showMessageDialog(parentFrame, "Unable to locate updates."); } else { - dme.checkForUpdates(listener); + dme.checkForUpdates(UpdateCheckListener.None); } } });