Browse Source

Make <cab>'s basedir optional.

PR: 18046


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@274288 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 22 years ago
parent
commit
4e347a681e
3 changed files with 45 additions and 17 deletions
  1. +3
    -0
      WHATSNEW
  2. +22
    -2
      docs/manual/OptionalTasks/cab.html
  3. +20
    -15
      src/main/org/apache/tools/ant/taskdefs/optional/Cab.java

+ 3
- 0
WHATSNEW View File

@@ -169,6 +169,9 @@ Other changes:

* Support for HP's NonStop (Tandem) OS has been added.

* <cab>'s basedir attribute is now optional if you specify nested
filesets. Bugzilla Report 18046.

Changes from Ant 1.5.2 to Ant 1.5.3
===================================



+ 22
- 2
docs/manual/OptionalTasks/cab.html View File

@@ -39,7 +39,7 @@ supports all attributes of <code>&lt;fileset&gt;</code>
<tr>
<td valign="top">basedir</td>
<td valign="top">the directory to start archiving files from.</td>
<td valign="top" align="center">Yes</td>
<td valign="top" align="center">No</td>
</tr>
<tr>
<td valign="top">verbose</td>
@@ -91,6 +91,13 @@ supports all attributes of <code>&lt;fileset&gt;</code>
<td valign="top" align="center">No</td>
</tr>
</table>
<h3>Parameters specified as nested elements</h3>
<h4>fileset</h4>

<p>The cab task supports any number of nested <a
href="../CoreTypes/fileset.html"><code>&lt;fileset&gt;</code></a>
elements to specify the files to be included in the archive.</p>

<h3>Examples</h3>
<blockquote><pre>
&lt;cab cabfile=&quot;${dist}/manual.cab&quot;
@@ -121,8 +128,21 @@ manual.cab in the ${dist} directory. Only html files under the
directory api are archived, and files with the name todo.html are
excluded. Output from the cabarc tool is displayed in the build
output.</p>

<blockquote><pre>
&lt;cab cabfile=&quot;${dist}/manual.cab&quot;
verbose=&quot;yes&quot;&gt;
&lt;fileset
dir=&quot;htdocs/manual&quot;
includes=&quot;api/**/*.html&quot;
excludes=&quot;**/todo.html&quot;
/&gt;
&lt;/cab&gt;
</pre></blockquote>
<p>is equivalent to the example above.</p>

<hr>
<p align="center">Copyright &copy; 2000-2002 Apache Software Foundation. All rights
<p align="center">Copyright &copy; 2000-2003 Apache Software Foundation. All rights
Reserved.</p>

</body>


+ 20
- 15
src/main/org/apache/tools/ant/taskdefs/optional/Cab.java View File

@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000-2002 The Apache Software Foundation. All rights
* Copyright (c) 2000-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -143,14 +143,17 @@ public class Cab extends MatchingTask {
* for side-effects to me...
*/
protected void checkConfiguration() throws BuildException {
if (baseDir == null) {
throw new BuildException("basedir attribute must be set!", getLocation());
if (baseDir == null && filesets.size() == 0) {
throw new BuildException("basedir attribute or at least one "
+ "nested filest is required!",
getLocation());
}
if (!baseDir.exists()) {
if (baseDir != null && !baseDir.exists()) {
throw new BuildException("basedir does not exist!", getLocation());
}
if (cabFile == null) {
throw new BuildException("cabfile attribute must be set!" , getLocation());
throw new BuildException("cabfile attribute must be set!",
getLocation());
}
}

@@ -175,7 +178,7 @@ public class Cab extends MatchingTask {
boolean upToDate = true;
for (int i = 0; i < files.size() && upToDate; i++) {
String file = files.elementAt(i).toString();
if (new File(baseDir, file).lastModified() >
if (fileUtils.resolveFile(baseDir, file).lastModified() >
cabFile.lastModified()) {
upToDate = false;
}
@@ -220,16 +223,16 @@ public class Cab extends MatchingTask {
protected Vector getFileList() throws BuildException {
Vector files = new Vector();

if (filesets.size() == 0) {
if (baseDir != null) {
// get files from old methods - includes and nested include
appendFiles(files, super.getDirectoryScanner(baseDir));
} else {
// get files from filesets
for (int i = 0; i < filesets.size(); i++) {
FileSet fs = (FileSet) filesets.elementAt(i);
if (fs != null) {
appendFiles(files, fs.getDirectoryScanner(getProject()));
}
}
// get files from filesets
for (int i = 0; i < filesets.size(); i++) {
FileSet fs = (FileSet) filesets.elementAt(i);
if (fs != null) {
appendFiles(files, fs.getDirectoryScanner(getProject()));
}
}

@@ -264,7 +267,9 @@ public class Cab extends MatchingTask {
try {
Process p = Execute.launch(getProject(),
new String[] {"listcab"}, null,
baseDir, true);
baseDir != null ? baseDir
: getProject().getBaseDir(),
true);
OutputStream out = p.getOutputStream();

// Create the stream pumpers to forward listcab's stdout and stderr to the log


Loading…
Cancel
Save