Browse Source

<style> tried to tranform all children of directories that matched the

include patterns - even children that are themselves directories.

Throw in a check that the thing we want to transform is not a
directory and an attribute to avoid this non-standard (among directory
based tasks) behavior.


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@271564 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 23 years ago
parent
commit
c28fbe7d76
4 changed files with 47 additions and 9 deletions
  1. +5
    -0
      WHATSNEW
  2. +1
    -1
      docs/manual/CoreTasks/javadoc.html
  3. +7
    -0
      docs/manual/CoreTasks/style.html
  4. +34
    -8
      src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java

+ 5
- 0
WHATSNEW View File

@@ -188,6 +188,11 @@ Other changes:
this feature can now be disabled by setting the new includeantruntime
attribute to false.

* <style> behaves different than any other directory based task as it
processes all files that it finds in included directories in
addition to the files matched by your patterns. There now is a new
attribute to suppress this behavior.

Changes from Ant 1.4 to Ant 1.4.1
===========================================



+ 1
- 1
docs/manual/CoreTasks/javadoc.html View File

@@ -613,7 +613,7 @@ respectively.</p>
&lt/javadoc&gt;</pre>
<hr>
<p align="center">Copyright &copy; 2001 Apache Software Foundation. All rights
<p align="center">Copyright &copy; 2001-2002 Apache Software Foundation. All rights
Reserved.</p>

</body>


+ 7
- 0
docs/manual/CoreTasks/style.html View File

@@ -147,6 +147,13 @@ inclusion/exclusion of files works, and how to write patterns.</p>
"html", and "text"</td>
<td valign="top" align="center">No</td>
</tr>
<tr>
<td valign="top">scanincludeddirectories</td>
<td valign="top">If any directories are matched by the
includes/excludes patterns, try to transform all files in these
directories. Default is <code>true</code></td>
<td valign="top" align="center">No</td>
</tr>
</table>
<h3>Parameters specified as nested elements</h3>
<h4>classpath</h4>


+ 34
- 8
src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java View File

@@ -87,6 +87,8 @@ import org.apache.tools.ant.util.FileUtils;
* such as images, or html files in the source directory will be
* copied into the destination directory.
*
* @version $Revision$
*
* @author <a href="mailto:kvisco@exoffice.com">Keith Visco</a>
* @author <a href="mailto:rubys@us.ibm.com">Sam Ruby</a>
* @author <a href="mailto:russgold@acm.org">Russell Gold</a>
@@ -119,6 +121,13 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger {

private String outputtype = null;

/**
* Whether to style all files in the included directories as well.
*
* @since 1.35, Ant 1.5
*/
private boolean performDirectoryScan = true;

/**
* Creates a new XSLTProcess Task.
**/
@@ -126,10 +135,18 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger {
fileUtils = FileUtils.newFileUtils();
} //-- XSLTProcess

/**
* Whether to style all files in the included directories as well.
*
* @since 1.35, Ant 1.5
*/
public void setScanIncludedDirectories(boolean b) {
performDirectoryScan = b;
}
/**
* Executes the task.
*/

public void execute() throws BuildException {
DirectoryScanner scanner;
String[] list;
@@ -190,12 +207,14 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger {
process( baseDir, list[i], destDir, stylesheet );
}

// Process all the directoried marked for styling
dirs = scanner.getIncludedDirectories();
for (int j = 0;j < dirs.length;++j){
list=new File(baseDir,dirs[j]).list();
for (int i = 0;i < list.length;++i) {
process( baseDir, list[i], destDir, stylesheet );
if (performDirectoryScan) {
// Process all the directories marked for styling
dirs = scanner.getIncludedDirectories();
for (int j = 0;j < dirs.length;++j){
list=new File(baseDir,dirs[j]).list();
for (int i = 0;i < list.length;++i) {
process( baseDir, list[i], destDir, stylesheet );
}
}
}
} //-- execute
@@ -325,7 +344,7 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger {
/**
* Processes the given input XML file and stores the result
* in the given resultFile.
**/
*/
private void process(File baseDir, String xmlFile, File destDir,
File stylesheet)
throws BuildException {
@@ -337,6 +356,13 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger {
try {
long styleSheetLastModified = stylesheet.lastModified();
inFile = new File(baseDir,xmlFile);

if (inFile.isDirectory()) {
log("Skipping " + inFile + " it is a directory.",
Project.MSG_VERBOSE);
return;
}
int dotPos = xmlFile.lastIndexOf('.');
if(dotPos>0){
outFile = new File(destDir,xmlFile.substring(0,xmlFile.lastIndexOf('.'))+fileExt);


Loading…
Cancel
Save