Skip to content

Commit

Permalink
Fix Jarzilla on El Capitan (Mac OSX 10.11)
Browse files Browse the repository at this point in the history
  • Loading branch information
depsypher committed Dec 17, 2015
1 parent 26d69f2 commit cae290e
Show file tree
Hide file tree
Showing 7 changed files with 448 additions and 359 deletions.
107 changes: 33 additions & 74 deletions jarzilla/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ Jarzilla
-->
<project name="jarzilla" default="dist">

<property file="google.properties" />

<property name="jarzilla.version" value="0.1.5" />
<property name="jarzilla.version" value="0.1.6" />
<property name="jarzilla.mainClass" value="com.googlecode.jarzilla.Jarzilla" />

<path id="jarzilla.classpath">
Expand All @@ -27,7 +25,7 @@ Jarzilla
-->
<target name="compile" description="Compiles the code">
<mkdir dir="build/jarzilla/classes" />
<javac srcdir="src/main/java" destdir="build/jarzilla/classes" debug="on" target="1.5" includeantruntime="false">
<javac srcdir="src/main/java" destdir="build/jarzilla/classes" debug="on" source="1.7" target="1.7" includeantruntime="false">
<classpath refid="jarzilla.classpath" />
</javac>
<copy todir="build/jarzilla/classes">
Expand All @@ -52,51 +50,41 @@ Jarzilla
<attribute name="Jarzilla-Version" value="${jarzilla.version}" />
</manifest>
</jar>

<property name="appdir" value="dist/Jarzilla.app"/>
<mkdir dir="${appdir}/Contents/MacOS"/>
<mkdir dir="${appdir}/Contents/Resources/Java"/>

<copy file="src/main/resources/JavaApplicationStub" todir="${appdir}/Contents/MacOS"/>
<exec executable="chmod">
<arg value="755" />
<arg value="${appdir}/Contents/MacOS/JavaApplicationStub" />
</exec>

<copy file="src/main/resources/Info.plist" todir="${appdir}/Contents" />
<copy file="src/main/resources/jarzilla.icns" todir="${appdir}/Contents/Resources" />

<copy file="src/main/resources/jad" todir="${appdir}/Contents/Resources" />
<exec executable="chmod">
<arg value="755" />
<arg value="${appdir}/Contents/Resources/jad" />
</exec>

<copy file="dist/jarzilla.jar" todir="${appdir}/Contents/Resources/Java" />
<copy todir="${appdir}/Contents/Resources/Java">
<fileset dir="lib/runtime">
<include name="*.jar" />
<include name="*.jnilib" />
</fileset>
</copy>
<exec executable="/Developer/Tools/SetFile">
<arg value="-a" />
<arg value="B" />
<arg value="${appdir}" />
</exec>

<copy file="src/main/resources/updater/schlepit.properties" todir="${appdir}" />

<taskdef name="schlepit"
classname="com.googlecode.jarzilla.schlepit.build.SchlepItTask"
classpath="lib/runtime/schlepit.jar" />

<zip destfile="dist/update.zip" basedir="${appdir}" />
<schlepit version="${jarzilla.version}" fileName="jarzilla.schlepit" source="dist/update.zip" dest="dist/" />
<taskdef name="jarbundler"
classname="net.sourceforge.jarbundler.JarBundler"
classpath="lib/compile/jarbundler-2.5.0.jar" />

<jarbundler
dir="dist"
name="Jarzilla"
shortname="Jarzilla"
icon="src/main/resources/jarzilla.icns"
stubfile="src/main/resources/universalJavaApplicationStub"
useJavaXKey="true"
mainclass="${jarzilla.mainClass}"
jvmversion="1.7+"
signature="JARZ"
bundleid="com.googlecode.jarzilla">

<resourcefilelist dir="src/main/resources" files="jad" />

<jarfilelist dir="dist" files="jarzilla.jar" />
<jarfilelist dir="lib/runtime" files="forms-1.2.1.jar, jsyntaxpane-0.9.4.jar, mac_widgets.jar, quaqua-filechooser-only.jar, schlepit.jar, swingx-1.6.jar" />

<javafilelist dir="lib/runtime" files="libquaqua.jnilib, libquaqua64.jnilib" />

<documenttype name="Jar file"
extensions="jar ear sar war zip"
utis="com.sun.java-archive com.pkware.zip-archive"
iconFile="src/main/resources/jarzilla.icns"
role="Viewer"/>
</jarbundler>
</target>

<!--
Publish the latest build to googlecode
Publish the latest build as dmg
-->
<target name="publish" depends="clean, dist">
<!-- create dmg -->
Expand All @@ -107,35 +95,6 @@ Jarzilla
<exec executable="hdiutil" dir="${basedir}/dist">
<arg line='convert "template.dmg" -format UDZO -imagekey zlib-level=9 -o "Jarzilla-${jarzilla.version}.dmg"' />
</exec>

<input message="Publishing to googlecode: continue (y/n)?"
validargs="y,n"
addproperty="do.publish" />

<condition property="do.abort">
<equals arg1="n" arg2="${do.publish}"/>
</condition>
<fail if="do.abort">Publishing aborted.</fail>

