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">
|
||||
<isset property="snark.present"/>
|
||||
</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>
|
||||
|
||||
<!-- prepares the application directories -->
|
||||
@@ -53,7 +59,7 @@
|
||||
<copy todir="${deploy.dir}/lib" flatten="true">
|
||||
<fileset refid="${app.name}.libs"/>
|
||||
</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>
|
||||
|
||||
<!-- cleans out the intermediate build files -->
|
||||
@@ -74,6 +80,7 @@
|
||||
classpathref="clazzpath" includeAntRuntime="no"
|
||||
source="1.5" target="1.5">
|
||||
<exclude name="**/TorrentDownloader*" unless="build.torrent"/>
|
||||
<exclude name="**/tools/Differ*" unless="build.differ"/>
|
||||
<compilerarg value="-Xlint:unchecked"/>
|
||||
</javac>
|
||||
</target>
|
||||
|
||||
@@ -55,7 +55,7 @@ import com.samskivert.text.MessageUtil;
|
||||
import com.samskivert.util.RunAnywhere;
|
||||
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.util.ConfigUtil;
|
||||
@@ -878,7 +878,7 @@ public class Application
|
||||
try {
|
||||
fin = targetURL.openStream();
|
||||
fout = new FileOutputStream(target);
|
||||
CopyUtils.copy(fin, fout);
|
||||
IOUtils.copy(fin, fout);
|
||||
} finally {
|
||||
StreamUtil.close(fin);
|
||||
StreamUtil.close(fout);
|
||||
|
||||
@@ -37,7 +37,7 @@ import java.util.zip.ZipEntry;
|
||||
import java.security.MessageDigest;
|
||||
|
||||
import com.sun.javaws.jardiff.JarDiff;
|
||||
import org.apache.commons.io.CopyUtils;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
||||
import com.samskivert.io.StreamUtil;
|
||||
|
||||
@@ -53,18 +53,6 @@ import com.threerings.getdown.data.Resource;
|
||||
*/
|
||||
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
|
||||
* the two specified application directories. The patch file will be
|
||||
@@ -160,7 +148,7 @@ public class Differ
|
||||
// their entirety before running jardiff on 'em
|
||||
File otemp = rebuildJar(orsrc.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);
|
||||
otemp.delete();
|
||||
temp.delete();
|
||||
@@ -171,7 +159,7 @@ public class Differ
|
||||
if (verbose) {
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -181,7 +169,7 @@ public class Differ
|
||||
if (verbose) {
|
||||
System.out.println("Removal: " + rsrc.getPath());
|
||||
}
|
||||
jout.putNextEntry(new ZipEntry(rsrc.getPath() + DELETE));
|
||||
jout.putNextEntry(new ZipEntry(rsrc.getPath() + Patcher.DELETE));
|
||||
}
|
||||
|
||||
StreamUtil.close(jout);
|
||||
@@ -252,7 +240,7 @@ public class Differ
|
||||
{
|
||||
FileInputStream fin = null;
|
||||
try {
|
||||
CopyUtils.copy(fin = new FileInputStream(file), jout);
|
||||
IOUtils.copy(fin = new FileInputStream(file), jout);
|
||||
} finally {
|
||||
StreamUtil.close(fin);
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ import java.util.jar.JarFile;
|
||||
import java.util.zip.ZipEntry;
|
||||
|
||||
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.util.ProgressObserver;
|
||||
@@ -43,6 +43,15 @@ import com.threerings.getdown.util.ProgressObserver;
|
||||
*/
|
||||
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
|
||||
* specified application directory. The supplied observer, if
|
||||
@@ -68,18 +77,18 @@ public class Patcher
|
||||
long elength = entry.getCompressedSize();
|
||||
|
||||
// depending on the suffix, we do The Right Thing (tm)
|
||||
if (path.endsWith(Differ.CREATE)) {
|
||||
path = strip(path, Differ.CREATE);
|
||||
if (path.endsWith(CREATE)) {
|
||||
path = strip(path, CREATE);
|
||||
System.out.println("Creating " + path + "...");
|
||||
createFile(file, entry, new File(appdir, path));
|
||||
|
||||
} else if (path.endsWith(Differ.PATCH)) {
|
||||
path = strip(path, Differ.PATCH);
|
||||
} else if (path.endsWith(PATCH)) {
|
||||
path = strip(path, PATCH);
|
||||
System.out.println("Patching " + path + "...");
|
||||
patchFile(file, entry, appdir, path);
|
||||
|
||||
} else if (path.endsWith(Differ.DELETE)) {
|
||||
path = strip(path, Differ.DELETE);
|
||||
} else if (path.endsWith(DELETE)) {
|
||||
path = strip(path, DELETE);
|
||||
System.out.println("Removing " + path + "...");
|
||||
File target = new File(appdir, path);
|
||||
if (!target.delete()) {
|
||||
@@ -152,8 +161,7 @@ public class Patcher
|
||||
InputStream in = null;
|
||||
FileOutputStream fout = null;
|
||||
try {
|
||||
CopyUtils.copy(in = file.getInputStream(entry),
|
||||
fout = new FileOutputStream(patch));
|
||||
IOUtils.copy(in = file.getInputStream(entry), fout = new FileOutputStream(patch));
|
||||
StreamUtil.close(fout);
|
||||
fout = null;
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.commons.io.CopyUtils;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
||||
import com.threerings.getdown.Log;
|
||||
|
||||
@@ -105,10 +105,9 @@ public class LaunchUtil
|
||||
if (newgd.renameTo(curgd)) {
|
||||
oldgd.delete(); // yay!
|
||||
try {
|
||||
// copy the moved file back to getdown-dop-new.jar so that
|
||||
// we don't end up downloading another copy next time
|
||||
CopyUtils.copy(new FileInputStream(curgd),
|
||||
new FileOutputStream(newgd));
|
||||
// copy the moved file back to getdown-dop-new.jar so that we don't end up
|
||||
// downloading another copy next time
|
||||
IOUtils.copy(new FileInputStream(curgd), new FileOutputStream(newgd));
|
||||
} catch (IOException 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
|
||||
Log.info("Attempting to upgrade by copying over " + curgd + "...");
|
||||
try {
|
||||
CopyUtils.copy(new FileInputStream(newgd),
|
||||
new FileOutputStream(curgd));
|
||||
IOUtils.copy(new FileInputStream(newgd), new FileOutputStream(curgd));
|
||||
} catch (IOException ioe) {
|
||||
Log.warning("Mayday! Brute force copy method also failed.");
|
||||
Log.logStackTrace(ioe);
|
||||
|
||||
Reference in New Issue
Block a user