Browse Source

revert <style> to old behavior - make its style attribute interpreted

as relative to the basdir attribute. Make sure it works when handed an
absolute path.


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

+ 2
- 3
WHATSNEW View File

@@ -6,9 +6,6 @@ Changes that could break older environments:

* Zip.setWhenempty() has changed its signature.

* <style>'s style attribute will be resolved as relative to the
projects basedir instead of the basedir attribute of the task.

Fixed bugs:
-----------

@@ -27,6 +24,8 @@ Fixed bugs:

* won't try to pass a -bootclasspath flag to javac 1.1 anymore

* <style>'s style attribute no handles absolute paths correctly.

Changes from Ant 1.2 to Ant 1.3
===========================================



+ 2
- 1
docs/manual/CoreTasks/style.html View File

@@ -52,7 +52,8 @@ inclusion/exclusion of files works, and how to write patterns.</p>
</tr>
<tr>
<td valign="top">style</td>
<td valign="top">name of the stylesheet to use.</td>
<td valign="top">name of the stylesheet to use - given either relative
to the basedir attribute or as an absolute path.</td>
<td align="center" valign="top">Yes</td>
</tr>
<tr>


+ 13
- 3
src/main/org/apache/tools/ant/Project.java View File

@@ -537,7 +537,13 @@ public class Project {
} while (!curtarget.getName().equals(targetName));
}

public File resolveFile(String fileName) {
/**
* Return the canonical form of fileName as an absolute path.
*
* <p>If fileName is a relative file name, resolve it relative to
* rootDir.</p>
*/
public File resolveFile(String fileName, File rootDir) {
fileName = fileName.replace('/', File.separatorChar).replace('\\', File.separatorChar);

// deal with absolute files
@@ -580,14 +586,14 @@ public class Project {
return new File(sb.toString());
}

File file = new File(baseDir.getAbsolutePath());
File file = new File(rootDir.getAbsolutePath());
StringTokenizer tok = new StringTokenizer(fileName, File.separator, false);
while (tok.hasMoreTokens()) {
String part = tok.nextToken();
if (part.equals("..")) {
String parentFile = file.getParent();
if (parentFile == null) {
throw new BuildException("The file or path you specified (" + fileName + ") is invalid releative to " + baseDir.getAbsolutePath());
throw new BuildException("The file or path you specified (" + fileName + ") is invalid releative to " + rootDir.getAbsolutePath());
}
file = new File(parentFile);
} else if (part.equals(".")) {
@@ -607,6 +613,10 @@ public class Project {
}
}

public File resolveFile(String fileName) {
return resolveFile(fileName, baseDir);
}

/**
* Translate a path into its native (platform specific) format.
* <p>


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

@@ -92,7 +92,7 @@ public class XSLTProcess extends MatchingTask {

private File baseDir = null;

private File xslFile = null;
private String xslFile = null;

private String targetExtension = ".html";
private Vector params = new Vector();
@@ -153,10 +153,11 @@ public class XSLTProcess extends MatchingTask {
long styleSheetLastModified = 0;
if (xslFile != null) {
try {
File file = project.resolveFile(xslFile, baseDir);
// Create a new XSL processor with the specified stylesheet
styleSheetLastModified = xslFile.lastModified();
log( "Loading stylesheet " + xslFile, Project.MSG_INFO);
liaison.setStylesheet( xslFile.toString() );
styleSheetLastModified = file.lastModified();
log( "Loading stylesheet " + file, Project.MSG_INFO);
liaison.setStylesheet( file.toString() );
for(Enumeration e = params.elements();e.hasMoreElements();) {
Param p = (Param)e.nextElement();
liaison.addParam( p.getName(), p.getExpression() );
@@ -213,15 +214,13 @@ public class XSLTProcess extends MatchingTask {
} //-- setDestDir

/**
* Sets the file to use for styling relative to the base directory.
* Sets the file to use for styling relative to the base directory
* of this task.
*/
public void setStyle(File xslFile) {
public void setStyle(String xslFile) {
this.xslFile = xslFile;
}

/**
* Sets the file to use for styling relative to the base directory.
*/
public void setProcessor(String processor) throws Exception {

if (processor.equals("trax")) {


Loading…
Cancel
Save