<taskdef classname="net.bluecow.googlecode.ant.GoogleCodeUploadTask" classpath="lib/compile/ant-googlecode-0.0.2.jar" name="gcupload"/>
<property file="google.properties" />
<gcupload
username="${google.username}"
password="${google.password}"
projectname="jarzilla"
filename="dist/jarzilla.schlepit"
targetfilename="jarzilla.schlepit"
summary="Jarzilla auto update package for version ${jarzilla.version}"
verbose="true" />
<gcupload
username="${google.username}"
password="${google.password}"
projectname="jarzilla"
filename="dist/jarzilla-${jarzilla.version}.dmg"
targetfilename="Jarzilla-${jarzilla.version}.dmg"
summary="Jarzilla version ${jarzilla.version}"
labels="Featured"
verbose="true" />
</target>

</project>
</project>
Binary file added jarzilla/lib/compile/jarbundler-2.5.0.jar
Binary file not shown.
Binary file modified jarzilla/lib/compile/lombok.jar
Binary file not shown.
177 changes: 17 additions & 160 deletions jarzilla/src/main/java/com/googlecode/jarzilla/Jarzilla.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,7 @@
*/
package com.googlecode.jarzilla;

import java.awt.BorderLayout;
import java.awt.Cursor;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Properties;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;

import javax.swing.AbstractAction;
import javax.swing.AbstractButton;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.UIManager;

import ch.randelshofer.quaqua.QuaquaManager;

import com.apple.eawt.AppEvent.OpenFilesEvent;
import com.apple.eawt.AppEvent.QuitEvent;
import com.apple.eawt.Application;
Expand All @@ -54,14 +21,27 @@
import com.googlecode.jarzilla.core.ArchiveFile;
import com.googlecode.jarzilla.core.ArchiveFileEntry;
import com.googlecode.jarzilla.core.Utils;
import com.googlecode.jarzilla.schlepit.Schlepper;
import com.googlecode.jarzilla.schlepit.net.DownloadObserver;
import com.googlecode.jarzilla.schlepit.net.Downloader;
import com.googlecode.jarzilla.ui.DetailsMessageBox;
import com.googlecode.jarzilla.ui.HelpDialog;
import com.googlecode.jarzilla.ui.JarzillaBottomBar;
import com.googlecode.jarzilla.ui.ResultsPanel;
import com.googlecode.jarzilla.ui.UpdateDialog;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;

/**
* Jarzilla application class
Expand Down Expand Up @@ -252,129 +232,6 @@ public void handleQuit(ApplicationEvent event)
}
});
}

// update
try
{
Jarzilla.update();
}
catch (Exception e)
{
System.out.println("Update error: " + e.getMessage());
}
}

/**
* @throws Exception
*/
public static void update() throws Exception
{
Schlepper schlepper = new Schlepper();
String path = schlepper.getDirectory(Jarzilla.class);
path = path.substring(0, path.indexOf("Jarzilla.app") + 13);
String propertiesPath = path + "schlepit.properties";

Properties props = schlepper.getProperties(propertiesPath);
String version = props.getProperty("version");
String updateUrl = props.getProperty("updateUrl");
String lastUpdateCheck = props.getProperty("lastUpdateCheck");

System.out.println(path);
System.out.println("Version: " + version);
System.out.println("UpdateUrl: " + updateUrl);
System.out.println("lastUpdateCheck: " + lastUpdateCheck);

long millis = 0;
if (lastUpdateCheck != null)
{
try
{
millis = Long.valueOf(lastUpdateCheck);
}
catch (Exception e)
{
// ignore
}
}

long elapsed = new Date().getTime() - millis;

// update last update check time once a month
if (millis == 0 || elapsed >= 2628000000L) {
props.setProperty("lastUpdateCheck", Long.valueOf(new Date().getTime()).toString());
schlepper.setProperties(propertiesPath, props);
}

// if a month hasn't passed yet, don't check for update
if (elapsed < 2628000000L)
{
System.out.println("Canceling update check, not enough time elapsed: " + elapsed);
return;
}

DownloadObserver observer = new DownloadObserver()
{
private UpdateDialog updateDialog = new UpdateDialog();

@Override
public void onUpdateAvailable(final Downloader downloader)
{
updateDialog.setOkActionListener(new ActionListener()
{
@Override
public void actionPerformed(ActionEvent e)
{
updateDialog.setProgressVisible(true);
synchronized(downloader)
{
downloader.notify();
}
}
});
updateDialog.setNotNowActionListener(new ActionListener()
{
@Override
public void actionPerformed(ActionEvent e)
{
updateDialog.dispose();
}
});
updateDialog.setVisible(true);
}

@Override
public void onUpdateComplete(final Downloader downloader)
{
updateDialog.confirmRestart();
updateDialog.setRestartActionListener(new ActionListener()
{
@Override
public void actionPerformed(ActionEvent e)
{
synchronized(downloader)
{
downloader.notify();
}
updateDialog.dispose();
}
});
}

@Override
public boolean downloadProgress(int percentDone, long secondsLeft)
{
updateDialog.setProgress(percentDone);
return true;
}
};

boolean updated = schlepper.schlep(version, updateUrl, path, observer);
if (updated)
{
new ProcessBuilder("open", "-n", path).start();
Thread.sleep(500);
System.exit(0);
}
}

/** */
Expand Down
Loading

0 comments on commit cae290e

Please sign in to comment.