hlship 2004/08/10 07:40:20
Modified: hivebuild/src/java/org/apache/hivemind/build Grabber.java
hivebuild jar-module.xml
Log:
Copy JARs to ext-package/lib for pickup in other projects.
Make Grabber avoid HTTP connection if destination file exists w/ non-zero
length.
Revision Changes Path
1.3 +8 -27
jakarta-hivemind/hivebuild/src/java/org/apache/hivemind/build/Grabber.java
Index: Grabber.java
===================================================================
RCS file:
/home/cvs/jakarta-hivemind/hivebuild/src/java/org/apache/hivemind/build/Grabber.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Grabber.java 4 Aug 2004 15:27:23 -0000 1.2
+++ Grabber.java 10 Aug 2004 14:40:18 -0000 1.3
@@ -21,7 +21,6 @@
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
-import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
@@ -65,27 +64,22 @@
if (_dest.isDirectory())
throw new BuildException("The specified destination is a
directory", getLocation());
+ if (isNonZeroLength(_dest))
+ return;
+
if (!_dest.canWrite())
throw new BuildException(
"Can't write to " + _dest.getAbsolutePath(),
getLocation());
}
- long destTimestamp = getTimestamp(_dest);
-
try
{
URLConnection connection = _src.openConnection();
- if (destTimestamp > 0)
- connection.setIfModifiedSince(destTimestamp);
-
connection.connect();
- if (checkNotModified(connection))
- return;
-
MessageDigest digest = copyConnectionToFile(connection);
if (_md5 != null)
@@ -97,22 +91,9 @@
}
}
- private long getTimestamp(File file)
- {
- if (file.exists())
- return file.lastModified();
-
- return 0;
- }
-
- private boolean checkNotModified(URLConnection connection) throws
IOException
+ private boolean isNonZeroLength(File file)
{
- if (!(connection instanceof HttpURLConnection))
- return false;
-
- HttpURLConnection c = (HttpURLConnection) connection;
-
- return c.getResponseCode() == HttpURLConnection.HTTP_NOT_MODIFIED;
+ return file.length() > 0;
}
private MessageDigest copyConnectionToFile(URLConnection connection)
throws IOException
@@ -187,13 +168,13 @@
reader.close();
String recordedDigest = buffer.toString().trim();
-
+
// Sometimes a digest has a string identifying the file after the
hex string; discard
// that.
-
+
int firstSpace = recordedDigest.indexOf(' ');
if (firstSpace > 0)
- recordedDigest = recordedDigest.substring(0, firstSpace);
+ recordedDigest = recordedDigest.substring(0, firstSpace);
if (downloadedDigest.equals(recordedDigest))
return;
1.7 +4 -0 jakarta-hivemind/hivebuild/jar-module.xml
Index: jar-module.xml
===================================================================
RCS file: /home/cvs/jakarta-hivemind/hivebuild/jar-module.xml,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- jar-module.xml 10 Aug 2004 14:25:16 -0000 1.6
+++ jar-module.xml 10 Aug 2004 14:40:19 -0000 1.7
@@ -261,6 +261,10 @@
<fileset dir="${descriptor.src.dir}"/>
<fileset dir="${java.classes.dir}"/>
</jar>
+
+ <!-- Copy the JAR to the external lib, so that it may be accessed by
other projects that share the
+ same ext-package directory. -->
+ <copy file="${complete-jar-path}" todir="${external.lib.dir}"/>
</target>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]