Skip to content

Commit

Permalink
Continued work on working directory customization
Browse files Browse the repository at this point in the history
  • Loading branch information
DrOverbuild committed Nov 28, 2015
1 parent 4bfc77e commit ec416ae
Showing 1 changed file with 27 additions and 22 deletions.
49 changes: 27 additions & 22 deletions jarbundler/Frame.java
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ public String getDescription() {

JPanel panel10 = new JPanel(new BorderLayout());
panel10.add(new JLabel("Working Directory: "), BorderLayout.WEST);
workingDirectoryComboBox = new JComboBox<>(new String[]{"User Home Directory", "App Location", "Resource Directory"});
workingDirectoryComboBox = new JComboBox<>(new String[]{"User Home Directory", "App Location (APP_ROOT/..)", "APP_ROOT/Contents/Resources/"});
panel10.add(workingDirectoryComboBox,BorderLayout.CENTER);
northPanel.add(panel10);

Expand Down Expand Up @@ -234,7 +234,7 @@ public void close(){
super.dispose();
}

public static String xmlBuildFile(File outputDirectory, File jarFile, String mainClassName, String shortVersionString, File icon){
public static String xmlBuildFile(File outputDirectory, File jarFile, String mainClassName, String shortVersionString, String workingDir, File icon){
String name = "";
if(outputDirectory.getName().endsWith(".app")){
name = outputDirectory.getName().substring(0,outputDirectory.getName().length()-4);
Expand All @@ -246,24 +246,25 @@ public static String xmlBuildFile(File outputDirectory, File jarFile, String mai
shortVersionString = "1.0";
}

String returnS = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + newline +
String returnS = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +newline+
"<project name=\"tempBuildFile\" default=\"default\" basedir=\"" + outputDirectory.getParent() + "\">" +newline+
" <description>Temporary build config for ant script</description>" +newline+
" <taskdef name=\"bundleapp\"" +newline+
" classname=\"com.oracle.appbundler.AppBundlerTask\""+newline+
" classpath=\"" + appBundlerLocation + "\" />"+newline+
" <target name=\"bundle-app\">"+newline+
" <bundleapp outputdirectory=\"" + outputDirectory.getParent() + "\"" +newline+
" name=\""+name+"\"" +newline+
" displayname=\""+name+"\"" +newline+
" identifier=\""+mainClassName+"\"" +newline+
" shortversion=\""+shortVersionString+"\""+newline+
" icon=\""+icon.getAbsolutePath()+"\""+newline+
" mainclassname=\""+mainClassName+"\">" +newline+
" <classpath file=\"" + jarFile.getAbsolutePath() + "\"/>" +newline+
" <option value=\"-Dapple.laf.useScreenMenuBar=true\"/>" +newline+
" </bundleapp>" +newline+
" </target>" +newline+
" <description>Temporary build config for ant script</description>" +newline+
" <taskdef name=\"bundleapp\"" +newline+
" classname=\"com.oracle.appbundler.AppBundlerTask\"" +newline+
" classpath=\"" + appBundlerLocation + "\" />" +newline+
" <target name=\"bundle-app\">" +newline+
" <bundleapp outputdirectory=\"" + outputDirectory.getParent() + "\"" +newline+
" name=\""+name+"\"" +newline+
" displayname=\""+name+"\"" +newline+
" identifier=\""+mainClassName+"\"" +newline+
" shortversion=\""+shortVersionString+"\"" +newline+
" icon=\""+icon.getAbsolutePath()+"\"" +newline+
" mainclassname=\""+mainClassName+"\">" +newline+
" <classpath file=\"" + jarFile.getAbsolutePath() + "\"/>" +newline+
" <option value=\"-Dapple.laf.useScreenMenuBar=true\"/>" +newline+
workingDir +
" </bundleapp>" +newline+
" </target>" +newline+
" </project>";

return returnS;
Expand Down Expand Up @@ -297,17 +298,21 @@ private void bundle(){
return;
}



// Create build.xml file
enterText("Generating build.xml...");
File parent = outputDirectoryFile.getParentFile();
String workingDir = "";
if(workingDirectoryComboBox.getSelectedItem().equals("App Location (APP_ROOT/..)")){
workingDir = "<option value=\"-Duser.dir=$APP_ROOT/..\"/>" + newline;
}else if (workingDirectoryComboBox.getSelectedItem().equals("APP_ROOT/Contents/Resources/")){
workingDir = "<option value=\"-Duser.dir=$APP_ROOT/Contents/Resources\"/>" + newline;
}
File buildDotXML = new File(parent, "build.xml");
BufferedWriter writer = null;
try {
buildDotXML.createNewFile();
writer = new BufferedWriter(new FileWriter(buildDotXML));
writer.write(xmlBuildFile(outputDirectoryFile, jarfileFile, mainClassNameField.getText(), versionStringField.getText(), iconFile));
writer.write(xmlBuildFile(outputDirectoryFile, jarfileFile, mainClassNameField.getText(), versionStringField.getText(), workingDir, iconFile));
writer.flush();

} catch (IOException ex) {
Expand Down

0 comments on commit ec416ae

Please sign in to comment.