peterreilly    2004/04/23 09:57:26

  Modified:    .        Tag: ANT_16_BRANCH WHATSNEW
               src/main/org/apache/tools/ant/taskdefs/optional/jdepend Tag:
                        ANT_16_BRANCH JDependTask.java
  Log:
  sync
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.503.2.86 +2 -0      ant/WHATSNEW
  
  Index: WHATSNEW
  ===================================================================
  RCS file: /home/cvs/ant/WHATSNEW,v
  retrieving revision 1.503.2.85
  retrieving revision 1.503.2.86
  diff -u -r1.503.2.85 -r1.503.2.86
  --- WHATSNEW  23 Apr 2004 15:47:31 -0000      1.503.2.85
  +++ WHATSNEW  23 Apr 2004 16:57:26 -0000      1.503.2.86
  @@ -164,6 +164,8 @@
   
   * failOnAny attribute for <parallel> was broken. Bugzilla Report 28122.
   
  +* JDependTask did not close an output file. Bugzilla Report 28557.
  +
   Other changes:
   --------------
   
  
  
  
  No                   revision
  No                   revision
  1.22.2.8  +83 -72    
ant/src/main/org/apache/tools/ant/taskdefs/optional/jdepend/JDependTask.java
  
  Index: JDependTask.java
  ===================================================================
  RCS file: 
