You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by bo...@locus.apache.org on 2000/11/06 15:32:28 UTC
cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional Cab.java
bodewig 00/11/06 06:32:27
Modified: . WHATSNEW
src/main/org/apache/tools/ant/taskdefs/optional Cab.java
Log:
Make <cab> support libcabinet on non-Windows platforms.
Submitted by: Nico Seessle <Ni...@epost.de>
Revision Changes Path
1.45 +3 -0 jakarta-ant/WHATSNEW
Index: WHATSNEW
===================================================================
RCS file: /home/cvs/jakarta-ant/WHATSNEW,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -r1.44 -r1.45
--- WHATSNEW 2000/11/06 12:52:39 1.44
+++ WHATSNEW 2000/11/06 14:32:24 1.45
@@ -19,6 +19,9 @@
given. If the doclet does not accept the -d flag then omit the destdir
attribute.
+* <cab> can work on non-Windows platforms with the help of libcabinet.
+ See http://trill.cis.fordham.edu/~barbacha/cabinet_library/.
+
Fixed bugs:
-----------
1.5 +47 -31 jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/Cab.java
Index: Cab.java
===================================================================
RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/Cab.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- Cab.java 2000/09/07 09:50:56 1.4
+++ Cab.java 2000/11/06 14:32:25 1.5
@@ -295,50 +295,66 @@
}
public void execute() throws BuildException {
- // we must be on Windows to continue
- if (!isWindows)
- {
- log("cannot run on non-Windows platforms: " + myos,
- Project.MSG_VERBOSE);
- return;
- }
-
+
checkConfiguration();
Vector files = getFileList();
-
+
// quick exit if the target is up to date
if (isUpToDate(files)) return;
log("Building "+ archiveType +": "+ cabFile.getAbsolutePath());
- try {
- File listFile = createListFile(files);
- ExecTask exec = createExec();
- File outFile = null;
+ // we must be on Windows to continue
+ if (!isWindows) {
+ log("Using listcab/libcabinet", Project.MSG_VERBOSE);
+
+ StringBuffer sb = new StringBuffer();
+
+ Enumeration fileEnum = files.elements();
- // die if cabarc fails
- exec.setFailonerror(true);
- exec.setDir(baseDir);
+ while (fileEnum.hasMoreElements()) {
+ sb.append(fileEnum.nextElement()).append("\n");
+ }
+ sb.append("\n").append(cabFile.getAbsolutePath()).append("\n");
- if (!doVerbose)
- {
- outFile = createTempFile("ant", null);
- exec.setOutput(outFile);
+ try {
+ Process p = Runtime.getRuntime().exec("listcab");
+ OutputStream out = p.getOutputStream();
+ out.write(sb.toString().getBytes());
+ out.flush();
+ out.close();
+ } catch (IOException ex) {
+ String msg = "Problem creating " + cabFile + " " + ex.getMessage();
+ throw new BuildException(msg);
}
+ } else {
+ try {
+ File listFile = createListFile(files);
+ ExecTask exec = createExec();
+ File outFile = null;
- exec.setCommand(createCommand(listFile));
- exec.execute();
-
- if (outFile != null)
- {
- outFile.delete();
+ // die if cabarc fails
+ exec.setFailonerror(true);
+ exec.setDir(baseDir);
+
+ if (!doVerbose) {
+ outFile = createTempFile("ant", null);
+ exec.setOutput(outFile);
+ }
+
+ exec.setCommand(createCommand(listFile));
+ exec.execute();
+
+ if (outFile != null) {
+ outFile.delete();
+ }
+
+ listFile.delete();
+ } catch (IOException ioe) {
+ String msg = "Problem creating " + cabFile + " " + ioe.getMessage();
+ throw new BuildException(msg);
}
-
- listFile.delete();
- } catch (IOException ioe) {
- String msg = "Problem creating " + cabFile + " " + ioe.getMessage();
- throw new BuildException(msg);
}
}
}