ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@locus.apache.org
Subject cvs commit: jakarta-ant/src/main/org/apache/tools/ant ProjectHelper.java
Date Thu, 19 Oct 2000 11:30:20 GMT
bodewig     00/10/19 04:30:19

  Modified:    src/main/org/apache/tools/ant ProjectHelper.java
  Log:
  It seems far more plausible to interpret a relative file URI in SYSTEM
  entities relative to the build file instead of basedir, doesn't it?
  
  Revision  Changes    Path
  1.35      +14 -6     jakarta-ant/src/main/org/apache/tools/ant/ProjectHelper.java
  
  Index: ProjectHelper.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/ProjectHelper.java,v
  retrieving revision 1.34
  retrieving revision 1.35
  diff -u -r1.34 -r1.35
  --- ProjectHelper.java	2000/10/19 10:57:48	1.34
  +++ ProjectHelper.java	2000/10/19 11:30:19	1.35
  @@ -75,6 +75,7 @@
       private org.xml.sax.Parser parser;
       private Project project;
       private File buildFile;
  +    private File buildFileParent;
       private Locator locator;
   
       /**
  @@ -89,7 +90,8 @@
        */
       private ProjectHelper(Project project, File buildFile) {
           this.project = project;
  -        this.buildFile = buildFile;
  +        this.buildFile = new File(buildFile.getAbsolutePath());
  +        buildFileParent = new File(this.buildFile.getParent());
       }
   
       /**
  @@ -181,16 +183,23 @@
       private class RootHandler extends HandlerBase {
   
           /**
  -         * resolve file: URIs as releative to the project's basedir.
  +         * resolve file: URIs as relative to the build file.
            */
           public InputSource resolveEntity(String publicId,
                                            String systemId) {
   
               if (systemId.startsWith("file:")) {
  +                String path = systemId.substring(5);
  +                File file = new File(path);
  +                if (!file.isAbsolute()) {
  +                    file = new File(buildFileParent, path);
  +                }
  +                
                   try {
  -                    return new InputSource(new FileInputStream(project.resolveFile(systemId.substring(5))));
  +                    return new InputSource(new FileInputStream(file));
                   } catch (FileNotFoundException fne) {
  -                    project.log(fne.getMessage(), Project.MSG_WARN);
  +                    project.log(file.getAbsolutePath()+" could not be found", 
  +                                Project.MSG_WARN);
                   }
               }
               // use default if not file or file not found
  @@ -251,9 +260,8 @@
               if (project.getProperty("basedir") != null) {
                   project.setBasedir(project.getProperty("basedir"));
               } else {
  -                String buildFileParent = (new File(buildFile.getAbsolutePath())).getParent();
                   if (baseDir == null) {
  -                    project.setBasedir((new File(buildFileParent)).getAbsolutePath());
  +                    project.setBasedir(buildFileParent.getAbsolutePath());
                   } else {
                       // check whether the user has specified an absolute path
                       if ((new File(baseDir)).isAbsolute()) {
  
  
  

Mime
View raw message