Don't build our differ if we don't have javaws.jar; fixed some deprecated
CopyUtils usage.
This commit is contained in:
@@ -34,6 +34,12 @@
|
|||||||
<condition property="build.torrent">
|
<condition property="build.torrent">
|
||||||
<isset property="snark.present"/>
|
<isset property="snark.present"/>
|
||||||
</condition>
|
</condition>
|
||||||
|
<available property="javaws.present"
|
||||||
|
classname="com.sun.javaws.jardiff.JarDiff" classpathref="clazzpath"/>
|
||||||
|
<echo message="Have Java Web Start: ${javaws.present}"/>
|
||||||
|
<condition property="build.differ">
|
||||||
|
<isset property="javaws.present"/>
|
||||||
|
</condition>
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
<!-- prepares the application directories -->
|
<!-- prepares the application directories -->
|
||||||
@@ -53,7 +59,7 @@
|
|||||||
<copy todir="${deploy.dir}/lib" flatten="true">
|
<copy todir="${deploy.dir}/lib" flatten="true">
|
||||||
<fileset refid="${app.name}.libs"/>
|
<fileset refid="${app.name}.libs"/>
|
||||||
</copy>
|
</copy>
|
||||||
<copy todir="${deploy.dir}/lib" file="${java.home}/lib/javaws.jar"/>
|
<copy todir="${deploy.dir}/lib" file="${java.home}/lib/javaws.jar" failonerror="false"/>
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
<!-- cleans out the intermediate build files -->
|
<!-- cleans out the intermediate build files -->
|
||||||
@@ -74,6 +80,7 @@
|
|||||||
classpathref="clazzpath" includeAntRuntime="no"
|
classpathref="clazzpath" includeAntRuntime="no"
|
||||||
source="1.5" target="1.5">
|
source="1.5" target="1.5">
|
||||||
<exclude name="**/TorrentDownloader*" unless="build.torrent"/>
|
<exclude name="**/TorrentDownloader*" unless="build.torrent"/>
|
||||||
|
<exclude name="**/tools/Differ*" unless="build.differ"/>
|
||||||
<compilerarg value="-Xlint:unchecked"/>
|
<compilerarg value="-Xlint:unchecked"/>
|
||||||
</javac>
|
</javac>
|
||||||
</target>
|
</target>
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ import com.samskivert.text.MessageUtil;
|
|||||||
import com.samskivert.util.RunAnywhere;
|
import com.samskivert.util.RunAnywhere;
|
||||||
import com.samskivert.util.StringUtil;
|
import com.samskivert.util.StringUtil;
|
||||||
|
|
||||||
import org.apache.commons.io.CopyUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
|
|
||||||
import com.threerings.getdown.Log;
|
import com.threerings.getdown.Log;
|
||||||
import com.threerings.getdown.util.ConfigUtil;
|
import com.threerings.getdown.util.ConfigUtil;
|
||||||
@@ -878,7 +878,7 @@ public class Application
|
|||||||
try {
|
try {
|
||||||
fin = targetURL.openStream();
|
fin = targetURL.openStream();
|
||||||
fout = new FileOutputStream(target);
|
fout = new FileOutputStream(target);
|
||||||
CopyUtils.copy(fin, fout);
|
IOUtils.copy(fin, fout);
|
||||||
} finally {
|
} finally {
|
||||||
StreamUtil.close(fin);
|
StreamUtil.close(fin);
|
||||||
StreamUtil.close(fout);
|
StreamUtil.close(fout);
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ import java.util.zip.ZipEntry;
|
|||||||
import java.security.MessageDigest;
|
import java.security.MessageDigest;
|
||||||
|
|
||||||
import com.sun.javaws.jardiff.JarDiff;
|
import com.sun.javaws.jardiff.JarDiff;
|
||||||
import org.apache.commons.io.CopyUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
|
|
||||||
import com.samskivert.io.StreamUtil;
|
import com.samskivert.io.StreamUtil;
|
||||||
|
|
||||||
@@ -53,18 +53,6 @@ import com.threerings.getdown.data.Resource;
|
|||||||
*/
|
*/
|
||||||
public class Differ
|
public class Differ
|
||||||
{
|
{
|
||||||
/** A suffix appended to file names to indicate that a file should be
|
|
||||||
* newly created. */
|
|
||||||
public static final String CREATE = ".create";
|
|
||||||
|
|
||||||
/** A suffix appended to file names to indicate that a file should be
|
|
||||||
* patched. */
|
|
||||||
public static final String PATCH = ".patch";
|
|
||||||
|
|
||||||
/** A suffix appended to file names to indicate that a file should be
|
|
||||||
* deleted. */
|
|
||||||
public static final String DELETE = ".delete";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a single patch file that contains the differences between
|
* Creates a single patch file that contains the differences between
|
||||||
* the two specified application directories. The patch file will be
|
* the two specified application directories. The patch file will be
|
||||||
@@ -160,7 +148,7 @@ public class Differ
|
|||||||
// their entirety before running jardiff on 'em
|
// their entirety before running jardiff on 'em
|
||||||
File otemp = rebuildJar(orsrc.getLocal());
|
File otemp = rebuildJar(orsrc.getLocal());
|
||||||
File temp = rebuildJar(rsrc.getLocal());
|
File temp = rebuildJar(rsrc.getLocal());
|
||||||
jout.putNextEntry(new ZipEntry(rsrc.getPath() + PATCH));
|
jout.putNextEntry(new ZipEntry(rsrc.getPath() + Patcher.PATCH));
|
||||||
jarDiff(otemp, temp, jout);
|
jarDiff(otemp, temp, jout);
|
||||||
otemp.delete();
|
otemp.delete();
|
||||||
temp.delete();
|
temp.delete();
|
||||||
@@ -171,7 +159,7 @@ public class Differ
|
|||||||
if (verbose) {
|
if (verbose) {
|
||||||
System.out.println("Addition: " + rsrc.getPath());
|
System.out.println("Addition: " + rsrc.getPath());
|
||||||
}
|
}
|
||||||
jout.putNextEntry(new ZipEntry(rsrc.getPath() + CREATE));
|
jout.putNextEntry(new ZipEntry(rsrc.getPath() + Patcher.CREATE));
|
||||||
pipe(rsrc.getLocal(), jout);
|
pipe(rsrc.getLocal(), jout);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -181,7 +169,7 @@ public class Differ
|
|||||||
if (verbose) {
|
if (verbose) {
|
||||||
System.out.println("Removal: " + rsrc.getPath());
|
System.out.println("Removal: " + rsrc.getPath());
|
||||||
}
|
}
|
||||||
jout.putNextEntry(new ZipEntry(rsrc.getPath() + DELETE));
|
jout.putNextEntry(new ZipEntry(rsrc.getPath() + Patcher.DELETE));
|
||||||
}
|
}
|
||||||
|
|
||||||
StreamUtil.close(jout);
|
StreamUtil.close(jout);
|
||||||
@@ -252,7 +240,7 @@ public class Differ
|
|||||||
{
|
{
|
||||||
FileInputStream fin = null;
|
FileInputStream fin = null;
|
||||||
try {
|
try {
|
||||||
CopyUtils.copy(fin = new FileInputStream(file), jout);
|
IOUtils.copy(fin = new FileInputStream(file), jout);
|
||||||
} finally {
|
} finally {
|
||||||
StreamUtil.close(fin);
|
StreamUtil.close(fin);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ import java.util.jar.JarFile;
|
|||||||
import java.util.zip.ZipEntry;
|
import java.util.zip.ZipEntry;
|
||||||
|
|
||||||
import com.samskivert.io.StreamUtil;
|
import com.samskivert.io.StreamUtil;
|
||||||
import org.apache.commons.io.CopyUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
|
|
||||||
import com.threerings.getdown.Log;
|
import com.threerings.getdown.Log;
|
||||||
import com.threerings.getdown.util.ProgressObserver;
|
import com.threerings.getdown.util.ProgressObserver;
|
||||||
@@ -43,6 +43,15 @@ import com.threerings.getdown.util.ProgressObserver;
|
|||||||
*/
|
*/
|
||||||
public class Patcher
|
public class Patcher
|
||||||
{
|
{
|
||||||
|
/** A suffix appended to file names to indicate that a file should be newly created. */
|
||||||
|
public static final String CREATE = ".create";
|
||||||
|
|
||||||
|
/** A suffix appended to file names to indicate that a file should be patched. */
|
||||||
|
public static final String PATCH = ".patch";
|
||||||
|
|
||||||
|
/** A suffix appended to file names to indicate that a file should be deleted. */
|
||||||
|
public static final String DELETE = ".delete";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Applies the specified patch file to the application living in the
|
* Applies the specified patch file to the application living in the
|
||||||
* specified application directory. The supplied observer, if
|
* specified application directory. The supplied observer, if
|
||||||
@@ -68,18 +77,18 @@ public class Patcher
|
|||||||
long elength = entry.getCompressedSize();
|
long elength = entry.getCompressedSize();
|
||||||
|
|
||||||
// depending on the suffix, we do The Right Thing (tm)
|
// depending on the suffix, we do The Right Thing (tm)
|
||||||
if (path.endsWith(Differ.CREATE)) {
|
if (path.endsWith(CREATE)) {
|
||||||
path = strip(path, Differ.CREATE);
|
path = strip(path, CREATE);
|
||||||
System.out.println("Creating " + path + "...");
|
System.out.println("Creating " + path + "...");
|
||||||
createFile(file, entry, new File(appdir, path));
|
createFile(file, entry, new File(appdir, path));
|
||||||
|
|
||||||
} else if (path.endsWith(Differ.PATCH)) {
|
} else if (path.endsWith(PATCH)) {
|
||||||
path = strip(path, Differ.PATCH);
|
path = strip(path, PATCH);
|
||||||
System.out.println("Patching " + path + "...");
|
System.out.println("Patching " + path + "...");
|
||||||
patchFile(file, entry, appdir, path);
|
patchFile(file, entry, appdir, path);
|
||||||
|
|
||||||
} else if (path.endsWith(Differ.DELETE)) {
|
} else if (path.endsWith(DELETE)) {
|
||||||
path = strip(path, Differ.DELETE);
|
path = strip(path, DELETE);
|
||||||
System.out.println("Removing " + path + "...");
|
System.out.println("Removing " + path + "...");
|
||||||
File target = new File(appdir, path);
|
File target = new File(appdir, path);
|
||||||
if (!target.delete()) {
|
if (!target.delete()) {
|
||||||
@@ -152,8 +161,7 @@ public class Patcher
|
|||||||
InputStream in = null;
|
InputStream in = null;
|
||||||
FileOutputStream fout = null;
|
FileOutputStream fout = null;
|
||||||
try {
|
try {
|
||||||
CopyUtils.copy(in = file.getInputStream(entry),
|
IOUtils.copy(in = file.getInputStream(entry), fout = new FileOutputStream(patch));
|
||||||
fout = new FileOutputStream(patch));
|
|
||||||
StreamUtil.close(fout);
|
StreamUtil.close(fout);
|
||||||
fout = null;
|
fout = null;
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import java.io.FileInputStream;
|
|||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import org.apache.commons.io.CopyUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
|
|
||||||
import com.threerings.getdown.Log;
|
import com.threerings.getdown.Log;
|
||||||
|
|
||||||
@@ -105,10 +105,9 @@ public class LaunchUtil
|
|||||||
if (newgd.renameTo(curgd)) {
|
if (newgd.renameTo(curgd)) {
|
||||||
oldgd.delete(); // yay!
|
oldgd.delete(); // yay!
|
||||||
try {
|
try {
|
||||||
// copy the moved file back to getdown-dop-new.jar so that
|
// copy the moved file back to getdown-dop-new.jar so that we don't end up
|
||||||
// we don't end up downloading another copy next time
|
// downloading another copy next time
|
||||||
CopyUtils.copy(new FileInputStream(curgd),
|
IOUtils.copy(new FileInputStream(curgd), new FileOutputStream(newgd));
|
||||||
new FileOutputStream(newgd));
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Log.warning("Error copying updated Getdown back: " + e);
|
Log.warning("Error copying updated Getdown back: " + e);
|
||||||
}
|
}
|
||||||
@@ -125,8 +124,7 @@ public class LaunchUtil
|
|||||||
// that didn't work, let's try copying it
|
// that didn't work, let's try copying it
|
||||||
Log.info("Attempting to upgrade by copying over " + curgd + "...");
|
Log.info("Attempting to upgrade by copying over " + curgd + "...");
|
||||||
try {
|
try {
|
||||||
CopyUtils.copy(new FileInputStream(newgd),
|
IOUtils.copy(new FileInputStream(newgd), new FileOutputStream(curgd));
|
||||||
new FileOutputStream(curgd));
|
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
Log.warning("Mayday! Brute force copy method also failed.");
|
Log.warning("Mayday! Brute force copy method also failed.");
|
||||||
Log.logStackTrace(ioe);
|
Log.logStackTrace(ioe);
|
||||||
|
|||||||
Reference in New Issue
Block a user