Changes to:

- Fix issue where legacy system JRE is required (Apple builds)
- Provide a no-op UpdateCheckListener
- Improve robustness of -dataCode argument in buildDist.py
This commit is contained in:
Norberto Lopez
2018-04-11 20:40:28 +00:00
parent 63a2bd53b4
commit d4c4187799
7 changed files with 128 additions and 93 deletions

View File

@@ -371,7 +371,6 @@ def buildPListInfoStatic(destFile, args, jreTarGzFile):
f = open(destFile, 'wb')
writeln(f, 0, '<?xml version="1.0" ?>')
# writeln(f, 0, '<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">')
writeln(f, 0, '<plist version="1.0">')
writeln(f, 1, '<dict>')
@@ -423,20 +422,20 @@ def buildPListInfoStatic(destFile, args, jreTarGzFile):
writeln(f, 3, '<string>' + aStr + '</string>')
writeln(f, 2, '</array>')
# JVM configuration
writeln(f, 2, '<key>Java</key>')
writeln(f, 2, '<dict>')
classPathStr = '$JAVAROOT/' + deployJreDist.getAppLauncherFileName()
tupList = []
tupList.append(('ClassPath', classPathStr))
for (key, val) in tupList:
writeln(f, 3, '<key>' + key + '</key>')
writeln(f, 3, '<string>' + str(val) + '</string>')
writeln(f, 2, '</dict>')
# # ClassPath: AppLauncher
# writeln(f, 2, '<key>Java</key>')
# writeln(f, 2, '<dict>')
#
# classPathStr = '$JAVAROOT/' + deployJreDist.getAppLauncherFileName()
#
# tupList = []
# tupList.append(('ClassPath', classPathStr))
#
# for (key, val) in tupList:
# writeln(f, 3, '<key>' + key + '</key>')
# writeln(f, 3, '<string>' + str(val) + '</string>')
#
# writeln(f, 2, '</dict>')
writeln(f, 1, '</dict>')
writeln(f, 0, '</plist>')

View File

@@ -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:

View File

@@ -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.

View File

@@ -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
* <P>
* This method will be called via reflection.
*/
private void checkForUpdatesWorker(FullTaskPanel aTask, UpdateCheckListener listener)
private void checkForUpdatesWorker(FullTaskPanel aTask, UpdateCheckListener aListener)
{
List<AppRelease> 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.

View File

@@ -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();
}

View File

@@ -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<String> 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 <AppName>/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 = "<string>(.*?)</string>";
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("<key>") == true && tmpStr.endsWith("</key>") == 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 = "<string>$JAVAROOT/" + PlatformUtils.getAppLauncherFileName(aRelease.getVersion()) + "</string>";
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<String> 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 = "<string>(.*?)</string>";
// 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("<key>") == true && tmpStr.endsWith("</key>") == 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 = "<string>$JAVAROOT/" + PlatformUtils.getAppLauncherFileName(aRelease.getVersion()) + "</string>";
// 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);
}
/**

View File

@@ -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);
}
}
});