From 4850b4c7451c52657f030d7ae18b94fdf00f5590 Mon Sep 17 00:00:00 2001 From: Peter Donald Date: Sun, 20 Jan 2002 09:52:38 +0000 Subject: [PATCH] Move addExtdirs to PathUtils git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@270805 13f79535-47bb-0310-9956-ffa450edef68 --- .../compilers/DefaultCompilerAdapter.java | 35 ++++--------------- .../compilers/DefaultCompilerAdapter.java | 35 ++++--------------- 2 files changed, 14 insertions(+), 56 deletions(-) diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java index b66c29036..ab6fb2597 100644 --- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java +++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java @@ -11,15 +11,15 @@ import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.io.PrintWriter; +import org.apache.avalon.excalibur.io.IOUtil; import org.apache.avalon.excalibur.util.StringUtil; import org.apache.avalon.framework.logger.AbstractLogEnabled; import org.apache.myrmidon.api.TaskException; -import org.apache.myrmidon.api.TaskContext; import org.apache.tools.ant.taskdefs.Javac; import org.apache.tools.ant.taskdefs.exec.Execute2; import org.apache.tools.ant.types.Commandline; import org.apache.tools.ant.types.Path; -import org.apache.tools.ant.types.FileSet; +import org.apache.tools.ant.types.PathUtil; import org.apache.tools.ant.util.FileUtils; /** @@ -288,7 +288,7 @@ public abstract class DefaultCompilerAdapter } // add the classpath - if ( m_compileClasspath != null ) + if( m_compileClasspath != null ) { classpath.addExisting( m_compileClasspath ); } @@ -344,22 +344,13 @@ public abstract class DefaultCompilerAdapter System.arraycopy( args, 0, commandArray, 0, firstFileName ); commandArray[ firstFileName ] = "@" + tmpFile.getAbsolutePath(); } - catch( IOException e ) + catch( final IOException ioe ) { - throw new TaskException( "Error creating temporary file", e ); + throw new TaskException( "Error creating temporary file", ioe ); } finally { - if( out != null ) - { - try - { - out.close(); - } - catch( Throwable t ) - { - } - } + IOUtil.shutdownWriter( out ); } } else @@ -439,19 +430,7 @@ public abstract class DefaultCompilerAdapter } } - final String[] dirs = m_extdirs.list(); - for( int i = 0; i < dirs.length; i++ ) - { - final File dir = new File( dirs[ i ] ); - if( dir.exists() && dir.isDirectory() ) - { - final FileSet fileSet = new FileSet(); - fileSet.setDir( dir ); - fileSet.setIncludes( "*" ); - path.addFileset( fileSet ); - } - } + PathUtil.addExtdirs( path, m_extdirs ); } - } diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java index b66c29036..ab6fb2597 100644 --- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java +++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java @@ -11,15 +11,15 @@ import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.io.PrintWriter; +import org.apache.avalon.excalibur.io.IOUtil; import org.apache.avalon.excalibur.util.StringUtil; import org.apache.avalon.framework.logger.AbstractLogEnabled; import org.apache.myrmidon.api.TaskException; -import org.apache.myrmidon.api.TaskContext; import org.apache.tools.ant.taskdefs.Javac; import org.apache.tools.ant.taskdefs.exec.Execute2; import org.apache.tools.ant.types.Commandline; import org.apache.tools.ant.types.Path; -import org.apache.tools.ant.types.FileSet; +import org.apache.tools.ant.types.PathUtil; import org.apache.tools.ant.util.FileUtils; /** @@ -288,7 +288,7 @@ public abstract class DefaultCompilerAdapter } // add the classpath - if ( m_compileClasspath != null ) + if( m_compileClasspath != null ) { classpath.addExisting( m_compileClasspath ); } @@ -344,22 +344,13 @@ public abstract class DefaultCompilerAdapter System.arraycopy( args, 0, commandArray, 0, firstFileName ); commandArray[ firstFileName ] = "@" + tmpFile.getAbsolutePath(); } - catch( IOException e ) + catch( final IOException ioe ) { - throw new TaskException( "Error creating temporary file", e ); + throw new TaskException( "Error creating temporary file", ioe ); } finally { - if( out != null ) - { - try - { - out.close(); - } - catch( Throwable t ) - { - } - } + IOUtil.shutdownWriter( out ); } } else @@ -439,19 +430,7 @@ public abstract class DefaultCompilerAdapter } } - final String[] dirs = m_extdirs.list(); - for( int i = 0; i < dirs.length; i++ ) - { - final File dir = new File( dirs[ i ] ); - if( dir.exists() && dir.isDirectory() ) - { - final FileSet fileSet = new FileSet(); - fileSet.setDir( dir ); - fileSet.setIncludes( "*" ); - path.addFileset( fileSet ); - } - } + PathUtil.addExtdirs( path, m_extdirs ); } - }