/home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/jdepend/JDependTask.java,v
  retrieving revision 1.22.2.7
  retrieving revision 1.22.2.8
  diff -u -r1.22.2.7 -r1.22.2.8
  --- JDependTask.java  9 Mar 2004 17:01:48 -0000       1.22.2.7
  +++ JDependTask.java  23 Apr 2004 16:57:26 -0000      1.22.2.8
  @@ -453,8 +453,8 @@
               jdepend = new jdepend.textui.JDepend();
           }
   
  +        FileWriter fw = null;
           if (getOutputFile() != null) {
  -            FileWriter fw;
               try {
                   fw = new FileWriter(getOutputFile().getPath());
               } catch (IOException e) {
  @@ -467,87 +467,98 @@
               log("Output to be stored in " + getOutputFile().getPath());
           }
   
  -        if (getClassespath() != null) {
  -            // This is the new, better way - use classespath instead
  -            // of sourcespath.  The code is currently the same - you
  -            // need class files in a directory to use this - jar files
  -            // coming soon....
  -            String[] classesPath = getClassespath().list();
  -            for (int i = 0; i < classesPath.length; i++) {
  -                File f = new File(classesPath[i]);
  -                // not necessary as JDepend would fail, but why loose
  -                // some time?
  -                if (!f.exists() || !f.isDirectory()) {
  -                    String msg = "\""
  -                        + f.getPath()
  -                        + "\" does not represent a valid"
  -                        + " directory. JDepend would fail.";
  -                    log(msg);
  -                    throw new BuildException(msg);
  -                }
  -                try {
  -                    jdepend.addDirectory(f.getPath());
  -                } catch (IOException e) {
  -                    String msg =
  -                        "JDepend Failed when adding a class directory: "
  -                        + e.getMessage();
  -                    log(msg);
  -                    throw new BuildException(msg);
  +
  +        try {
  +            if (getClassespath() != null) {
  +                // This is the new, better way - use classespath instead
  +                // of sourcespath.  The code is currently the same - you
  +                // need class files in a directory to use this - jar files
  +                // coming soon....
  +                String[] classesPath = getClassespath().list();
  +                for (int i = 0; i < classesPath.length; i++) {
  +                    File f = new File(classesPath[i]);
  +                    // not necessary as JDepend would fail, but why loose
  +                    // some time?
  +                    if (!f.exists() || !f.isDirectory()) {
  +                        String msg = "\""
  +                            + f.getPath()
  +                            + "\" does not represent a valid"
  +                            + " directory. JDepend would fail.";
  +                        log(msg);
  +                        throw new BuildException(msg);
  +                    }
  +                    try {
  +                        jdepend.addDirectory(f.getPath());
  +                    } catch (IOException e) {
  +                        String msg =
  +                            "JDepend Failed when adding a class directory: "
  +                            + e.getMessage();
  +                        log(msg);
  +                        throw new BuildException(msg);
  +                    }
  +                }
  +
  +            } else if (getSourcespath() != null) {
  +
  +                // This is the old way and is deprecated - classespath is
  +                // the right way to do this and is above
  +                String[] sourcesPath = getSourcespath().list();
  +                for (int i = 0; i < sourcesPath.length; i++) {
  +                    File f = new File(sourcesPath[i]);
  +
  +                    // not necessary as JDepend would fail, but why loose
  +                    // some time?
  +                    if (!f.exists() || !f.isDirectory()) {
  +                        String msg = "\""
  +                            + f.getPath()
  +                            + "\" does not represent a valid"
  +                            + " directory. JDepend would fail.";
  +                        log(msg);
  +                        throw new BuildException(msg);
  +                    }
  +                    try {
  +                        jdepend.addDirectory(f.getPath());
  +                    } catch (IOException e) {
  +                        String msg =
  +                            "JDepend Failed when adding a source directory: "
  +                            + e.getMessage();
  +                        log(msg);
  +                        throw new BuildException(msg);
  +                    }
                   }
               }
   
  -        } else if (getSourcespath() != null) {
  -
  -            // This is the old way and is deprecated - classespath is
  -            // the right way to do this and is above
  -            String[] sourcesPath = getSourcespath().list();
  -            for (int i = 0; i < sourcesPath.length; i++) {
  -                File f = new File(sourcesPath[i]);
  -
  -                // not necessary as JDepend would fail, but why loose
  -                // some time?
  -                if (!f.exists() || !f.isDirectory()) {
  -                    String msg = "\""
  -                        + f.getPath()
  -                        + "\" does not represent a valid"
  -                        + " directory. JDepend would fail.";
  -                    log(msg);
  -                    throw new BuildException(msg);
  -                }
  -                try {
  -                    jdepend.addDirectory(f.getPath());
  -                } catch (IOException e) {
  -                    String msg =
  -                        "JDepend Failed when adding a source directory: "
  -                        + e.getMessage();
  -                    log(msg);
  -                    throw new BuildException(msg);
  +            // This bit turns <exclude> child tags into patters to ignore
  +            String[] patterns = 
defaultPatterns.getExcludePatterns(getProject());
  +            if (patterns != null && patterns.length > 0) {
  +                if (setFilter != null) {
  +                    Vector v = new Vector();
  +                    for (int i = 0; i < patterns.length; i++) {
  +                        v.addElement(patterns[i]);
  +                    }
  +                    try {
  +                        Object o = packageFilterC.newInstance(new Object[] 
{v});
  +                        setFilter.invoke(jdepend, new Object[] {o});
  +                    } catch (Throwable e) {
  +                        log("excludes will be ignored as JDepend doesn't 
like me: "
  +                            + e.getMessage(), Project.MSG_WARN);
  +                    }
  +                } else {
  +                    log("Sorry, your version of JDepend doesn't support 
excludes",
  +                        Project.MSG_WARN);
                   }
               }
  -        }
   
  -        // This bit turns <exclude> child tags into patters to ignore
  -        String[] patterns = defaultPatterns.getExcludePatterns(getProject());
  -        if (patterns != null && patterns.length > 0) {
  -            if (setFilter != null) {
  -                Vector v = new Vector();
  -                for (int i = 0; i < patterns.length; i++) {
  -                    v.addElement(patterns[i]);
  -                }
  +            jdepend.analyze();
  +        } finally {
  +            if (fw != null) {
                   try {
  -                    Object o = packageFilterC.newInstance(new Object[] {v});
  -                    setFilter.invoke(jdepend, new Object[] {o});
  -                } catch (Throwable e) {
  -                    log("excludes will be ignored as JDepend doesn't like 
me: "
  -                        + e.getMessage(), Project.MSG_WARN);
  +                    fw.close();
  +                } catch (Throwable t) {
  +                    // Ignore
                   }
  -            } else {
  -                log("Sorry, your version of JDepend doesn't support 
excludes",
  -                    Project.MSG_WARN);
               }
           }
  -
  -        jdepend.analyze();
           return SUCCESS;
       }
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to