Also moved some of the static methods (particularly path parsing) into FileUtils). git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@270770 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -172,7 +172,10 @@ public class XMLValidateTask | |||||
| { | { | ||||
| m_classpath = new Path(); | m_classpath = new Path(); | ||||
| } | } | ||||
| return m_classpath.createPath(); | |||||
| Path path1 = m_classpath; | |||||
| final Path path = new Path(); | |||||
| path1.addPath( path ); | |||||
| return path; | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -166,7 +166,10 @@ public class XSLTProcess | |||||
| { | { | ||||
| m_classpath = new Path(); | m_classpath = new Path(); | ||||
| } | } | ||||
| return m_classpath.createPath(); | |||||
| Path path1 = m_classpath; | |||||
| final Path path = new Path(); | |||||
| path1.addPath( path ); | |||||
| return path; | |||||
| } | } | ||||
| public XSLTParam createParam() | public XSLTParam createParam() | ||||
| @@ -92,7 +92,10 @@ public class Available | |||||
| { | { | ||||
| m_classpath = new Path(); | m_classpath = new Path(); | ||||
| } | } | ||||
| return m_classpath.createPath(); | |||||
| Path path1 = m_classpath; | |||||
| final Path path = new Path(); | |||||
| path1.addPath( path ); | |||||
| return path; | |||||
| } | } | ||||
| public Path createFilepath() | public Path createFilepath() | ||||
| @@ -102,7 +105,10 @@ public class Available | |||||
| { | { | ||||
| m_filepath = new Path(); | m_filepath = new Path(); | ||||
| } | } | ||||
| return m_filepath.createPath(); | |||||
| Path path1 = m_filepath; | |||||
| final Path path = new Path(); | |||||
| path1.addPath( path ); | |||||
| return path; | |||||
| } | } | ||||
| public boolean eval() | public boolean eval() | ||||
| @@ -117,7 +117,10 @@ public class Java | |||||
| public Path createClasspath() | public Path createClasspath() | ||||
| throws TaskException | throws TaskException | ||||
| { | { | ||||
| return m_cmdl.createClasspath().createPath(); | |||||
| Path path1 = m_cmdl.createClasspath(); | |||||
| final Path path = new Path(); | |||||
| path1.addPath( path ); | |||||
| return path; | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -642,7 +642,10 @@ public class Javac extends MatchingTask | |||||
| { | { | ||||
| bootclasspath = new Path(); | bootclasspath = new Path(); | ||||
| } | } | ||||
| return bootclasspath.createPath(); | |||||
| Path path1 = bootclasspath; | |||||
| final Path path = new Path(); | |||||
| path1.addPath( path ); | |||||
| return path; | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -657,7 +660,10 @@ public class Javac extends MatchingTask | |||||
| { | { | ||||
| compileClasspath = new Path(); | compileClasspath = new Path(); | ||||
| } | } | ||||
| return compileClasspath.createPath(); | |||||
| Path path1 = compileClasspath; | |||||
| final Path path = new Path(); | |||||
| path1.addPath( path ); | |||||
| return path; | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -685,7 +691,10 @@ public class Javac extends MatchingTask | |||||
| { | { | ||||
| extdirs = new Path(); | extdirs = new Path(); | ||||
| } | } | ||||
| return extdirs.createPath(); | |||||
| Path path1 = extdirs; | |||||
| final Path path = new Path(); | |||||
| path1.addPath( path ); | |||||
| return path; | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -700,7 +709,10 @@ public class Javac extends MatchingTask | |||||
| { | { | ||||
| src = new Path(); | src = new Path(); | ||||
| } | } | ||||
| return src.createPath(); | |||||
| Path path1 = src; | |||||
| final Path path = new Path(); | |||||
| path1.addPath( path ); | |||||
| return path; | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -105,7 +105,10 @@ public class PathConvert extends Task | |||||
| { | { | ||||
| m_path = new Path(); | m_path = new Path(); | ||||
| } | } | ||||
| return m_path.createPath(); | |||||
| Path path1 = m_path; | |||||
| final Path path = new Path(); | |||||
| path1.addPath( path ); | |||||
| return path; | |||||
| } | } | ||||
| public void execute() | public void execute() | ||||
| @@ -75,7 +75,10 @@ public class Property | |||||
| { | { | ||||
| m_classpath = new Path(); | m_classpath = new Path(); | ||||
| } | } | ||||
| return m_classpath.createPath(); | |||||
| Path path1 = m_classpath; | |||||
| final Path path = new Path(); | |||||
| path1.addPath( path ); | |||||
| return path; | |||||
| } | } | ||||
| public void execute() | public void execute() | ||||
| @@ -471,7 +471,10 @@ public class Rmic extends MatchingTask | |||||
| { | { | ||||
| compileClasspath = new Path(); | compileClasspath = new Path(); | ||||
| } | } | ||||
| return compileClasspath.createPath(); | |||||
| Path path1 = compileClasspath; | |||||
| final Path path = new Path(); | |||||
| path1.addPath( path ); | |||||
| return path; | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -486,7 +489,10 @@ public class Rmic extends MatchingTask | |||||
| { | { | ||||
| extdirs = new Path(); | extdirs = new Path(); | ||||
| } | } | ||||
| return extdirs.createPath(); | |||||
| Path path1 = extdirs; | |||||
| final Path path = new Path(); | |||||
| path1.addPath( path ); | |||||
| return path; | |||||
| } | } | ||||
| public void execute() | public void execute() | ||||
| @@ -357,7 +357,10 @@ public class SQLExec | |||||
| { | { | ||||
| this.classpath = new Path(); | this.classpath = new Path(); | ||||
| } | } | ||||
| return this.classpath.createPath(); | |||||
| Path path1 = this.classpath; | |||||
| final Path path = new Path(); | |||||
| path1.addPath( path ); | |||||
| return path; | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -65,6 +65,9 @@ public class DocletInfo | |||||
| { | { | ||||
| m_path = new Path(); | m_path = new Path(); | ||||
| } | } | ||||
| return m_path.createPath(); | |||||
| Path path1 = m_path; | |||||
| final Path path = new Path(); | |||||
| path1.addPath( path ); | |||||
| return path; | |||||
| } | } | ||||
| } | } | ||||
| @@ -471,7 +471,10 @@ public class Javadoc | |||||
| { | { | ||||
| m_bootclasspath = new Path(); | m_bootclasspath = new Path(); | ||||
| } | } | ||||
| return m_bootclasspath.createPath(); | |||||
| Path path1 = m_bootclasspath; | |||||
| final Path path = new Path(); | |||||
| path1.addPath( path ); | |||||
| return path; | |||||
| } | } | ||||
| public Path createClasspath() | public Path createClasspath() | ||||
| @@ -481,7 +484,10 @@ public class Javadoc | |||||
| { | { | ||||
| m_classpath = new Path(); | m_classpath = new Path(); | ||||
| } | } | ||||
| return m_classpath.createPath(); | |||||
| Path path1 = m_classpath; | |||||
| final Path path = new Path(); | |||||
| path1.addPath( path ); | |||||
| return path; | |||||
| } | } | ||||
| public DocletInfo createDoclet() | public DocletInfo createDoclet() | ||||
| @@ -511,7 +517,10 @@ public class Javadoc | |||||
| { | { | ||||
| m_sourcePath = new Path(); | m_sourcePath = new Path(); | ||||
| } | } | ||||
| return m_sourcePath.createPath(); | |||||
| Path path1 = m_sourcePath; | |||||
| final Path path = new Path(); | |||||
| path1.addPath( path ); | |||||
| return path; | |||||
| } | } | ||||
| public void execute() | public void execute() | ||||
| @@ -92,7 +92,10 @@ public class ANTLR extends Task | |||||
| */ | */ | ||||
| public Path createClasspath() | public Path createClasspath() | ||||
| { | { | ||||
| return commandline.createClasspath().createPath(); | |||||
| Path path1 = commandline.createClasspath(); | |||||
| final Path path = new Path(); | |||||
| path1.addPath( path ); | |||||
| return path; | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -155,7 +155,10 @@ public class Javah | |||||
| { | { | ||||
| m_bootclasspath = new Path(); | m_bootclasspath = new Path(); | ||||
| } | } | ||||
| return m_bootclasspath.createPath(); | |||||
| Path path1 = m_bootclasspath; | |||||
| final Path path = new Path(); | |||||
| path1.addPath( path ); | |||||
| return path; | |||||
| } | } | ||||
| public ClassArgument createClass() | public ClassArgument createClass() | ||||
| @@ -172,7 +175,10 @@ public class Javah | |||||
| { | { | ||||
| m_classpath = new Path(); | m_classpath = new Path(); | ||||
| } | } | ||||
| return m_classpath.createPath(); | |||||
| Path path1 = m_classpath; | |||||
| final Path path = new Path(); | |||||
| path1.addPath( path ); | |||||
| return path; | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -174,7 +174,10 @@ public class Depend extends MatchingTask | |||||
| { | { | ||||
| dependClasspath = new Path(); | dependClasspath = new Path(); | ||||
| } | } | ||||
| return dependClasspath.createPath(); | |||||
| Path path1 = dependClasspath; | |||||
| final Path path = new Path(); | |||||
| path1.addPath( path ); | |||||
| return path; | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -92,7 +92,10 @@ public class BorlandGenerateClient extends Task | |||||
| { | { | ||||
| this.classpath = new Path(); | this.classpath = new Path(); | ||||
| } | } | ||||
| return this.classpath.createPath(); | |||||
| Path path1 = this.classpath; | |||||
| final Path path = new Path(); | |||||
| path1.addPath( path ); | |||||
| return path; | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -256,7 +256,10 @@ public class EjbJar extends MatchingTask | |||||
| { | { | ||||
| config.classpath = new Path(); | config.classpath = new Path(); | ||||
| } | } | ||||
| return config.classpath.createPath(); | |||||
| Path path1 = config.classpath; | |||||
| final Path path = new Path(); | |||||
| path1.addPath( path ); | |||||
| return path; | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -200,7 +200,10 @@ public class GenericDeploymentTool | |||||
| { | { | ||||
| classpath = new Path(); | classpath = new Path(); | ||||
| } | } | ||||
| return classpath.createPath(); | |||||
| Path path1 = classpath; | |||||
| final Path path = new Path(); | |||||
| path1.addPath( path ); | |||||
| return path; | |||||
| } | } | ||||
| public void processDescriptor( String descriptorFileName, SAXParser saxParser ) | public void processDescriptor( String descriptorFileName, SAXParser saxParser ) | ||||
| @@ -178,7 +178,10 @@ public class IPlanetEjbcTask extends Task | |||||
| { | { | ||||
| classpath = new Path(); | classpath = new Path(); | ||||
| } | } | ||||
| return classpath.createPath(); | |||||
| Path path1 = classpath; | |||||
| final Path path = new Path(); | |||||
| path1.addPath( path ); | |||||
| return path; | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -239,7 +239,10 @@ public class WLRun extends Task | |||||
| { | { | ||||
| classpath = new Path(); | classpath = new Path(); | ||||
| } | } | ||||
| return classpath.createPath(); | |||||
| Path path1 = classpath; | |||||
| final Path path = new Path(); | |||||
| path1.addPath( path ); | |||||
| return path; | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -253,7 +256,10 @@ public class WLRun extends Task | |||||
| { | { | ||||
| weblogicClasspath = new Path(); | weblogicClasspath = new Path(); | ||||
| } | } | ||||
| return weblogicClasspath.createPath(); | |||||
| Path path1 = weblogicClasspath; | |||||
| final Path path = new Path(); | |||||
| path1.addPath( path ); | |||||
| return path; | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -122,7 +122,10 @@ public class WLStop extends Task | |||||
| { | { | ||||
| classpath = new Path(); | classpath = new Path(); | ||||
| } | } | ||||
| return classpath.createPath(); | |||||
| Path path1 = classpath; | |||||
| final Path path = new Path(); | |||||
| path1.addPath( path ); | |||||
| return path; | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -298,7 +298,10 @@ public class WeblogicDeploymentTool extends GenericDeploymentTool | |||||
| { | { | ||||
| wlClasspath = new Path(); | wlClasspath = new Path(); | ||||
| } | } | ||||
| return wlClasspath.createPath(); | |||||
| Path path1 = wlClasspath; | |||||
| final Path path = new Path(); | |||||
| path1.addPath( path ); | |||||
| return path; | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -378,7 +378,10 @@ public class WebsphereDeploymentTool | |||||
| { | { | ||||
| wasClasspath = new Path(); | wasClasspath = new Path(); | ||||
| } | } | ||||
| return wasClasspath.createPath(); | |||||
| Path path1 = wasClasspath; | |||||
| final Path path = new Path(); | |||||
| path1.addPath( path ); | |||||
| return path; | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -17,6 +17,7 @@ import org.apache.tools.ant.taskdefs.exec.Execute2; | |||||
| import org.apache.tools.ant.types.Argument; | import org.apache.tools.ant.types.Argument; | ||||
| import org.apache.tools.ant.types.CommandlineJava; | import org.apache.tools.ant.types.CommandlineJava; | ||||
| import org.apache.tools.ant.types.Path; | import org.apache.tools.ant.types.Path; | ||||
| import org.apache.tools.ant.types.PathElement; | |||||
| /** | /** | ||||
| * Taskdef for the JJTree compiler compiler. | * Taskdef for the JJTree compiler compiler. | ||||
| @@ -174,7 +175,9 @@ public class JJTree extends Task | |||||
| throw new TaskException( "Javacchome not set." ); | throw new TaskException( "Javacchome not set." ); | ||||
| } | } | ||||
| final Path classpath = cmdl.createClasspath(); | final Path classpath = cmdl.createClasspath(); | ||||
| classpath.createPathElement().setPath( javaccHome.getAbsolutePath() + | |||||
| final PathElement pathElement = new PathElement(); | |||||
| classpath.addPathElement( pathElement ); | |||||
| pathElement.setPath( javaccHome.getAbsolutePath() + | |||||
| "/JavaCC.zip" ); | "/JavaCC.zip" ); | ||||
| classpath.addJavaRuntime(); | classpath.addJavaRuntime(); | ||||
| @@ -18,6 +18,7 @@ import org.apache.tools.ant.types.Argument; | |||||
| import org.apache.tools.ant.types.Commandline; | import org.apache.tools.ant.types.Commandline; | ||||
| import org.apache.tools.ant.types.CommandlineJava; | import org.apache.tools.ant.types.CommandlineJava; | ||||
| import org.apache.tools.ant.types.Path; | import org.apache.tools.ant.types.Path; | ||||
| import org.apache.tools.ant.types.PathElement; | |||||
| import org.apache.avalon.excalibur.util.StringUtil; | import org.apache.avalon.excalibur.util.StringUtil; | ||||
| /** | /** | ||||
| @@ -228,7 +229,9 @@ public class JavaCC extends Task | |||||
| throw new TaskException( "Javacchome not set." ); | throw new TaskException( "Javacchome not set." ); | ||||
| } | } | ||||
| final Path classpath = cmdl.createClasspath(); | final Path classpath = cmdl.createClasspath(); | ||||
| classpath.createPathElement().setPath( javaccHome.getAbsolutePath() + | |||||
| final PathElement pathElement = new PathElement(); | |||||
| classpath.addPathElement( pathElement ); | |||||
| pathElement.setPath( javaccHome.getAbsolutePath() + | |||||
| "/JavaCC.zip" ); | "/JavaCC.zip" ); | ||||
| classpath.addJavaRuntime(); | classpath.addJavaRuntime(); | ||||
| @@ -131,7 +131,10 @@ public class JDependTask | |||||
| { | { | ||||
| m_compileClasspath = new Path(); | m_compileClasspath = new Path(); | ||||
| } | } | ||||
| return m_compileClasspath.createPath(); | |||||
| Path path1 = m_compileClasspath; | |||||
| final Path path = new Path(); | |||||
| path1.addPath( path ); | |||||
| return path; | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -156,7 +159,10 @@ public class JDependTask | |||||
| { | { | ||||
| m_sourcesPath = new Path(); | m_sourcesPath = new Path(); | ||||
| } | } | ||||
| return m_sourcesPath.createPath(); | |||||
| Path path1 = m_sourcesPath; | |||||
| final Path path = new Path(); | |||||
| path1.addPath( path ); | |||||
| return path; | |||||
| } | } | ||||
| public void execute() | public void execute() | ||||
| @@ -300,7 +300,10 @@ public class JspC extends MatchingTask | |||||
| { | { | ||||
| if( classpath == null ) | if( classpath == null ) | ||||
| classpath = new Path(); | classpath = new Path(); | ||||
| return classpath.createPath(); | |||||
| Path path1 = classpath; | |||||
| final Path path = new Path(); | |||||
| path1.addPath( path ); | |||||
| return path; | |||||
| } | } | ||||
| /* | /* | ||||
| @@ -348,7 +348,10 @@ public class JUnitTask extends Task | |||||
| */ | */ | ||||
| public Path createClasspath() | public Path createClasspath() | ||||
| { | { | ||||
| return commandline.createClasspath().createPath(); | |||||
| Path path1 = commandline.createClasspath(); | |||||
| final Path path = new Path(); | |||||
| path1.addPath( path ); | |||||
| return path; | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -23,6 +23,7 @@ import org.apache.tools.ant.types.Argument; | |||||
| import org.apache.tools.ant.types.CommandlineJava; | import org.apache.tools.ant.types.CommandlineJava; | ||||
| import org.apache.tools.ant.types.FileSet; | import org.apache.tools.ant.types.FileSet; | ||||
| import org.apache.tools.ant.types.Path; | import org.apache.tools.ant.types.Path; | ||||
| import org.apache.tools.ant.types.PathElement; | |||||
| /** | /** | ||||
| * Somewhat abstract framework to be used for other metama 2.0 tasks. This | * Somewhat abstract framework to be used for other metama 2.0 tasks. This | ||||
| @@ -197,7 +198,9 @@ public abstract class AbstractMetamataTask | |||||
| // set the classpath as the jar file | // set the classpath as the jar file | ||||
| File jar = getMetamataJar( m_metamataHome ); | File jar = getMetamataJar( m_metamataHome ); | ||||
| final Path classPath = m_cmdl.createClasspath(); | final Path classPath = m_cmdl.createClasspath(); | ||||
| classPath.createPathElement().setLocation( jar ); | |||||
| final PathElement pathElement = new PathElement(); | |||||
| classPath.addPathElement( pathElement ); | |||||
| pathElement.setLocation( jar ); | |||||
| // set the metamata.home property | // set the metamata.home property | ||||
| final Argument vmArgs = m_cmdl.createVmArgument(); | final Argument vmArgs = m_cmdl.createVmArgument(); | ||||
| @@ -19,6 +19,7 @@ import org.apache.tools.ant.taskdefs.exec.Execute2; | |||||
| import org.apache.tools.ant.types.Argument; | import org.apache.tools.ant.types.Argument; | ||||
| import org.apache.tools.ant.types.CommandlineJava; | import org.apache.tools.ant.types.CommandlineJava; | ||||
| import org.apache.tools.ant.types.Path; | import org.apache.tools.ant.types.Path; | ||||
| import org.apache.tools.ant.types.PathElement; | |||||
| /** | /** | ||||
| * Simple Metamata MParse task based on the original written by <a | * Simple Metamata MParse task based on the original written by <a | ||||
| @@ -203,7 +204,9 @@ public class MParse | |||||
| final Path classPath = m_cmdl.createClasspath(); | final Path classPath = m_cmdl.createClasspath(); | ||||
| for( int i = 0; i < jars.length; i++ ) | for( int i = 0; i < jars.length; i++ ) | ||||
| { | { | ||||
| classPath.createPathElement().setLocation( jars[ i ] ); | |||||
| final PathElement pathElement = new PathElement(); | |||||
| classPath.addPathElement( pathElement ); | |||||
| pathElement.setLocation( jars[ i ] ); | |||||
| } | } | ||||
| // set the metamata.home property | // set the metamata.home property | ||||
| @@ -203,7 +203,10 @@ public class CovReport extends Task | |||||
| { | { | ||||
| coveragePath = new Path(); | coveragePath = new Path(); | ||||
| } | } | ||||
| return coveragePath.createPath(); | |||||
| Path path1 = coveragePath; | |||||
| final Path path = new Path(); | |||||
| path1.addPath( path ); | |||||
| return path; | |||||
| } | } | ||||
| public Reference createReference() | public Reference createReference() | ||||
| @@ -221,7 +224,10 @@ public class CovReport extends Task | |||||
| { | { | ||||
| sourcePath = new Path(); | sourcePath = new Path(); | ||||
| } | } | ||||
| return sourcePath.createPath(); | |||||
| Path path1 = sourcePath; | |||||
| final Path path = new Path(); | |||||
| path1.addPath( path ); | |||||
| return path; | |||||
| } | } | ||||
| public void execute() | public void execute() | ||||
| @@ -289,7 +295,10 @@ public class CovReport extends Task | |||||
| if( sourcePath == null ) | if( sourcePath == null ) | ||||
| { | { | ||||
| sourcePath = new Path(); | sourcePath = new Path(); | ||||
| sourcePath.createPath().setLocation( getBaseDirectory() ); | |||||
| Path path1 = sourcePath; | |||||
| final Path path = new Path(); | |||||
| path1.addPath( path ); | |||||
| path.setLocation( getBaseDirectory() ); | |||||
| } | } | ||||
| v.add( "-sourcepath=" + sourcePath ); | v.add( "-sourcepath=" + sourcePath ); | ||||
| @@ -362,7 +371,10 @@ public class CovReport extends Task | |||||
| { | { | ||||
| classPath = new Path(); | classPath = new Path(); | ||||
| } | } | ||||
| return classPath.createPath(); | |||||
| Path path1 = classPath; | |||||
| final Path path = new Path(); | |||||
| path1.addPath( path ); | |||||
| return path; | |||||
| } | } | ||||
| public ReportFilters createFilters() | public ReportFilters createFilters() | ||||
| @@ -187,7 +187,10 @@ public class Coverage | |||||
| */ | */ | ||||
| public Path createClasspath() | public Path createClasspath() | ||||
| { | { | ||||
| return cmdlJava.createClasspath().createPath(); | |||||
| Path path1 = cmdlJava.createClasspath(); | |||||
| final Path path = new Path(); | |||||
| path1.addPath( path ); | |||||
| return path; | |||||
| } | } | ||||
| public Filters createFilters() | public Filters createFilters() | ||||
| @@ -12,7 +12,8 @@ import java.io.IOException; | |||||
| import java.net.URL; | import java.net.URL; | ||||
| import java.util.ArrayList; | import java.util.ArrayList; | ||||
| import java.util.Locale; | import java.util.Locale; | ||||
| import org.apache.avalon.excalibur.io.FileUtil; | |||||
| import org.apache.avalon.framework.logger.AbstractLogEnabled; | |||||
| import org.apache.avalon.framework.logger.Logger; | |||||
| import org.apache.myrmidon.api.TaskException; | import org.apache.myrmidon.api.TaskException; | ||||
| import org.apache.tools.ant.ProjectComponent; | import org.apache.tools.ant.ProjectComponent; | ||||
| import org.apache.tools.ant.util.FileUtils; | import org.apache.tools.ant.util.FileUtils; | ||||
| @@ -54,7 +55,7 @@ public class Path | |||||
| { | { | ||||
| public final static Path systemClasspath = createSystemClasspath(); | public final static Path systemClasspath = createSystemClasspath(); | ||||
| private ArrayList elements; | |||||
| private ArrayList m_elements; | |||||
| private static Path createSystemClasspath() | private static Path createSystemClasspath() | ||||
| { | { | ||||
| @@ -76,90 +77,20 @@ public class Path | |||||
| throws TaskException | throws TaskException | ||||
| { | { | ||||
| this(); | this(); | ||||
| createPathElement().setPath( path ); | |||||
| final PathElement pathElement = new PathElement(); | |||||
| addPathElement( pathElement ); | |||||
| pathElement.setPath( path ); | |||||
| } | } | ||||
| public Path() | public Path() | ||||
| { | { | ||||
| elements = new ArrayList(); | |||||
| } | |||||
| /** | |||||
| * Returns its argument with all file separator characters replaced so that | |||||
| * they match the local OS conventions. | |||||
| */ | |||||
| protected static String translateFile( final String source ) | |||||
| { | |||||
| if( source == null ) | |||||
| return ""; | |||||
| final StringBuffer result = new StringBuffer( source ); | |||||
| for( int i = 0; i < result.length(); i++ ) | |||||
| { | |||||
| translateFileSep( result, i ); | |||||
| } | |||||
| return result.toString(); | |||||
| } | |||||
| /** | |||||
| * Splits a PATH (with : or ; as separators) into its parts. | |||||
| */ | |||||
| protected String[] translatePath( final File baseDirectory, String source ) | |||||
| { | |||||
| final ArrayList result = new ArrayList(); | |||||
| if( source == null ) | |||||
| return new String[ 0 ]; | |||||
| final String[] elements = FileUtils.parsePath( source ); | |||||
| StringBuffer element = new StringBuffer(); | |||||
| for( int i = 0; i < elements.length; i++ ) | |||||
| { | |||||
| element.setLength( 0 ); | |||||
| final String pathElement = elements[ i ]; | |||||
| try | |||||
| { | |||||
| element.append( resolveFile( baseDirectory, pathElement ) ); | |||||
| } | |||||
| catch( TaskException e ) | |||||
| { | |||||
| final String message = | |||||
| "Dropping path element " + pathElement + " as it is not valid relative to the project"; | |||||
| getLogger().debug( message ); | |||||
| } | |||||
| for( int j = 0; j < element.length(); j++ ) | |||||
| { | |||||
| translateFileSep( element, j ); | |||||
| } | |||||
| result.add( element.toString() ); | |||||
| } | |||||
| return (String[])result.toArray( new String[ result.size() ] ); | |||||
| } | |||||
| /** | |||||
| * Translates all occurrences of / or \ to correct separator of the current | |||||
| * platform and returns whether it had to do any replacements. | |||||
| * | |||||
| * @param buffer Description of Parameter | |||||
| * @param pos Description of Parameter | |||||
| * @return Description of the Returned Value | |||||
| */ | |||||
| private static boolean translateFileSep( StringBuffer buffer, int pos ) | |||||
| { | |||||
| if( buffer.charAt( pos ) == '/' || buffer.charAt( pos ) == '\\' ) | |||||
| { | |||||
| buffer.setCharAt( pos, File.separatorChar ); | |||||
| return true; | |||||
| } | |||||
| return false; | |||||
| m_elements = new ArrayList(); | |||||
| } | } | ||||
| /** | /** | ||||
| * Adds a String to the ArrayList if it isn't already included. | * Adds a String to the ArrayList if it isn't already included. | ||||
| */ | */ | ||||
| private static void addUnlessPresent( final ArrayList list, final String entry ) | |||||
| private void addUnlessPresent( final ArrayList list, final String entry ) | |||||
| { | { | ||||
| if( !list.contains( entry ) ) | if( !list.contains( entry ) ) | ||||
| { | { | ||||
| @@ -167,22 +98,6 @@ public class Path | |||||
| } | } | ||||
| } | } | ||||
| /** | |||||
| * Resolve a filename with Project's help - if we know one that is. <p> | |||||
| * | |||||
| * Assume the filename is absolute if project is null.</p> | |||||
| */ | |||||
| private static String resolveFile( final File baseDirectory, final String relativeName ) | |||||
| throws TaskException | |||||
| { | |||||
| if( null != baseDirectory ) | |||||
| { | |||||
| final File file = FileUtil.resolveFile( baseDirectory, relativeName ); | |||||
| return file.getAbsolutePath(); | |||||
| } | |||||
| return relativeName; | |||||
| } | |||||
| /** | /** | ||||
| * Adds a element definition to the path. | * Adds a element definition to the path. | ||||
| * | * | ||||
| @@ -191,7 +106,9 @@ public class Path | |||||
| */ | */ | ||||
| public void setLocation( final File location ) | public void setLocation( final File location ) | ||||
| { | { | ||||
| createPathElement().setLocation( location ); | |||||
| final PathElement pathElement = new PathElement(); | |||||
| addPathElement( pathElement ); | |||||
| pathElement.setLocation( location ); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -201,7 +118,9 @@ public class Path | |||||
| */ | */ | ||||
| public void setPath( String path ) | public void setPath( String path ) | ||||
| { | { | ||||
| createPathElement().setPath( path ); | |||||
| final PathElement pathElement = new PathElement(); | |||||
| addPathElement( pathElement ); | |||||
| pathElement.setPath( path ); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -267,7 +186,7 @@ public class Path | |||||
| */ | */ | ||||
| public void addFileset( final FileSet fileSet ) | public void addFileset( final FileSet fileSet ) | ||||
| { | { | ||||
| elements.add( fileSet ); | |||||
| m_elements.add( fileSet ); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -334,9 +253,9 @@ public class Path | |||||
| for( int i = 0; i < list.length; i++ ) | for( int i = 0; i < list.length; i++ ) | ||||
| { | { | ||||
| final String file = list[ i ]; | final String file = list[ i ]; | ||||
| if( elements.contains( file ) ) | |||||
| if( m_elements.contains( file ) ) | |||||
| { | { | ||||
| elements.add( file ); | |||||
| m_elements.add( file ); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -414,21 +333,17 @@ public class Path | |||||
| * @return Description of the Returned Value | * @return Description of the Returned Value | ||||
| * @exception TaskException Description of Exception | * @exception TaskException Description of Exception | ||||
| */ | */ | ||||
| public Path createPath() | |||||
| public void addPath( final Path path ) | |||||
| { | { | ||||
| final Path other = new Path(); | |||||
| elements.add( other ); | |||||
| return other; | |||||
| m_elements.add( path ); | |||||
| } | } | ||||
| /** | /** | ||||
| * Creates the nested <code><pathelement></code> element. | * Creates the nested <code><pathelement></code> element. | ||||
| */ | */ | ||||
| public PathElement createPathElement() | |||||
| public void addPathElement( final PathElement pathElement ) | |||||
| { | { | ||||
| final PathElement pathElement = new PathElement(); | |||||
| elements.add( pathElement ); | |||||
| return pathElement; | |||||
| m_elements.add( pathElement ); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -437,10 +352,10 @@ public class Path | |||||
| public String[] list() | public String[] list() | ||||
| throws TaskException | throws TaskException | ||||
| { | { | ||||
| ArrayList result = new ArrayList( 2 * elements.size() ); | |||||
| for( int i = 0; i < elements.size(); i++ ) | |||||
| ArrayList result = new ArrayList( 2 * m_elements.size() ); | |||||
| for( int i = 0; i < m_elements.size(); i++ ) | |||||
| { | { | ||||
| Object o = elements.get( i ); | |||||
| Object o = m_elements.get( i ); | |||||
| if( o instanceof String ) | if( o instanceof String ) | ||||
| { | { | ||||
| // obtained via append | // obtained via append | ||||
| @@ -448,7 +363,9 @@ public class Path | |||||
| } | } | ||||
| else if( o instanceof PathElement ) | else if( o instanceof PathElement ) | ||||
| { | { | ||||
| String[] parts = ( (PathElement)o ).getParts(); | |||||
| final File baseDirectory = getBaseDirectory(); | |||||
| final PathElement element = (PathElement)o; | |||||
| final String[] parts = element.getParts( baseDirectory, getLogger() ); | |||||
| if( parts == null ) | if( parts == null ) | ||||
| { | { | ||||
| throw new NullPointerException( "You must either set location or path on <pathelement>" ); | throw new NullPointerException( "You must either set location or path on <pathelement>" ); | ||||
| @@ -477,7 +394,7 @@ public class Path | |||||
| { | { | ||||
| File f = new File( dir, s[ j ] ); | File f = new File( dir, s[ j ] ); | ||||
| String absolutePath = f.getAbsolutePath(); | String absolutePath = f.getAbsolutePath(); | ||||
| addUnlessPresent( result, translateFile( absolutePath ) ); | |||||
| addUnlessPresent( result, FileUtils.translateFile( absolutePath ) ); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -552,26 +469,4 @@ public class Path | |||||
| } | } | ||||
| } | } | ||||
| /** | |||||
| * Helper class, holds the nested <code><pathelement></code> values. | |||||
| */ | |||||
| public class PathElement | |||||
| { | |||||
| private String[] m_parts; | |||||
| public void setLocation( File loc ) | |||||
| { | |||||
| m_parts = new String[]{translateFile( loc.getAbsolutePath() )}; | |||||
| } | |||||
| public void setPath( String path ) | |||||
| { | |||||
| m_parts = translatePath( getProject().getBaseDir(), path ); | |||||
| } | |||||
| public String[] getParts() | |||||
| { | |||||
| return m_parts; | |||||
| } | |||||
| } | |||||
| } | } | ||||
| @@ -0,0 +1,35 @@ | |||||
| /* | |||||
| * Copyright (C) The Apache Software Foundation. All rights reserved. | |||||
| * | |||||
| * This software is published under the terms of the Apache Software License | |||||
| * version 1.1, a copy of which has been included with this distribution in | |||||
| * the LICENSE.txt file. | |||||
| */ | |||||
| package org.apache.tools.ant.types; | |||||
| import java.io.File; | |||||
| import org.apache.tools.ant.util.FileUtils; | |||||
| import org.apache.avalon.framework.logger.Logger; | |||||
| /** | |||||
| * Helper class, holds the nested <code><pathelement></code> values. | |||||
| */ | |||||
| public class PathElement | |||||
| { | |||||
| private String m_path; | |||||
| public void setLocation( final File location ) | |||||
| { | |||||
| m_path = FileUtils.translateFile( location.getAbsolutePath() ); | |||||
| } | |||||
| public void setPath( String path ) | |||||
| { | |||||
| m_path = path; | |||||
| } | |||||
| protected String[] getParts( final File baseDirectory, final Logger logger ) | |||||
| { | |||||
| return FileUtils.translatePath( baseDirectory, m_path, logger ); | |||||
| } | |||||
| } | |||||
| @@ -15,9 +15,11 @@ import java.io.FileOutputStream; | |||||
| import java.io.FileReader; | import java.io.FileReader; | ||||
| import java.io.FileWriter; | import java.io.FileWriter; | ||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.util.ArrayList; | |||||
| import java.util.Stack; | import java.util.Stack; | ||||
| import java.util.StringTokenizer; | import java.util.StringTokenizer; | ||||
| import java.util.ArrayList; | |||||
| import org.apache.avalon.excalibur.io.FileUtil; | |||||
| import org.apache.avalon.framework.logger.Logger; | |||||
| import org.apache.myrmidon.api.TaskException; | import org.apache.myrmidon.api.TaskException; | ||||
| import org.apache.tools.ant.types.FilterSetCollection; | import org.apache.tools.ant.types.FilterSetCollection; | ||||
| @@ -377,5 +379,95 @@ public class FileUtils | |||||
| final String[] args = new String[ v.size() ]; | final String[] args = new String[ v.size() ]; | ||||
| return (String[])v.toArray( args ); | return (String[])v.toArray( args ); | ||||
| } | } | ||||
| /** | |||||
| * Returns its argument with all file separator characters replaced so that | |||||
| * they match the local OS conventions. | |||||
| */ | |||||
| public static String translateFile( final String source ) | |||||
| { | |||||
| if( source == null ) | |||||
| return ""; | |||||
| final StringBuffer result = new StringBuffer( source ); | |||||
| for( int i = 0; i < result.length(); i++ ) | |||||
| { | |||||
| translateFileSep( result, i ); | |||||
| } | |||||
| return result.toString(); | |||||
| } | |||||
| /** | |||||
| * Translates all occurrences of / or \ to correct separator of the current | |||||
| * platform and returns whether it had to do any replacements. | |||||
| * | |||||
| * @param buffer Description of Parameter | |||||
| * @param pos Description of Parameter | |||||
| * @return Description of the Returned Value | |||||
| */ | |||||
| public static boolean translateFileSep( StringBuffer buffer, int pos ) | |||||
| { | |||||
| if( buffer.charAt( pos ) == '/' || buffer.charAt( pos ) == '\\' ) | |||||
| { | |||||
| buffer.setCharAt( pos, File.separatorChar ); | |||||
| return true; | |||||
| } | |||||
| return false; | |||||
| } | |||||
| /** | |||||
| * Splits a PATH (with : or ; as separators) into its parts. | |||||
| */ | |||||
| public static String[] translatePath( final File baseDirectory, | |||||
| String source, | |||||
| final Logger logger ) | |||||
| { | |||||
| final ArrayList result = new ArrayList(); | |||||
| if( source == null ) | |||||
| return new String[ 0 ]; | |||||
| final String[] elements = parsePath( source ); | |||||
| StringBuffer element = new StringBuffer(); | |||||
| for( int i = 0; i < elements.length; i++ ) | |||||
| { | |||||
| element.setLength( 0 ); | |||||
| final String pathElement = elements[ i ]; | |||||
| try | |||||
| { | |||||
| element.append( resolveFile( baseDirectory, pathElement ) ); | |||||
| } | |||||
| catch( TaskException e ) | |||||
| { | |||||
| final String message = | |||||
| "Dropping path element " + pathElement + " as it is not valid relative to the project"; | |||||
| logger.debug( message ); | |||||
| } | |||||
| for( int j = 0; j < element.length(); j++ ) | |||||
| { | |||||
| translateFileSep( element, j ); | |||||
| } | |||||
| result.add( element.toString() ); | |||||
| } | |||||
| return (String[])result.toArray( new String[ result.size() ] ); | |||||
| } | |||||
| /** | |||||
| * Resolve a filename with Project's help - if we know one that is. <p> | |||||
| * | |||||
| * Assume the filename is absolute if project is null.</p> | |||||
| */ | |||||
| public static String resolveFile( final File baseDirectory, final String relativeName ) | |||||
| throws TaskException | |||||
| { | |||||
| if( null != baseDirectory ) | |||||
| { | |||||
| final File file = FileUtil.resolveFile( baseDirectory, relativeName ); | |||||
| return file.getAbsolutePath(); | |||||
| } | |||||
| return relativeName; | |||||
| } | |||||
| } | } | ||||
| @@ -152,6 +152,9 @@ public class Mapper | |||||
| { | { | ||||
| m_classpath = new Path(); | m_classpath = new Path(); | ||||
| } | } | ||||
| return m_classpath.createPath(); | |||||
| Path path1 = m_classpath; | |||||
| final Path path = new Path(); | |||||
| path1.addPath( path ); | |||||
| return path; | |||||
| } | } | ||||
| } | } | ||||
| @@ -92,7 +92,10 @@ public class Available | |||||
| { | { | ||||
| m_classpath = new Path(); | m_classpath = new Path(); | ||||
| } | } | ||||
| return m_classpath.createPath(); | |||||
| Path path1 = m_classpath; | |||||
| final Path path = new Path(); | |||||
| path1.addPath( path ); | |||||
| return path; | |||||
| } | } | ||||
| public Path createFilepath() | public Path createFilepath() | ||||
| @@ -102,7 +105,10 @@ public class Available | |||||
| { | { | ||||
| m_filepath = new Path(); | m_filepath = new Path(); | ||||
| } | } | ||||
| return m_filepath.createPath(); | |||||
| Path path1 = m_filepath; | |||||
| final Path path = new Path(); | |||||
| path1.addPath( path ); | |||||
| return path; | |||||
| } | } | ||||
| public boolean eval() | public boolean eval() | ||||
| @@ -117,7 +117,10 @@ public class Java | |||||
| public Path createClasspath() | public Path createClasspath() | ||||
| throws TaskException | throws TaskException | ||||
| { | { | ||||
| return m_cmdl.createClasspath().createPath(); | |||||
| Path path1 = m_cmdl.createClasspath(); | |||||
| final Path path = new Path(); | |||||
| path1.addPath( path ); | |||||
| return path; | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -642,7 +642,10 @@ public class Javac extends MatchingTask | |||||
| { | { | ||||
| bootclasspath = new Path(); | bootclasspath = new Path(); | ||||
| } | } | ||||
| return bootclasspath.createPath(); | |||||
| Path path1 = bootclasspath; | |||||
| final Path path = new Path(); | |||||
| path1.addPath( path ); | |||||
| return path; | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -657,7 +660,10 @@ public class Javac extends MatchingTask | |||||
| { | { | ||||
| compileClasspath = new Path(); | compileClasspath = new Path(); | ||||
| } | } | ||||
| return compileClasspath.createPath(); | |||||
| Path path1 = compileClasspath; | |||||
| final Path path = new Path(); | |||||
| path1.addPath( path ); | |||||
| return path; | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -685,7 +691,10 @@ public class Javac extends MatchingTask | |||||
| { | { | ||||
| extdirs = new Path(); | extdirs = new Path(); | ||||
| } | } | ||||
| return extdirs.createPath(); | |||||
| Path path1 = extdirs; | |||||
| final Path path = new Path(); | |||||
| path1.addPath( path ); | |||||
| return path; | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -700,7 +709,10 @@ public class Javac extends MatchingTask | |||||
| { | { | ||||
| src = new Path(); | src = new Path(); | ||||
| } | } | ||||
| return src.createPath(); | |||||
| Path path1 = src; | |||||
| final Path path = new Path(); | |||||
| path1.addPath( path ); | |||||
| return path; | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -105,7 +105,10 @@ public class PathConvert extends Task | |||||
| { | { | ||||
| m_path = new Path(); | m_path = new Path(); | ||||
| } | } | ||||
| return m_path.createPath(); | |||||
| Path path1 = m_path; | |||||
| final Path path = new Path(); | |||||
| path1.addPath( path ); | |||||
| return path; | |||||
| } | } | ||||
| public void execute() | public void execute() | ||||
| @@ -75,7 +75,10 @@ public class Property | |||||
| { | { | ||||
| m_classpath = new Path(); | m_classpath = new Path(); | ||||
| } | } | ||||
| return m_classpath.createPath(); | |||||
| Path path1 = m_classpath; | |||||
| final Path path = new Path(); | |||||
| path1.addPath( path ); | |||||
| return path; | |||||
| } | } | ||||
| public void execute() | public void execute() | ||||
| @@ -471,7 +471,10 @@ public class Rmic extends MatchingTask | |||||
| { | { | ||||
| compileClasspath = new Path(); | compileClasspath = new Path(); | ||||
| } | } | ||||
| return compileClasspath.createPath(); | |||||
| Path path1 = compileClasspath; | |||||
| final Path path = new Path(); | |||||
| path1.addPath( path ); | |||||
| return path; | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -486,7 +489,10 @@ public class Rmic extends MatchingTask | |||||
| { | { | ||||
| extdirs = new Path(); | extdirs = new Path(); | ||||
| } | } | ||||
| return extdirs.createPath(); | |||||
| Path path1 = extdirs; | |||||
| final Path path = new Path(); | |||||
| path1.addPath( path ); | |||||
| return path; | |||||
| } | } | ||||
| public void execute() | public void execute() | ||||
| @@ -357,7 +357,10 @@ public class SQLExec | |||||
| { | { | ||||
| this.classpath = new Path(); | this.classpath = new Path(); | ||||
| } | } | ||||
| return this.classpath.createPath(); | |||||
| Path path1 = this.classpath; | |||||
| final Path path = new Path(); | |||||
| path1.addPath( path ); | |||||
| return path; | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -65,6 +65,9 @@ public class DocletInfo | |||||
| { | { | ||||
| m_path = new Path(); | m_path = new Path(); | ||||
| } | } | ||||
| return m_path.createPath(); | |||||
| Path path1 = m_path; | |||||
| final Path path = new Path(); | |||||
| path1.addPath( path ); | |||||
| return path; | |||||
| } | } | ||||
| } | } | ||||
| @@ -471,7 +471,10 @@ public class Javadoc | |||||
| { | { | ||||
| m_bootclasspath = new Path(); | m_bootclasspath = new Path(); | ||||
| } | } | ||||
| return m_bootclasspath.createPath(); | |||||
| Path path1 = m_bootclasspath; | |||||
| final Path path = new Path(); | |||||
| path1.addPath( path ); | |||||
| return path; | |||||
| } | } | ||||
| public Path createClasspath() | public Path createClasspath() | ||||
| @@ -481,7 +484,10 @@ public class Javadoc | |||||
| { | { | ||||
| m_classpath = new Path(); | m_classpath = new Path(); | ||||
| } | } | ||||
| return m_classpath.createPath(); | |||||
| Path path1 = m_classpath; | |||||
| final Path path = new Path(); | |||||
| path1.addPath( path ); | |||||
| return path; | |||||
| } | } | ||||
| public DocletInfo createDoclet() | public DocletInfo createDoclet() | ||||
| @@ -511,7 +517,10 @@ public class Javadoc | |||||
| { | { | ||||
| m_sourcePath = new Path(); | m_sourcePath = new Path(); | ||||
| } | } | ||||
| return m_sourcePath.createPath(); | |||||
| Path path1 = m_sourcePath; | |||||
| final Path path = new Path(); | |||||
| path1.addPath( path ); | |||||
| return path; | |||||
| } | } | ||||
| public void execute() | public void execute() | ||||
| @@ -92,7 +92,10 @@ public class ANTLR extends Task | |||||
| */ | */ | ||||
| public Path createClasspath() | public Path createClasspath() | ||||
| { | { | ||||
| return commandline.createClasspath().createPath(); | |||||
| Path path1 = commandline.createClasspath(); | |||||
| final Path path = new Path(); | |||||
| path1.addPath( path ); | |||||
| return path; | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -155,7 +155,10 @@ public class Javah | |||||
| { | { | ||||
| m_bootclasspath = new Path(); | m_bootclasspath = new Path(); | ||||
| } | } | ||||
| return m_bootclasspath.createPath(); | |||||
| Path path1 = m_bootclasspath; | |||||
| final Path path = new Path(); | |||||
| path1.addPath( path ); | |||||
| return path; | |||||
| } | } | ||||
| public ClassArgument createClass() | public ClassArgument createClass() | ||||
| @@ -172,7 +175,10 @@ public class Javah | |||||
| { | { | ||||
| m_classpath = new Path(); | m_classpath = new Path(); | ||||
| } | } | ||||
| return m_classpath.createPath(); | |||||
| Path path1 = m_classpath; | |||||
| final Path path = new Path(); | |||||
| path1.addPath( path ); | |||||
| return path; | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -174,7 +174,10 @@ public class Depend extends MatchingTask | |||||
| { | { | ||||
| dependClasspath = new Path(); | dependClasspath = new Path(); | ||||
| } | } | ||||
| return dependClasspath.createPath(); | |||||
| Path path1 = dependClasspath; | |||||
| final Path path = new Path(); | |||||
| path1.addPath( path ); | |||||
| return path; | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -92,7 +92,10 @@ public class BorlandGenerateClient extends Task | |||||
| { | { | ||||
| this.classpath = new Path(); | this.classpath = new Path(); | ||||
| } | } | ||||
| return this.classpath.createPath(); | |||||
| Path path1 = this.classpath; | |||||
| final Path path = new Path(); | |||||
| path1.addPath( path ); | |||||
| return path; | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -256,7 +256,10 @@ public class EjbJar extends MatchingTask | |||||
| { | { | ||||
| config.classpath = new Path(); | config.classpath = new Path(); | ||||
| } | } | ||||
| return config.classpath.createPath(); | |||||
| Path path1 = config.classpath; | |||||
| final Path path = new Path(); | |||||
| path1.addPath( path ); | |||||
| return path; | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -200,7 +200,10 @@ public class GenericDeploymentTool | |||||
| { | { | ||||
| classpath = new Path(); | classpath = new Path(); | ||||
| } | } | ||||
| return classpath.createPath(); | |||||
| Path path1 = classpath; | |||||
| final Path path = new Path(); | |||||
| path1.addPath( path ); | |||||
| return path; | |||||
| } | } | ||||
| public void processDescriptor( String descriptorFileName, SAXParser saxParser ) | public void processDescriptor( String descriptorFileName, SAXParser saxParser ) | ||||
| @@ -178,7 +178,10 @@ public class IPlanetEjbcTask extends Task | |||||
| { | { | ||||
| classpath = new Path(); | classpath = new Path(); | ||||
| } | } | ||||
| return classpath.createPath(); | |||||
| Path path1 = classpath; | |||||
| final Path path = new Path(); | |||||
| path1.addPath( path ); | |||||
| return path; | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -239,7 +239,10 @@ public class WLRun extends Task | |||||
| { | { | ||||
| classpath = new Path(); | classpath = new Path(); | ||||
| } | } | ||||
| return classpath.createPath(); | |||||
| Path path1 = classpath; | |||||
| final Path path = new Path(); | |||||
| path1.addPath( path ); | |||||
| return path; | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -253,7 +256,10 @@ public class WLRun extends Task | |||||
| { | { | ||||
| weblogicClasspath = new Path(); | weblogicClasspath = new Path(); | ||||
| } | } | ||||
| return weblogicClasspath.createPath(); | |||||
| Path path1 = weblogicClasspath; | |||||
| final Path path = new Path(); | |||||
| path1.addPath( path ); | |||||
| return path; | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -122,7 +122,10 @@ public class WLStop extends Task | |||||
| { | { | ||||
| classpath = new Path(); | classpath = new Path(); | ||||
| } | } | ||||
| return classpath.createPath(); | |||||
| Path path1 = classpath; | |||||
| final Path path = new Path(); | |||||
| path1.addPath( path ); | |||||
| return path; | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -298,7 +298,10 @@ public class WeblogicDeploymentTool extends GenericDeploymentTool | |||||
| { | { | ||||
| wlClasspath = new Path(); | wlClasspath = new Path(); | ||||
| } | } | ||||
| return wlClasspath.createPath(); | |||||
| Path path1 = wlClasspath; | |||||
| final Path path = new Path(); | |||||
| path1.addPath( path ); | |||||
| return path; | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -378,7 +378,10 @@ public class WebsphereDeploymentTool | |||||
| { | { | ||||
| wasClasspath = new Path(); | wasClasspath = new Path(); | ||||
| } | } | ||||
| return wasClasspath.createPath(); | |||||
| Path path1 = wasClasspath; | |||||
| final Path path = new Path(); | |||||
| path1.addPath( path ); | |||||
| return path; | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -17,6 +17,7 @@ import org.apache.tools.ant.taskdefs.exec.Execute2; | |||||
| import org.apache.tools.ant.types.Argument; | import org.apache.tools.ant.types.Argument; | ||||
| import org.apache.tools.ant.types.CommandlineJava; | import org.apache.tools.ant.types.CommandlineJava; | ||||
| import org.apache.tools.ant.types.Path; | import org.apache.tools.ant.types.Path; | ||||
| import org.apache.tools.ant.types.PathElement; | |||||
| /** | /** | ||||
| * Taskdef for the JJTree compiler compiler. | * Taskdef for the JJTree compiler compiler. | ||||
| @@ -174,7 +175,9 @@ public class JJTree extends Task | |||||
| throw new TaskException( "Javacchome not set." ); | throw new TaskException( "Javacchome not set." ); | ||||
| } | } | ||||
| final Path classpath = cmdl.createClasspath(); | final Path classpath = cmdl.createClasspath(); | ||||
| classpath.createPathElement().setPath( javaccHome.getAbsolutePath() + | |||||
| final PathElement pathElement = new PathElement(); | |||||
| classpath.addPathElement( pathElement ); | |||||
| pathElement.setPath( javaccHome.getAbsolutePath() + | |||||
| "/JavaCC.zip" ); | "/JavaCC.zip" ); | ||||
| classpath.addJavaRuntime(); | classpath.addJavaRuntime(); | ||||
| @@ -18,6 +18,7 @@ import org.apache.tools.ant.types.Argument; | |||||
| import org.apache.tools.ant.types.Commandline; | import org.apache.tools.ant.types.Commandline; | ||||
| import org.apache.tools.ant.types.CommandlineJava; | import org.apache.tools.ant.types.CommandlineJava; | ||||
| import org.apache.tools.ant.types.Path; | import org.apache.tools.ant.types.Path; | ||||
| import org.apache.tools.ant.types.PathElement; | |||||
| import org.apache.avalon.excalibur.util.StringUtil; | import org.apache.avalon.excalibur.util.StringUtil; | ||||
| /** | /** | ||||
| @@ -228,7 +229,9 @@ public class JavaCC extends Task | |||||
| throw new TaskException( "Javacchome not set." ); | throw new TaskException( "Javacchome not set." ); | ||||
| } | } | ||||
| final Path classpath = cmdl.createClasspath(); | final Path classpath = cmdl.createClasspath(); | ||||
| classpath.createPathElement().setPath( javaccHome.getAbsolutePath() + | |||||
| final PathElement pathElement = new PathElement(); | |||||
| classpath.addPathElement( pathElement ); | |||||
| pathElement.setPath( javaccHome.getAbsolutePath() + | |||||
| "/JavaCC.zip" ); | "/JavaCC.zip" ); | ||||
| classpath.addJavaRuntime(); | classpath.addJavaRuntime(); | ||||
| @@ -131,7 +131,10 @@ public class JDependTask | |||||
| { | { | ||||
| m_compileClasspath = new Path(); | m_compileClasspath = new Path(); | ||||
| } | } | ||||
| return m_compileClasspath.createPath(); | |||||
| Path path1 = m_compileClasspath; | |||||
| final Path path = new Path(); | |||||
| path1.addPath( path ); | |||||
| return path; | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -156,7 +159,10 @@ public class JDependTask | |||||
| { | { | ||||
| m_sourcesPath = new Path(); | m_sourcesPath = new Path(); | ||||
| } | } | ||||
| return m_sourcesPath.createPath(); | |||||
| Path path1 = m_sourcesPath; | |||||
| final Path path = new Path(); | |||||
| path1.addPath( path ); | |||||
| return path; | |||||
| } | } | ||||
| public void execute() | public void execute() | ||||
| @@ -300,7 +300,10 @@ public class JspC extends MatchingTask | |||||
| { | { | ||||
| if( classpath == null ) | if( classpath == null ) | ||||
| classpath = new Path(); | classpath = new Path(); | ||||
| return classpath.createPath(); | |||||
| Path path1 = classpath; | |||||
| final Path path = new Path(); | |||||
| path1.addPath( path ); | |||||
| return path; | |||||
| } | } | ||||
| /* | /* | ||||
| @@ -348,7 +348,10 @@ public class JUnitTask extends Task | |||||
| */ | */ | ||||
| public Path createClasspath() | public Path createClasspath() | ||||
| { | { | ||||
| return commandline.createClasspath().createPath(); | |||||
| Path path1 = commandline.createClasspath(); | |||||
| final Path path = new Path(); | |||||
| path1.addPath( path ); | |||||
| return path; | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -23,6 +23,7 @@ import org.apache.tools.ant.types.Argument; | |||||
| import org.apache.tools.ant.types.CommandlineJava; | import org.apache.tools.ant.types.CommandlineJava; | ||||
| import org.apache.tools.ant.types.FileSet; | import org.apache.tools.ant.types.FileSet; | ||||
| import org.apache.tools.ant.types.Path; | import org.apache.tools.ant.types.Path; | ||||
| import org.apache.tools.ant.types.PathElement; | |||||
| /** | /** | ||||
| * Somewhat abstract framework to be used for other metama 2.0 tasks. This | * Somewhat abstract framework to be used for other metama 2.0 tasks. This | ||||
| @@ -197,7 +198,9 @@ public abstract class AbstractMetamataTask | |||||
| // set the classpath as the jar file | // set the classpath as the jar file | ||||
| File jar = getMetamataJar( m_metamataHome ); | File jar = getMetamataJar( m_metamataHome ); | ||||
| final Path classPath = m_cmdl.createClasspath(); | final Path classPath = m_cmdl.createClasspath(); | ||||
| classPath.createPathElement().setLocation( jar ); | |||||
| final PathElement pathElement = new PathElement(); | |||||
| classPath.addPathElement( pathElement ); | |||||
| pathElement.setLocation( jar ); | |||||
| // set the metamata.home property | // set the metamata.home property | ||||
| final Argument vmArgs = m_cmdl.createVmArgument(); | final Argument vmArgs = m_cmdl.createVmArgument(); | ||||
| @@ -19,6 +19,7 @@ import org.apache.tools.ant.taskdefs.exec.Execute2; | |||||
| import org.apache.tools.ant.types.Argument; | import org.apache.tools.ant.types.Argument; | ||||
| import org.apache.tools.ant.types.CommandlineJava; | import org.apache.tools.ant.types.CommandlineJava; | ||||
| import org.apache.tools.ant.types.Path; | import org.apache.tools.ant.types.Path; | ||||
| import org.apache.tools.ant.types.PathElement; | |||||
| /** | /** | ||||
| * Simple Metamata MParse task based on the original written by <a | * Simple Metamata MParse task based on the original written by <a | ||||
| @@ -203,7 +204,9 @@ public class MParse | |||||
| final Path classPath = m_cmdl.createClasspath(); | final Path classPath = m_cmdl.createClasspath(); | ||||
| for( int i = 0; i < jars.length; i++ ) | for( int i = 0; i < jars.length; i++ ) | ||||
| { | { | ||||
| classPath.createPathElement().setLocation( jars[ i ] ); | |||||
| final PathElement pathElement = new PathElement(); | |||||
| classPath.addPathElement( pathElement ); | |||||
| pathElement.setLocation( jars[ i ] ); | |||||
| } | } | ||||
| // set the metamata.home property | // set the metamata.home property | ||||
| @@ -203,7 +203,10 @@ public class CovReport extends Task | |||||
| { | { | ||||
| coveragePath = new Path(); | coveragePath = new Path(); | ||||
| } | } | ||||
| return coveragePath.createPath(); | |||||
| Path path1 = coveragePath; | |||||
| final Path path = new Path(); | |||||
| path1.addPath( path ); | |||||
| return path; | |||||
| } | } | ||||
| public Reference createReference() | public Reference createReference() | ||||
| @@ -221,7 +224,10 @@ public class CovReport extends Task | |||||
| { | { | ||||
| sourcePath = new Path(); | sourcePath = new Path(); | ||||
| } | } | ||||
| return sourcePath.createPath(); | |||||
| Path path1 = sourcePath; | |||||
| final Path path = new Path(); | |||||
| path1.addPath( path ); | |||||
| return path; | |||||
| } | } | ||||
| public void execute() | public void execute() | ||||
| @@ -289,7 +295,10 @@ public class CovReport extends Task | |||||
| if( sourcePath == null ) | if( sourcePath == null ) | ||||
| { | { | ||||
| sourcePath = new Path(); | sourcePath = new Path(); | ||||
| sourcePath.createPath().setLocation( getBaseDirectory() ); | |||||
| Path path1 = sourcePath; | |||||
| final Path path = new Path(); | |||||
| path1.addPath( path ); | |||||
| path.setLocation( getBaseDirectory() ); | |||||
| } | } | ||||
| v.add( "-sourcepath=" + sourcePath ); | v.add( "-sourcepath=" + sourcePath ); | ||||
| @@ -362,7 +371,10 @@ public class CovReport extends Task | |||||
| { | { | ||||
| classPath = new Path(); | classPath = new Path(); | ||||
| } | } | ||||
| return classPath.createPath(); | |||||
| Path path1 = classPath; | |||||
| final Path path = new Path(); | |||||
| path1.addPath( path ); | |||||
| return path; | |||||
| } | } | ||||
| public ReportFilters createFilters() | public ReportFilters createFilters() | ||||
| @@ -187,7 +187,10 @@ public class Coverage | |||||
| */ | */ | ||||
| public Path createClasspath() | public Path createClasspath() | ||||
| { | { | ||||
| return cmdlJava.createClasspath().createPath(); | |||||
| Path path1 = cmdlJava.createClasspath(); | |||||
| final Path path = new Path(); | |||||
| path1.addPath( path ); | |||||
| return path; | |||||
| } | } | ||||
| public Filters createFilters() | public Filters createFilters() | ||||
| @@ -12,7 +12,8 @@ import java.io.IOException; | |||||
| import java.net.URL; | import java.net.URL; | ||||
| import java.util.ArrayList; | import java.util.ArrayList; | ||||
| import java.util.Locale; | import java.util.Locale; | ||||
| import org.apache.avalon.excalibur.io.FileUtil; | |||||
| import org.apache.avalon.framework.logger.AbstractLogEnabled; | |||||
| import org.apache.avalon.framework.logger.Logger; | |||||
| import org.apache.myrmidon.api.TaskException; | import org.apache.myrmidon.api.TaskException; | ||||
| import org.apache.tools.ant.ProjectComponent; | import org.apache.tools.ant.ProjectComponent; | ||||
| import org.apache.tools.ant.util.FileUtils; | import org.apache.tools.ant.util.FileUtils; | ||||
| @@ -54,7 +55,7 @@ public class Path | |||||
| { | { | ||||
| public final static Path systemClasspath = createSystemClasspath(); | public final static Path systemClasspath = createSystemClasspath(); | ||||
| private ArrayList elements; | |||||
| private ArrayList m_elements; | |||||
| private static Path createSystemClasspath() | private static Path createSystemClasspath() | ||||
| { | { | ||||
| @@ -76,90 +77,20 @@ public class Path | |||||
| throws TaskException | throws TaskException | ||||
| { | { | ||||
| this(); | this(); | ||||
| createPathElement().setPath( path ); | |||||
| final PathElement pathElement = new PathElement(); | |||||
| addPathElement( pathElement ); | |||||
| pathElement.setPath( path ); | |||||
| } | } | ||||
| public Path() | public Path() | ||||
| { | { | ||||
| elements = new ArrayList(); | |||||
| } | |||||
| /** | |||||
| * Returns its argument with all file separator characters replaced so that | |||||
| * they match the local OS conventions. | |||||
| */ | |||||
| protected static String translateFile( final String source ) | |||||
| { | |||||
| if( source == null ) | |||||
| return ""; | |||||
| final StringBuffer result = new StringBuffer( source ); | |||||
| for( int i = 0; i < result.length(); i++ ) | |||||
| { | |||||
| translateFileSep( result, i ); | |||||
| } | |||||
| return result.toString(); | |||||
| } | |||||
| /** | |||||
| * Splits a PATH (with : or ; as separators) into its parts. | |||||
| */ | |||||
| protected String[] translatePath( final File baseDirectory, String source ) | |||||
| { | |||||
| final ArrayList result = new ArrayList(); | |||||
| if( source == null ) | |||||
| return new String[ 0 ]; | |||||
| final String[] elements = FileUtils.parsePath( source ); | |||||
| StringBuffer element = new StringBuffer(); | |||||
| for( int i = 0; i < elements.length; i++ ) | |||||
| { | |||||
| element.setLength( 0 ); | |||||
| final String pathElement = elements[ i ]; | |||||
| try | |||||
| { | |||||
| element.append( resolveFile( baseDirectory, pathElement ) ); | |||||
| } | |||||
| catch( TaskException e ) | |||||
| { | |||||
| final String message = | |||||
| "Dropping path element " + pathElement + " as it is not valid relative to the project"; | |||||
| getLogger().debug( message ); | |||||
| } | |||||
| for( int j = 0; j < element.length(); j++ ) | |||||
| { | |||||
| translateFileSep( element, j ); | |||||
| } | |||||
| result.add( element.toString() ); | |||||
| } | |||||
| return (String[])result.toArray( new String[ result.size() ] ); | |||||
| } | |||||
| /** | |||||
| * Translates all occurrences of / or \ to correct separator of the current | |||||
| * platform and returns whether it had to do any replacements. | |||||
| * | |||||
| * @param buffer Description of Parameter | |||||
| * @param pos Description of Parameter | |||||
| * @return Description of the Returned Value | |||||
| */ | |||||
| private static boolean translateFileSep( StringBuffer buffer, int pos ) | |||||
| { | |||||
| if( buffer.charAt( pos ) == '/' || buffer.charAt( pos ) == '\\' ) | |||||
| { | |||||
| buffer.setCharAt( pos, File.separatorChar ); | |||||
| return true; | |||||
| } | |||||
| return false; | |||||
| m_elements = new ArrayList(); | |||||
| } | } | ||||
| /** | /** | ||||
| * Adds a String to the ArrayList if it isn't already included. | * Adds a String to the ArrayList if it isn't already included. | ||||
| */ | */ | ||||
| private static void addUnlessPresent( final ArrayList list, final String entry ) | |||||
| private void addUnlessPresent( final ArrayList list, final String entry ) | |||||
| { | { | ||||
| if( !list.contains( entry ) ) | if( !list.contains( entry ) ) | ||||
| { | { | ||||
| @@ -167,22 +98,6 @@ public class Path | |||||
| } | } | ||||
| } | } | ||||
| /** | |||||
| * Resolve a filename with Project's help - if we know one that is. <p> | |||||
| * | |||||
| * Assume the filename is absolute if project is null.</p> | |||||
| */ | |||||
| private static String resolveFile( final File baseDirectory, final String relativeName ) | |||||
| throws TaskException | |||||
| { | |||||
| if( null != baseDirectory ) | |||||
| { | |||||
| final File file = FileUtil.resolveFile( baseDirectory, relativeName ); | |||||
| return file.getAbsolutePath(); | |||||
| } | |||||
| return relativeName; | |||||
| } | |||||
| /** | /** | ||||
| * Adds a element definition to the path. | * Adds a element definition to the path. | ||||
| * | * | ||||
| @@ -191,7 +106,9 @@ public class Path | |||||
| */ | */ | ||||
| public void setLocation( final File location ) | public void setLocation( final File location ) | ||||
| { | { | ||||
| createPathElement().setLocation( location ); | |||||
| final PathElement pathElement = new PathElement(); | |||||
| addPathElement( pathElement ); | |||||
| pathElement.setLocation( location ); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -201,7 +118,9 @@ public class Path | |||||
| */ | */ | ||||
| public void setPath( String path ) | public void setPath( String path ) | ||||
| { | { | ||||
| createPathElement().setPath( path ); | |||||
| final PathElement pathElement = new PathElement(); | |||||
| addPathElement( pathElement ); | |||||
| pathElement.setPath( path ); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -267,7 +186,7 @@ public class Path | |||||
| */ | */ | ||||
| public void addFileset( final FileSet fileSet ) | public void addFileset( final FileSet fileSet ) | ||||
| { | { | ||||
| elements.add( fileSet ); | |||||
| m_elements.add( fileSet ); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -334,9 +253,9 @@ public class Path | |||||
| for( int i = 0; i < list.length; i++ ) | for( int i = 0; i < list.length; i++ ) | ||||
| { | { | ||||
| final String file = list[ i ]; | final String file = list[ i ]; | ||||
| if( elements.contains( file ) ) | |||||
| if( m_elements.contains( file ) ) | |||||
| { | { | ||||
| elements.add( file ); | |||||
| m_elements.add( file ); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -414,21 +333,17 @@ public class Path | |||||
| * @return Description of the Returned Value | * @return Description of the Returned Value | ||||
| * @exception TaskException Description of Exception | * @exception TaskException Description of Exception | ||||
| */ | */ | ||||
| public Path createPath() | |||||
| public void addPath( final Path path ) | |||||
| { | { | ||||
| final Path other = new Path(); | |||||
| elements.add( other ); | |||||
| return other; | |||||
| m_elements.add( path ); | |||||
| } | } | ||||
| /** | /** | ||||
| * Creates the nested <code><pathelement></code> element. | * Creates the nested <code><pathelement></code> element. | ||||
| */ | */ | ||||
| public PathElement createPathElement() | |||||
| public void addPathElement( final PathElement pathElement ) | |||||
| { | { | ||||
| final PathElement pathElement = new PathElement(); | |||||
| elements.add( pathElement ); | |||||
| return pathElement; | |||||
| m_elements.add( pathElement ); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -437,10 +352,10 @@ public class Path | |||||
| public String[] list() | public String[] list() | ||||
| throws TaskException | throws TaskException | ||||
| { | { | ||||
| ArrayList result = new ArrayList( 2 * elements.size() ); | |||||
| for( int i = 0; i < elements.size(); i++ ) | |||||
| ArrayList result = new ArrayList( 2 * m_elements.size() ); | |||||
| for( int i = 0; i < m_elements.size(); i++ ) | |||||
| { | { | ||||
| Object o = elements.get( i ); | |||||
| Object o = m_elements.get( i ); | |||||
| if( o instanceof String ) | if( o instanceof String ) | ||||
| { | { | ||||
| // obtained via append | // obtained via append | ||||
| @@ -448,7 +363,9 @@ public class Path | |||||
| } | } | ||||
| else if( o instanceof PathElement ) | else if( o instanceof PathElement ) | ||||
| { | { | ||||
| String[] parts = ( (PathElement)o ).getParts(); | |||||
| final File baseDirectory = getBaseDirectory(); | |||||
| final PathElement element = (PathElement)o; | |||||
| final String[] parts = element.getParts( baseDirectory, getLogger() ); | |||||
| if( parts == null ) | if( parts == null ) | ||||
| { | { | ||||
| throw new NullPointerException( "You must either set location or path on <pathelement>" ); | throw new NullPointerException( "You must either set location or path on <pathelement>" ); | ||||
| @@ -477,7 +394,7 @@ public class Path | |||||
| { | { | ||||
| File f = new File( dir, s[ j ] ); | File f = new File( dir, s[ j ] ); | ||||
| String absolutePath = f.getAbsolutePath(); | String absolutePath = f.getAbsolutePath(); | ||||
| addUnlessPresent( result, translateFile( absolutePath ) ); | |||||
| addUnlessPresent( result, FileUtils.translateFile( absolutePath ) ); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -552,26 +469,4 @@ public class Path | |||||
| } | } | ||||
| } | } | ||||
| /** | |||||
| * Helper class, holds the nested <code><pathelement></code> values. | |||||
| */ | |||||
| public class PathElement | |||||
| { | |||||
| private String[] m_parts; | |||||
| public void setLocation( File loc ) | |||||
| { | |||||
| m_parts = new String[]{translateFile( loc.getAbsolutePath() )}; | |||||
| } | |||||
| public void setPath( String path ) | |||||
| { | |||||
| m_parts = translatePath( getProject().getBaseDir(), path ); | |||||
| } | |||||
| public String[] getParts() | |||||
| { | |||||
| return m_parts; | |||||
| } | |||||
| } | |||||
| } | } | ||||
| @@ -0,0 +1,35 @@ | |||||
| /* | |||||
| * Copyright (C) The Apache Software Foundation. All rights reserved. | |||||
| * | |||||
| * This software is published under the terms of the Apache Software License | |||||
| * version 1.1, a copy of which has been included with this distribution in | |||||
| * the LICENSE.txt file. | |||||
| */ | |||||
| package org.apache.tools.ant.types; | |||||
| import java.io.File; | |||||
| import org.apache.tools.ant.util.FileUtils; | |||||
| import org.apache.avalon.framework.logger.Logger; | |||||
| /** | |||||
| * Helper class, holds the nested <code><pathelement></code> values. | |||||
| */ | |||||
| public class PathElement | |||||
| { | |||||
| private String m_path; | |||||
| public void setLocation( final File location ) | |||||
| { | |||||
| m_path = FileUtils.translateFile( location.getAbsolutePath() ); | |||||
| } | |||||
| public void setPath( String path ) | |||||
| { | |||||
| m_path = path; | |||||
| } | |||||
| protected String[] getParts( final File baseDirectory, final Logger logger ) | |||||
| { | |||||
| return FileUtils.translatePath( baseDirectory, m_path, logger ); | |||||
| } | |||||
| } | |||||
| @@ -15,9 +15,11 @@ import java.io.FileOutputStream; | |||||
| import java.io.FileReader; | import java.io.FileReader; | ||||
| import java.io.FileWriter; | import java.io.FileWriter; | ||||
| import java.io.IOException; | import java.io.IOException; | ||||
| import java.util.ArrayList; | |||||
| import java.util.Stack; | import java.util.Stack; | ||||
| import java.util.StringTokenizer; | import java.util.StringTokenizer; | ||||
| import java.util.ArrayList; | |||||
| import org.apache.avalon.excalibur.io.FileUtil; | |||||
| import org.apache.avalon.framework.logger.Logger; | |||||
| import org.apache.myrmidon.api.TaskException; | import org.apache.myrmidon.api.TaskException; | ||||
| import org.apache.tools.ant.types.FilterSetCollection; | import org.apache.tools.ant.types.FilterSetCollection; | ||||
| @@ -377,5 +379,95 @@ public class FileUtils | |||||
| final String[] args = new String[ v.size() ]; | final String[] args = new String[ v.size() ]; | ||||
| return (String[])v.toArray( args ); | return (String[])v.toArray( args ); | ||||
| } | } | ||||
| /** | |||||
| * Returns its argument with all file separator characters replaced so that | |||||
| * they match the local OS conventions. | |||||
| */ | |||||
| public static String translateFile( final String source ) | |||||
| { | |||||
| if( source == null ) | |||||
| return ""; | |||||
| final StringBuffer result = new StringBuffer( source ); | |||||
| for( int i = 0; i < result.length(); i++ ) | |||||
| { | |||||
| translateFileSep( result, i ); | |||||
| } | |||||
| return result.toString(); | |||||
| } | |||||
| /** | |||||
| * Translates all occurrences of / or \ to correct separator of the current | |||||
| * platform and returns whether it had to do any replacements. | |||||
| * | |||||
| * @param buffer Description of Parameter | |||||
| * @param pos Description of Parameter | |||||
| * @return Description of the Returned Value | |||||
| */ | |||||
| public static boolean translateFileSep( StringBuffer buffer, int pos ) | |||||
| { | |||||
| if( buffer.charAt( pos ) == '/' || buffer.charAt( pos ) == '\\' ) | |||||
| { | |||||
| buffer.setCharAt( pos, File.separatorChar ); | |||||
| return true; | |||||
| } | |||||
| return false; | |||||
| } | |||||
| /** | |||||
| * Splits a PATH (with : or ; as separators) into its parts. | |||||
| */ | |||||
| public static String[] translatePath( final File baseDirectory, | |||||
| String source, | |||||
| final Logger logger ) | |||||
| { | |||||
| final ArrayList result = new ArrayList(); | |||||
| if( source == null ) | |||||
| return new String[ 0 ]; | |||||
| final String[] elements = parsePath( source ); | |||||
| StringBuffer element = new StringBuffer(); | |||||
| for( int i = 0; i < elements.length; i++ ) | |||||
| { | |||||
| element.setLength( 0 ); | |||||
| final String pathElement = elements[ i ]; | |||||
| try | |||||
| { | |||||
| element.append( resolveFile( baseDirectory, pathElement ) ); | |||||
| } | |||||
| catch( TaskException e ) | |||||
| { | |||||
| final String message = | |||||
| "Dropping path element " + pathElement + " as it is not valid relative to the project"; | |||||
| logger.debug( message ); | |||||
| } | |||||
| for( int j = 0; j < element.length(); j++ ) | |||||
| { | |||||
| translateFileSep( element, j ); | |||||
| } | |||||
| result.add( element.toString() ); | |||||
| } | |||||
| return (String[])result.toArray( new String[ result.size() ] ); | |||||
| } | |||||
| /** | |||||
| * Resolve a filename with Project's help - if we know one that is. <p> | |||||
| * | |||||
| * Assume the filename is absolute if project is null.</p> | |||||
| */ | |||||
| public static String resolveFile( final File baseDirectory, final String relativeName ) | |||||
| throws TaskException | |||||
| { | |||||
| if( null != baseDirectory ) | |||||
| { | |||||
| final File file = FileUtil.resolveFile( baseDirectory, relativeName ); | |||||
| return file.getAbsolutePath(); | |||||
| } | |||||
| return relativeName; | |||||
| } | |||||
| } | } | ||||
| @@ -152,6 +152,9 @@ public class Mapper | |||||
| { | { | ||||
| m_classpath = new Path(); | m_classpath = new Path(); | ||||
| } | } | ||||
| return m_classpath.createPath(); | |||||
| Path path1 = m_classpath; | |||||
| final Path path = new Path(); | |||||
| path1.addPath( path ); | |||||
| return path; | |||||
| } | } | ||||
| } | } | ||||