Browse Source

Some refactoring of Path. The plan is to make the 'evaluate' API of Path a

little narrower, to make it easier to extract an interface, and get multiple
path implementations happening.

* Replaced usages of Path.append() with Path.addPath(), and removed append().

* Replaced usages of Path.addExisting() with Path.addPath(), and removed
  addExisting().

* Replaced Path.size() with Path.isEmpty().

* Added the setX() methods back.

* Replaced usages of Path.toString() with new PathUtil.formatPath() method, and
  removed Path.toString().  Probably missed a few usages.

* Replaced FileUtil.translatePath( Path ) with PathUtil.formatPath(), and
  removed translatePath().

* Enabled the String -> Path converter again.


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@271893 13f79535-47bb-0310-9956-ffa450edef68
master
adammurdoch 23 years ago
parent
commit
d319ab594b
32 changed files with 236 additions and 295 deletions
  1. +1
    -1
      proposal/myrmidon/src/java/org/apache/antlib/dotnet/CSharp.java
  2. +1
    -1
      proposal/myrmidon/src/java/org/apache/antlib/xml/XMLValidateTask.java
  3. +0
    -2
      proposal/myrmidon/src/manifest/ant1-ant-descriptor.xml
  4. +27
    -22
      proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/IContract.java
  5. +3
    -2
      proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/Javah.java
  6. +9
    -16
      proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/javac/DefaultCompilerAdapter.java
  7. +6
    -5
      proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/javac/Gcj.java
  8. +7
    -6
      proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/javac/Jikes.java
  9. +6
    -5
      proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/javac/Jvc.java
  10. +7
    -8
      proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/javac/Kjc.java
  11. +1
    -1
      proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/javadoc/DocletInfo.java
  12. +8
    -16
      proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/javadoc/Javadoc.java
  13. +7
    -5
      proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/jdepend/JDependTask.java
  14. +2
    -2
      proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/jsp/JspC.java
  15. +3
    -2
      proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/jsp/WLJspc.java
  16. +3
    -14
      proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/metamata/AbstractMetamataTask.java
  17. +15
    -9
      proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/metamata/MAudit.java
  18. +11
    -4
      proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/metamata/MMetrics.java
  19. +4
    -5
      proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/metamata/MParse.java
  20. +4
    -4
      proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/rmic/DefaultRmicAdapter.java
  21. +3
    -4
      proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/sitraka/Coverage.java
  22. +14
    -20
      proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/vss/MSVSSCHECKIN.java
  23. +13
    -22
      proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/vss/MSVSSCHECKOUT.java
  24. +6
    -7
      proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/vss/MSVSSGET.java
  25. +2
    -2
      proposal/myrmidon/src/todo/org/apache/tools/todo/types/Argument.java
  26. +3
    -3
      proposal/myrmidon/src/todo/org/apache/tools/todo/types/CommandlineJava.java
  27. +3
    -2
      proposal/myrmidon/src/todo/org/apache/tools/todo/types/EnvironmentVariable.java
  28. +24
    -80
      proposal/myrmidon/src/todo/org/apache/tools/todo/types/Path.java
  29. +1
    -1
      proposal/myrmidon/src/todo/org/apache/tools/todo/types/PathElement.java
  30. +36
    -6
      proposal/myrmidon/src/todo/org/apache/tools/todo/types/PathUtil.java
  31. +5
    -9
      proposal/myrmidon/src/todo/org/apache/tools/todo/types/converters/StringToPathConverter.java
  32. +1
    -9
      proposal/myrmidon/src/todo/org/apache/tools/todo/util/FileUtils.java

+ 1
- 1
proposal/myrmidon/src/java/org/apache/antlib/dotnet/CSharp.java View File

@@ -396,7 +396,7 @@ public class CSharp
{
m_referenceFiles = new Path();
}
m_referenceFiles.append( path );
m_referenceFiles.addPath( path );
}

/**


+ 1
- 1
proposal/myrmidon/src/java/org/apache/antlib/xml/XMLValidateTask.java View File

@@ -109,7 +109,7 @@ public class XMLValidateTask
}
else
{
m_classpath.append( classpath );
m_classpath.addPath( classpath );
}
}



+ 0
- 2
proposal/myrmidon/src/manifest/ant1-ant-descriptor.xml View File

@@ -1,8 +1,6 @@
<ant-lib version="1.0">

<types>
<task name="ant1-tasklib" classname="org.apache.myrmidon.libs.ant1.Ant1Tasklib" />

<data-type name="path" classname="org.apache.tools.ant.types.Path" />
<task name="path" classname="org.apache.myrmidon.framework.TypeInstanceTask" />
<converter


+ 27
- 22
proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/IContract.java View File

@@ -21,6 +21,7 @@ import org.apache.tools.todo.taskdefs.javac.DefaultCompilerAdapter;
import org.apache.tools.todo.taskdefs.javac.Javac;
import org.apache.tools.todo.types.DirectoryScanner;
import org.apache.tools.todo.types.Path;
import org.apache.tools.todo.types.PathUtil;

/**
* Instruments Java classes with <a href="http://www.reliable-systems.com/tools/">
@@ -484,9 +485,9 @@ public class IContract extends MatchingTask
* @param path The new Classpath value
* @path the classpath
*/
public void setClasspath( Path path )
public void setClasspath( final Path path )
{
createClasspath().append( path );
createClasspath().addPath( path );
}

/**
@@ -706,30 +707,34 @@ public class IContract extends MatchingTask
classpathHelper.modify( baseClasspath );

// Create the classpath required to compile the sourcefiles BEFORE instrumentation
Path beforeInstrumentationClasspath = ( (Path)baseClasspath.clone() );
beforeInstrumentationClasspath.append( new Path( srcDir.getAbsolutePath() ) );
Path beforeInstrumentationClasspath = new Path();
beforeInstrumentationClasspath.addPath( baseClasspath );
beforeInstrumentationClasspath.addLocation( srcDir );

// Create the classpath required to compile the sourcefiles AFTER instrumentation
Path afterInstrumentationClasspath = ( (Path)baseClasspath.clone() );
afterInstrumentationClasspath.append( new Path( instrumentDir.getAbsolutePath() ) );
afterInstrumentationClasspath.append( new Path( repositoryDir.getAbsolutePath() ) );
afterInstrumentationClasspath.append( new Path( srcDir.getAbsolutePath() ) );
afterInstrumentationClasspath.append( new Path( buildDir.getAbsolutePath() ) );
Path afterInstrumentationClasspath = new Path();
afterInstrumentationClasspath.addPath( baseClasspath );
afterInstrumentationClasspath.addLocation( instrumentDir );
afterInstrumentationClasspath.addLocation( repositoryDir );
afterInstrumentationClasspath.addLocation( srcDir );
afterInstrumentationClasspath.addLocation( buildDir );

// Create the classpath required to automatically compile the repository files
Path repositoryClasspath = ( (Path)baseClasspath.clone() );
repositoryClasspath.append( new Path( instrumentDir.getAbsolutePath() ) );
repositoryClasspath.append( new Path( srcDir.getAbsolutePath() ) );
repositoryClasspath.append( new Path( repositoryDir.getAbsolutePath() ) );
repositoryClasspath.append( new Path( buildDir.getAbsolutePath() ) );
Path repositoryClasspath = new Path();
repositoryClasspath.addPath( baseClasspath );
repositoryClasspath.addLocation( instrumentDir );
repositoryClasspath.addLocation( srcDir );
repositoryClasspath.addLocation( repositoryDir );
repositoryClasspath.addLocation( buildDir );

// Create the classpath required for iContract itself
Path iContractClasspath = ( (Path)baseClasspath.clone() );
iContractClasspath.append( new Path( System.getProperty( "java.home" ) + File.separator + ".." + File.separator + "lib" + File.separator + "tools.jar" ) );
iContractClasspath.append( new Path( srcDir.getAbsolutePath() ) );
iContractClasspath.append( new Path( repositoryDir.getAbsolutePath() ) );
iContractClasspath.append( new Path( instrumentDir.getAbsolutePath() ) );
iContractClasspath.append( new Path( buildDir.getAbsolutePath() ) );
Path iContractClasspath = new Path();
iContractClasspath.addPath( baseClasspath );
iContractClasspath.addLocation( new File(System.getProperty( "java.home" ) + File.separator + ".." + File.separator + "lib" + File.separator + "tools.jar" ) );
iContractClasspath.addLocation( srcDir );
iContractClasspath.addLocation( repositoryDir );
iContractClasspath.addLocation( instrumentDir );
iContractClasspath.addLocation( buildDir );

// Create a forked java process
Java iContract = null;//(Java)getProject().createTask( "java" );
@@ -768,7 +773,7 @@ public class IContract extends MatchingTask
}
iControlProps.setProperty( "sourceRoot", srcDir.getAbsolutePath() );
iControlProps.setProperty( "classRoot", classDir.getAbsolutePath() );
iControlProps.setProperty( "classpath", afterInstrumentationClasspath.toString() );
iControlProps.setProperty( "classpath", PathUtil.formatPath( afterInstrumentationClasspath ) );
iControlProps.setProperty( "controlFile", controlFile.getAbsolutePath() );
iControlProps.setProperty( "targetsFile", targets.getAbsolutePath() );

@@ -1027,7 +1032,7 @@ public class IContract extends MatchingTask
{
icCompiler = compiler;
m_includeJavaRuntime = true;
path.append( getCompileClasspath() );
addCompileClasspath( path );
}
}
}


+ 3
- 2
proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/Javah.java View File

@@ -17,6 +17,7 @@ import org.apache.myrmidon.api.TaskException;
import org.apache.myrmidon.api.TaskContext;
import org.apache.tools.todo.types.Commandline;
import org.apache.tools.todo.types.Path;
import org.apache.tools.todo.types.PathUtil;
import org.apache.tools.todo.util.FileUtils;
import org.apache.tools.todo.taskdefs.ClassArgument;

@@ -270,7 +271,7 @@ public class Javah
if( m_classpath != null )
{
cmd.addArgument( "-classpath" );
cmd.addArguments( FileUtils.translateCommandline( m_classpath ) );
cmd.addArgument( PathUtil.formatPath( m_classpath ) );
}

if( m_verbose )
@@ -298,7 +299,7 @@ public class Javah
if( m_bootclasspath != null )
{
cmd.addArgument( "-bootclasspath" );
cmd.addArguments( FileUtils.translateCommandline( m_bootclasspath ) );
cmd.addArgument( PathUtil.formatPath( m_bootclasspath ) );
}

logAndAddFilesToCompile( cmd );


+ 9
- 16
proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/javac/DefaultCompilerAdapter.java View File

@@ -19,8 +19,6 @@ import org.apache.myrmidon.framework.Execute;
import org.apache.tools.todo.types.Commandline;
import org.apache.tools.todo.types.Path;
import org.apache.tools.todo.types.PathUtil;
import org.apache.tools.todo.util.FileUtils;
import org.apache.tools.todo.taskdefs.javac.CompilerAdapter;

/**
* This is the default implementation for the CompilerAdapter interface.
@@ -132,7 +130,8 @@ public abstract class DefaultCompilerAdapter
boolean useDebugLevel )
throws TaskException
{
Path classpath = getCompileClasspath();
Path classpath = new Path();
addCompileClasspath( classpath );
String memoryParameterPrefix = "-J-X";
if( m_memoryInitialSize != null )
{
@@ -177,10 +176,10 @@ public abstract class DefaultCompilerAdapter
}

cmd.addArgument( "-classpath" );
cmd.addArguments( FileUtils.translateCommandline( classpath ) );
cmd.addArgument( PathUtil.formatPath( classpath ) );

cmd.addArgument( "-sourcepath" );
cmd.addArguments( FileUtils.translateCommandline( src ) );
cmd.addArgument( PathUtil.formatPath( src ) );

if( target != null )
{
@@ -191,13 +190,13 @@ public abstract class DefaultCompilerAdapter
if( m_bootclasspath != null )
{
cmd.addArgument( "-bootclasspath" );
cmd.addArguments( FileUtils.translateCommandline( m_bootclasspath ) );
cmd.addArgument( PathUtil.formatPath( m_bootclasspath ) );
}

if( m_extdirs != null )
{
cmd.addArgument( "-extdirs" );
cmd.addArguments( FileUtils.translateCommandline( m_extdirs ) );
cmd.addArgument( PathUtil.formatPath( m_extdirs ) );
}

if( m_encoding != null )
@@ -279,15 +278,11 @@ public abstract class DefaultCompilerAdapter
}

/**
* Builds the compilation classpath.
*
* @return The CompileClasspath value
* Adds the compilation classpath to a path.
*/
protected Path getCompileClasspath()
protected void addCompileClasspath( final Path classpath )
throws TaskException
{
Path classpath = new Path();

// add dest dir to classpath so that previously compiled and
// untouched classes are on classpath

@@ -299,10 +294,8 @@ public abstract class DefaultCompilerAdapter
// add the classpath
if( m_compileClasspath != null )
{
classpath.addExisting( m_compileClasspath );
classpath.addPath( m_compileClasspath );
}

return classpath;
}

/**


+ 6
- 5
proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/javac/Gcj.java View File

@@ -11,6 +11,7 @@ import org.apache.myrmidon.api.TaskException;
import org.apache.myrmidon.api.TaskContext;
import org.apache.tools.todo.types.Commandline;
import org.apache.tools.todo.types.Path;
import org.apache.tools.todo.types.PathUtil;
import org.apache.tools.todo.util.FileUtils;
import org.apache.tools.todo.taskdefs.javac.DefaultCompilerAdapter;

@@ -53,23 +54,23 @@ public class Gcj extends DefaultCompilerAdapter
// so we'll emulate it for compatibility and convenience.
if( m_bootclasspath != null )
{
classpath.append( m_bootclasspath );
classpath.addPath( m_bootclasspath );
}

// gcj doesn't support an extension dir (-extdir)
// so we'll emulate it for compatibility and convenience.
addExtdirs( classpath );

if( ( m_bootclasspath == null ) || ( m_bootclasspath.size() == 0 ) )
if( ( m_bootclasspath == null ) || m_bootclasspath.isEmpty() )
{
// no bootclasspath, therefore, get one from the java runtime
m_includeJavaRuntime = true;
}
classpath.append( getCompileClasspath() );
addCompileClasspath( classpath );

// Gcj has no option for source-path so we
// will add it to classpath.
classpath.append( src );
classpath.addPath( src );

cmd.setExecutable( "gcj" );

@@ -86,7 +87,7 @@ public class Gcj extends DefaultCompilerAdapter
}

cmd.addArgument( "-classpath" );
cmd.addArguments( FileUtils.translateCommandline( classpath ) );
cmd.addArgument( PathUtil.formatPath( classpath ) );

if( m_encoding != null )
{


+ 7
- 6
proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/javac/Jikes.java View File

@@ -11,6 +11,7 @@ import org.apache.myrmidon.api.TaskException;
import org.apache.myrmidon.api.TaskContext;
import org.apache.tools.todo.types.Commandline;
import org.apache.tools.todo.types.Path;
import org.apache.tools.todo.types.PathUtil;
import org.apache.tools.todo.util.FileUtils;
import org.apache.tools.todo.taskdefs.javac.DefaultCompilerAdapter;

@@ -50,14 +51,14 @@ public class Jikes
// so we'll emulate it for compatibility and convenience.
if( m_bootclasspath != null )
{
classpath.append( m_bootclasspath );
classpath.addPath( m_bootclasspath );
}

// Jikes doesn't support an extension dir (-extdir)
// so we'll emulate it for compatibility and convenience.
addExtdirs( classpath );

if( ( m_bootclasspath == null ) || ( m_bootclasspath.size() == 0 ) )
if( ( m_bootclasspath == null ) || m_bootclasspath.isEmpty() )
{
// no bootclasspath, therefore, get one from the java runtime
m_includeJavaRuntime = true;
@@ -69,17 +70,17 @@ public class Jikes
// bootclasspath and said to include the java runtime, it's on
// their head!
}
classpath.append( getCompileClasspath() );
addCompileClasspath( classpath );

// Jikes has no option for source-path so we
// will add it to classpath.
classpath.append( src );
classpath.addPath( src );

// if the user has set JIKESPATH we should add the contents as well
String jikesPath = System.getProperty( "jikes.class.path" );
if( jikesPath != null )
{
classpath.append( new Path( jikesPath ) );
classpath.addPath( jikesPath );
}

Commandline cmd = new Commandline();
@@ -97,7 +98,7 @@ public class Jikes
}

cmd.addArgument( "-classpath" );
cmd.addArguments( FileUtils.translateCommandline( classpath ) );
cmd.addArgument( PathUtil.formatPath( classpath ) );

if( m_encoding != null )
{


+ 6
- 5
proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/javac/Jvc.java View File

@@ -11,6 +11,7 @@ import org.apache.myrmidon.api.TaskException;
import org.apache.myrmidon.api.TaskContext;
import org.apache.tools.todo.types.Commandline;
import org.apache.tools.todo.types.Path;
import org.apache.tools.todo.types.PathUtil;
import org.apache.tools.todo.util.FileUtils;
import org.apache.tools.todo.taskdefs.javac.DefaultCompilerAdapter;

@@ -38,14 +39,14 @@ public class Jvc extends DefaultCompilerAdapter
// so we'll emulate it for compatibility and convenience.
if( m_bootclasspath != null )
{
classpath.append( m_bootclasspath );
classpath.addPath( m_bootclasspath );
}

// jvc doesn't support an extension dir (-extdir)
// so we'll emulate it for compatibility and convenience.
addExtdirs( classpath );

if( ( m_bootclasspath == null ) || ( m_bootclasspath.size() == 0 ) )
if( ( m_bootclasspath == null ) || m_bootclasspath.isEmpty() )
{
// no bootclasspath, therefore, get one from the java runtime
m_includeJavaRuntime = true;
@@ -57,11 +58,11 @@ public class Jvc extends DefaultCompilerAdapter
// bootclasspath and said to include the java runtime, it's on
// their head!
}
classpath.append( getCompileClasspath() );
addCompileClasspath( classpath );

// jvc has no option for source-path so we
// will add it to classpath.
classpath.append( src );
classpath.addPath( src );

Commandline cmd = new Commandline();
cmd.setExecutable( "jvc" );
@@ -74,7 +75,7 @@ public class Jvc extends DefaultCompilerAdapter

// Add the Classpath before the "internal" one.
cmd.addArgument( "/cp:p" );
cmd.addArguments( FileUtils.translateCommandline( classpath ) );
cmd.addArgument( PathUtil.formatPath( classpath ) );

// Enable MS-Extensions and ...
cmd.addArgument( "/x-" );


+ 7
- 8
proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/javac/Kjc.java View File

@@ -9,11 +9,9 @@ package org.apache.tools.todo.taskdefs.javac;

import java.lang.reflect.Method;
import org.apache.myrmidon.api.TaskException;
import org.apache.myrmidon.api.TaskContext;
import org.apache.tools.todo.types.Commandline;
import org.apache.tools.todo.types.Path;
import org.apache.tools.todo.util.FileUtils;
import org.apache.tools.todo.taskdefs.javac.DefaultCompilerAdapter;
import org.apache.tools.todo.types.PathUtil;

/**
* The implementation of the Java compiler for KJC. This is primarily a
@@ -71,7 +69,8 @@ public class Kjc extends DefaultCompilerAdapter
Commandline cmd = new Commandline();

// generate classpath, because kjc does't support sourcepath.
Path classpath = getCompileClasspath();
Path classpath = new Path();
addCompileClasspath( classpath );

if( m_deprecation == true )
{
@@ -92,7 +91,7 @@ public class Kjc extends DefaultCompilerAdapter
// kjc don't have bootclasspath option.
if( m_bootclasspath != null )
{
cp.append( m_bootclasspath );
cp.addPath( m_bootclasspath );
}

if( m_extdirs != null )
@@ -100,10 +99,10 @@ public class Kjc extends DefaultCompilerAdapter
addExtdirs( cp );
}

cp.append( classpath );
cp.append( src );
cp.addPath( classpath );
cp.addPath( src );

cmd.addArguments( FileUtils.translateCommandline( cp ) );
cmd.addArgument( PathUtil.formatPath( cp ) );

// kjc-1.5A doesn't support -encoding option now.
// but it will be supported near the feature.


+ 1
- 1
proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/javadoc/DocletInfo.java View File

@@ -32,7 +32,7 @@ public class DocletInfo
}
else
{
m_path.append( path );
m_path.addPath( path );
}
}



+ 8
- 16
proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/javadoc/Javadoc.java View File

@@ -15,25 +15,18 @@ import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.StringTokenizer;
import org.apache.aut.nativelib.ExecManager;
import org.apache.aut.nativelib.ExecOutputHandler;
import org.apache.aut.nativelib.Os;
import org.apache.myrmidon.api.AbstractTask;
import org.apache.myrmidon.api.TaskException;
import org.apache.myrmidon.api.TaskContext;
import org.apache.myrmidon.framework.Execute;
import org.apache.myrmidon.framework.Pattern;
import org.apache.tools.todo.types.Commandline;
import org.apache.tools.todo.types.DirectoryScanner;
import org.apache.tools.todo.types.FileSet;
import org.apache.tools.todo.types.Path;
import org.apache.tools.todo.types.PathUtil;
import org.apache.tools.todo.types.ScannerUtil;
import org.apache.tools.todo.util.FileUtils;
import org.apache.tools.todo.taskdefs.javadoc.AccessType;
import org.apache.tools.todo.taskdefs.javadoc.DocletInfo;
import org.apache.tools.todo.taskdefs.javadoc.DocletParam;
import org.apache.tools.todo.taskdefs.javadoc.GroupArgument;
import org.apache.tools.todo.taskdefs.javadoc.Html;

/**
* This task makes it easy to generate Javadoc documentation for a collection of
@@ -85,7 +78,6 @@ public class Javadoc
private Path m_classpath;
private Path m_bootclasspath;
private String m_group;
private ArrayList m_compileList = new ArrayList( 10 );
private String m_packageList;
private ArrayList m_links = new ArrayList( 2 );
private ArrayList m_groups = new ArrayList( 2 );
@@ -122,7 +114,7 @@ public class Javadoc
}
else
{
m_bootclasspath.append( src );
m_bootclasspath.addPath( src );
}
}

@@ -147,7 +139,7 @@ public class Javadoc
}
else
{
m_classpath.append( src );
m_classpath.addPath( src );
}
}

@@ -392,7 +384,7 @@ public class Javadoc
}
else
{
m_sourcePath.append( src );
m_sourcePath.addPath( src );
}
}

@@ -578,7 +570,7 @@ public class Javadoc
classpath.addPath( m_classpath );
}
cmd.addArgument( "-classpath" );
cmd.addArgument( classpath.toString() );
cmd.addArgument( PathUtil.formatPath( classpath ) );

if( m_version && m_doclet == null )
{
@@ -615,7 +607,7 @@ public class Javadoc
if( m_doclet.getPath() != null )
{
cmd.addArgument( "-docletpath" );
cmd.addArguments( FileUtils.translateCommandline( m_doclet.getPath() ) );
cmd.addArgument( PathUtil.formatPath( m_doclet.getPath() ) );
}
for( Iterator e = m_doclet.getParams(); e.hasNext(); )
{
@@ -636,7 +628,7 @@ public class Javadoc
if( m_bootclasspath != null )
{
cmd.addArgument( "-bootclasspath" );
cmd.addArguments( FileUtils.translateCommandline( m_bootclasspath ) );
cmd.addArgument( PathUtil.formatPath( m_bootclasspath ) );
}

// add the links arguments
@@ -896,7 +888,7 @@ public class Javadoc
ArrayList packages, ArrayList excludePackages )
throws TaskException
{
getContext().debug( "Source path = " + sourcePath.toString() );
getContext().debug( "Source path = " + PathUtil.formatPath( sourcePath ) );
StringBuffer msg = new StringBuffer( "Packages = " );
for( int i = 0; i < packages.size(); i++ )
{


+ 7
- 5
proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/jdepend/JDependTask.java View File

@@ -17,6 +17,7 @@ import org.apache.myrmidon.framework.Execute;
import org.apache.tools.todo.types.Commandline;
import org.apache.tools.todo.types.CommandlineJava;
import org.apache.tools.todo.types.Path;
import org.apache.tools.todo.types.PathUtil;
import org.apache.tools.todo.util.FileUtils;

/**
@@ -54,7 +55,7 @@ public class JDependTask
}
else
{
m_compileClasspath.append( classpath );
m_compileClasspath.addPath( classpath );
}
}

@@ -192,10 +193,11 @@ public class JDependTask

// not sure whether this test is needed but cost nothing to put.
// hope it will be reviewed by anybody competent
if( m_compileClasspath.toString().length() > 0 )
final String compileClasspath = PathUtil.formatPath( m_compileClasspath );
if( compileClasspath.length() > 0 )
{
commandline.addVmArgument( "-classpath" );
commandline.addVmArgument( m_compileClasspath.toString() );
commandline.addVmArgument( compileClasspath );
}

if( m_outputFile != null )
@@ -207,7 +209,7 @@ public class JDependTask
// we have to find a cleaner way to put this output
}

final String[] elements = FileUtils.parsePath( m_sourcesPath.toString() );
final String[] elements = m_sourcesPath.list();
for( int i = 0; i < elements.length; i++ )
{
File f = new File( elements[ i ] );
@@ -276,7 +278,7 @@ public class JDependTask
getContext().info( "Output to be stored in " + m_outputFile.getPath() );
}

final String[] elements = FileUtils.parsePath( m_sourcesPath.toString() );
final String[] elements = m_sourcesPath.list();
for( int i = 0; i < elements.length; i++ )
{
File f = new File( elements[ i ] );


+ 2
- 2
proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/jsp/JspC.java View File

@@ -109,7 +109,7 @@ public class JspC extends MatchingTask
}
else
{
classpath.append( cp );
classpath.addPath( cp );
}
}

@@ -187,7 +187,7 @@ public class JspC extends MatchingTask
}
else
{
src.append( srcDir );
src.addPath( srcDir );
}
}



+ 3
- 2
proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/jsp/WLJspc.java View File

@@ -17,6 +17,7 @@ import org.apache.tools.todo.taskdefs.MatchingTask;
import org.apache.tools.todo.types.Argument;
import org.apache.tools.todo.types.DirectoryScanner;
import org.apache.tools.todo.types.Path;
import org.apache.tools.todo.types.PathUtil;

/**
* Class to precompile JSP's using weblogic's jsp compiler (weblogic.jspc)
@@ -82,7 +83,7 @@ public class WLJspc extends MatchingTask
}
else
{
compileClasspath.append( classpath );
compileClasspath.addPath( classpath );
}
}

@@ -194,7 +195,7 @@ public class WLJspc extends MatchingTask
// Does not take the classpath from the env....
// Am i missing something about the Java task??
args[ j++ ] = "-classpath";
args[ j++ ] = compileClasspath.toString();
args[ j++ ] = PathUtil.formatPath( compileClasspath );

this.scanDir( files );
getContext().info( "Compiling " + filesToDo.size() + " JSP files" );


+ 3
- 14
proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/metamata/AbstractMetamataTask.java View File

@@ -15,10 +15,8 @@ import java.util.ArrayList;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.Random;
import org.apache.aut.nativelib.ExecManager;
import org.apache.myrmidon.api.AbstractTask;
import org.apache.myrmidon.api.TaskException;
import org.apache.myrmidon.api.TaskContext;
import org.apache.myrmidon.framework.Execute;
import org.apache.tools.todo.types.Argument;
import org.apache.tools.todo.types.Commandline;
@@ -43,7 +41,7 @@ public abstract class AbstractMetamataTask
* command line. The classpath must includes both the <tt>.class</tt> and
* the <tt>.java</tt> files for accurate audit.
*/
private Path m_classPath;
private Path m_classPath = new Path();

/**
* the path to the source file
@@ -142,13 +140,9 @@ public abstract class AbstractMetamataTask
/**
* user classpath
*/
public Path createClasspath()
public void addClasspath( final Path path )
{
if( m_classPath == null )
{
m_classPath = new Path();
}
return m_classPath;
m_classPath.addPath( path );
}

/**
@@ -364,11 +358,6 @@ public abstract class AbstractMetamataTask
return m_classPath;
}

protected void setClassPath( Path classPath )
{
m_classPath = classPath;
}

protected Path getSourcePath()
{
return m_sourcePath;


+ 15
- 9
proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/metamata/MAudit.java View File

@@ -10,9 +10,8 @@ package org.apache.tools.todo.taskdefs.metamata;
import java.io.File;
import java.util.ArrayList;
import org.apache.myrmidon.api.TaskException;
import org.apache.myrmidon.api.AbstractTask;
import org.apache.myrmidon.api.TaskContext;
import org.apache.tools.todo.types.Path;
import org.apache.tools.todo.types.PathUtil;

/**
* Metamata Audit evaluates Java code for programming errors, weaknesses, and
@@ -119,22 +118,29 @@ public class MAudit
throws TaskException
{
ArrayList options = new ArrayList( 512 );

final Path classpath = new Path();

// there is a bug in Metamata 2.0 build 37. The sourcepath argument does
// not work. So we will use the sourcepath prepended to classpath. (order
// is important since Metamata looks at .class and .java)
if( getSourcePath() != null )
final Path sourcePath = getSourcePath();
if( sourcePath != null )
{
getSourcePath().append( getClassPath() );// srcpath is prepended
setClassPath( getSourcePath() );
classpath.addPath( sourcePath );
setSourcePath( null );// prevent from using -sourcepath
}

// don't forget to modify the pattern if you change the options reporting
if( getClassPath() != null )
classpath.addPath( getClassPath() );

final String formattedClasspath = PathUtil.formatPath( classpath );
if( formattedClasspath.length() > 0 )
{
options.add( "-classpath" );
options.add( getClassPath().toString() );
options.add( formattedClasspath );
}

// suppress copyright msg when running, we will let it so that this
// will be the only output to the console if in xml mode
// options.add("-quiet");
@@ -154,13 +160,13 @@ public class MAudit
if( getSourcePath() != null )
{
options.add( "-sourcepath" );
options.add( getSourcePath().toString() );
options.add( PathUtil.formatPath( getSourcePath() ) );
}

if( m_unused )
{
options.add( "-unused" );
options.add( m_searchPath.toString() );
options.add( PathUtil.formatPath( m_searchPath ) );
}
addAllArrayList( options, getIncludedFiles().keySet().iterator() );
return options;


+ 11
- 4
proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/metamata/MMetrics.java View File

@@ -15,6 +15,7 @@ import java.util.ArrayList;
import org.apache.myrmidon.api.TaskException;
import org.apache.tools.todo.taskdefs.exec.ExecuteStreamHandler;
import org.apache.tools.todo.types.Path;
import org.apache.tools.todo.types.PathUtil;

/**
* Calculates global complexity and quality metrics on Java source code. You
@@ -120,22 +121,28 @@ public class MMetrics extends AbstractMetamataTask
throws TaskException
{
ArrayList options = new ArrayList( 512 );

final Path classpath = new Path();

// there is a bug in Metamata 2.0 build 37. The sourcepath argument does
// not work. So we will use the sourcepath prepended to classpath. (order
// is important since Metamata looks at .class and .java)
if( getSourcePath() != null )
{
getSourcePath().append( getClassPath() );// srcpath is prepended
setClassPath( getSourcePath() );
classpath.addPath( getSourcePath() );
setSourcePath( null );// prevent from using -sourcepath
}

// don't forget to modify the pattern if you change the options reporting
if( getClassPath() != null )
classpath.addPath( getClassPath() );

final String formattedClasspath = PathUtil.formatPath( classpath );
if( formattedClasspath.length() > 0 )
{
options.add( "-classpath" );
options.add( getClassPath() );
options.add( formattedClasspath );
}

options.add( "-output" );
options.add( tmpFile.toString() );



+ 4
- 5
proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/metamata/MParse.java View File

@@ -13,16 +13,15 @@ import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Random;
import org.apache.aut.nativelib.ExecManager;
import org.apache.avalon.excalibur.io.IOUtil;
import org.apache.myrmidon.api.AbstractTask;
import org.apache.myrmidon.api.TaskException;
import org.apache.myrmidon.api.TaskContext;
import org.apache.myrmidon.framework.Execute;
import org.apache.tools.todo.types.Argument;
import org.apache.tools.todo.types.Commandline;
import org.apache.tools.todo.types.CommandlineJava;
import org.apache.tools.todo.types.Path;
import org.apache.tools.todo.types.PathUtil;

/**
* Simple Metamata MParse task based on the original written by <a
@@ -240,7 +239,7 @@ public class MParse
*
* @return The Options value
*/
protected String[] getOptions()
protected String[] getOptions() throws TaskException
{
ArrayList options = new ArrayList();
if( m_verbose )
@@ -258,12 +257,12 @@ public class MParse
if( m_classpath != null )
{
options.add( "-classpath" );
options.add( m_classpath.toString() );
options.add( PathUtil.formatPath( m_classpath ) );
}
if( m_sourcepath != null )
{
options.add( "-sourcepath" );
options.add( m_sourcepath.toString() );
options.add( PathUtil.formatPath( m_sourcepath ) );
}
options.add( m_target.getAbsolutePath() );



+ 4
- 4
proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/rmic/DefaultRmicAdapter.java View File

@@ -15,7 +15,7 @@ import org.apache.myrmidon.api.TaskException;
import org.apache.myrmidon.framework.FileNameMapper;
import org.apache.tools.todo.types.Commandline;
import org.apache.tools.todo.types.Path;
import org.apache.tools.todo.util.FileUtils;
import org.apache.tools.todo.types.PathUtil;

/**
* This is the default implementation for the RmicAdapter interface. Currently,
@@ -120,11 +120,11 @@ public abstract class DefaultRmicAdapter
if( attributes.getExtdirs() != null )
{
cmd.addArgument( "-extdirs" );
cmd.addArguments( FileUtils.translateCommandline( attributes.getExtdirs() ) );
cmd.addArgument( PathUtil.formatPath( attributes.getExtdirs() ) );
}

cmd.addArgument( "-classpath" );
cmd.addArguments( FileUtils.translateCommandline( classpath ) );
cmd.addArgument( PathUtil.formatPath( classpath ) );

String stubVersion = attributes.getStubVersion();
if( null != stubVersion )
@@ -195,7 +195,7 @@ public abstract class DefaultRmicAdapter
// add the classpath
if( attributes.getClasspath() != null )
{
classpath.addExisting( attributes.getClasspath() );
classpath.addPath( attributes.getClasspath() );
}

return classpath;


+ 3
- 4
proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/sitraka/Coverage.java View File

@@ -13,16 +13,15 @@ import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.ArrayList;
import org.apache.aut.nativelib.ExecManager;
import org.apache.myrmidon.api.AbstractTask;
import org.apache.myrmidon.api.TaskException;
import org.apache.myrmidon.api.TaskContext;
import org.apache.myrmidon.framework.Execute;
import org.apache.tools.todo.types.Argument;
import org.apache.tools.todo.types.Commandline;
import org.apache.tools.todo.types.CommandlineJava;
import org.apache.tools.todo.types.FileSet;
import org.apache.tools.todo.types.Path;
import org.apache.tools.todo.types.PathUtil;

/**
* Convenient task to run Sitraka JProbe Coverage from Ant. Options are pretty
@@ -313,9 +312,9 @@ public class Coverage
}
// classpath
Path classpath = cmdlJava.getClasspath();
if( classpath != null && classpath.size() > 0 )
if( classpath != null && ! classpath.isEmpty() )
{
params.add( "-classpath " + classpath.toString() );
params.add( "-classpath " + PathUtil.formatPath( classpath ) );
}
// classname (runner or standalone)
if( cmdlJava.getClassname() != null )


+ 14
- 20
proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/vss/MSVSSCHECKIN.java View File

@@ -10,7 +10,6 @@ package org.apache.tools.todo.taskdefs.vss;
import java.io.File;
import org.apache.myrmidon.api.TaskException;
import org.apache.tools.todo.types.Commandline;
import org.apache.tools.todo.types.Path;

/**
* Task to perform CheckIn commands to Microsoft Visual Source Safe.
@@ -20,7 +19,7 @@ import org.apache.tools.todo.types.Path;
public class MSVSSCHECKIN
extends MSVSS
{
private String m_localPath;
private File m_localPath;
private boolean m_recursive;
private boolean m_writable;
private String m_autoResponse;
@@ -67,9 +66,9 @@ public class MSVSSCHECKIN
/**
* Set the local path.
*/
public void setLocalpath( final Path localPath )
public void setLocalpath( final File localPath )
{
m_localPath = localPath.toString();
m_localPath = localPath;
}

/**
@@ -117,27 +116,22 @@ public class MSVSSCHECKIN
{
return;
}
else

// make sure m_LocalDir exists, create it if it doesn't
if( !m_localPath.exists() )
{
// make sure m_LocalDir exists, create it if it doesn't
final File dir = getContext().resolveFile( m_localPath );
if( !dir.exists() )
if( !m_localPath.mkdirs() )
{
final boolean done = dir.mkdirs();
if( !done )
{
final String message =
"Directory " + m_localPath + " creation was not " +
"succesful for an unknown reason";
throw new TaskException( message );
}

final String message = "Created dir: " + dir.getAbsolutePath();
getContext().info( message );
final String message =
"Directory " + m_localPath + " creation was not " +
"succesful for an unknown reason";
throw new TaskException( message );
}

cmd.addArgument( FLAG_OVERRIDE_WORKING_DIR + m_localPath );
final String message = "Created dir: " + m_localPath.getAbsolutePath();
getContext().info( message );
}
cmd.addArgument( FLAG_OVERRIDE_WORKING_DIR + m_localPath );
}

private void getRecursiveCommand( final Commandline cmd )


+ 13
- 22
proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/vss/MSVSSCHECKOUT.java View File

@@ -10,7 +10,6 @@ package org.apache.tools.todo.taskdefs.vss;
import java.io.File;
import org.apache.myrmidon.api.TaskException;
import org.apache.tools.todo.types.Commandline;
import org.apache.tools.todo.types.Path;

/**
* Task to perform CheckOut commands to Microsoft Visual Source Safe.
@@ -20,7 +19,7 @@ import org.apache.tools.todo.types.Path;
public class MSVSSCHECKOUT
extends MSVSS
{
private String m_localPath;
private File m_localPath;
private boolean m_recursive;
private String m_version;
private String m_date;
@@ -82,9 +81,9 @@ public class MSVSSCHECKOUT
/**
* Set the local path.
*/
public void setLocalpath( final Path localPath )
public void setLocalpath( final File localPath )
{
m_localPath = localPath.toString();
m_localPath = localPath;
}

/**
@@ -148,32 +147,24 @@ public class MSVSSCHECKOUT
public void getLocalpathCommand( final Commandline cmd )
throws TaskException
{
// make sure m_LocalDir exists, create it if it doesn't
if( m_localPath == null )
{
return;
}
else
if( !m_localPath.exists() )
{
// make sure m_LocalDir exists, create it if it doesn't
final File dir = getContext().resolveFile( m_localPath );
if( !dir.exists() )
if( !m_localPath.mkdirs() )
{
if( !dir.mkdirs() )
{
final String message =
"Directory " + m_localPath + " creation was not " +
"succesful for an unknown reason";
throw new TaskException( message );
}
else
{
final String message = "Created dir: " + dir.getAbsolutePath();
getContext().info( message );
}
final String message =
"Directory " + m_localPath + " creation was not " +
"succesful for an unknown reason";
throw new TaskException( message );
}
cmd.addArgument( FLAG_OVERRIDE_WORKING_DIR + m_localPath );
final String message = "Created dir: " + m_localPath.getAbsolutePath();
getContext().info( message );
}
cmd.addArgument( FLAG_OVERRIDE_WORKING_DIR + m_localPath );
}

private void getRecursiveCommand( final Commandline cmd )


+ 6
- 7
proposal/myrmidon/src/todo/org/apache/tools/todo/taskdefs/vss/MSVSSGET.java View File

@@ -206,7 +206,7 @@ import org.apache.tools.todo.types.Path;
public class MSVSSGET extends MSVSS
{

private String m_LocalPath = null;
private File m_LocalPath = null;
private boolean m_Recursive = false;
private boolean m_Writable = false;
private String m_Version = null;
@@ -296,9 +296,9 @@ public class MSVSSGET extends MSVSS
*
* @param localPath The new Localpath value
*/
public void setLocalpath( Path localPath )
public void setLocalpath( final File localPath )
{
m_LocalPath = localPath.toString();
m_LocalPath = localPath;
}

/**
@@ -379,17 +379,16 @@ public class MSVSSGET extends MSVSS
else
{
// make sure m_LocalDir exists, create it if it doesn't
File dir = getContext().resolveFile( m_LocalPath );
if( !dir.exists() )
if( !m_LocalPath.exists() )
{
boolean done = dir.mkdirs();
boolean done = m_LocalPath.mkdirs();
if( done == false )
{
String msg = "Directory " + m_LocalPath + " creation was not " +
"successful for an unknown reason";
throw new TaskException( msg );
}
getContext().info( "Created dir: " + dir.getAbsolutePath() );
getContext().info( "Created dir: " + m_LocalPath.getAbsolutePath() );
}

cmd.addArgument( FLAG_OVERRIDE_WORKING_DIR + m_LocalPath );


+ 2
- 2
proposal/myrmidon/src/todo/org/apache/tools/todo/types/Argument.java View File

@@ -60,9 +60,9 @@ public class Argument
*
* @param value a single commandline argument.
*/
public void setPath( final Path value )
public void setPath( final Path value ) throws TaskException
{
m_parts = new String[]{value.toString()};
m_parts = new String[]{ PathUtil.formatPath( value ) };
}

/**


+ 3
- 3
proposal/myrmidon/src/todo/org/apache/tools/todo/types/CommandlineJava.java View File

@@ -134,10 +134,10 @@ public class CommandlineJava
pos += m_sysProperties.size();
}
// classpath is a vm option too..
if( m_classpath != null && m_classpath.toString().trim().length() > 0 )
if( m_classpath != null && ! m_classpath.isEmpty() )
{
result[ pos++ ] = "-classpath";
result[ pos++ ] = m_classpath.toString();
result[ pos++ ] = PathUtil.formatPath( m_classpath );
}
// this is the classname to run as well as its arguments.
// in case of 'executeJar', the executable is a jar file.
@@ -226,7 +226,7 @@ public class CommandlineJava
{
int size = getActualVMCommand().size() + m_javaCommand.size() + m_sysProperties.size();
// classpath is "-classpath <classpath>" -> 2 args
if( m_classpath != null && m_classpath.toString().trim().length() > 0 )
if( m_classpath != null && ! m_classpath.isEmpty() )
{
size += 2;
}


+ 3
- 2
proposal/myrmidon/src/todo/org/apache/tools/todo/types/EnvironmentVariable.java View File

@@ -8,6 +8,7 @@
package org.apache.tools.todo.types;

import java.io.File;
import org.apache.myrmidon.api.TaskException;

public class EnvironmentVariable
{
@@ -24,9 +25,9 @@ public class EnvironmentVariable
m_key = key;
}

public void setPath( final Path path )
public void setPath( final Path path ) throws TaskException
{
m_value = path.toString();
m_value = PathUtil.formatPath( path );
}

public void setValue( final String value )


+ 24
- 80
proposal/myrmidon/src/todo/org/apache/tools/todo/types/Path.java View File

@@ -49,18 +49,12 @@ import org.apache.tools.todo.types.FileSet;
public class Path
implements DataType
{
private ArrayList m_elements = new ArrayList();
private final ArrayList m_elements = new ArrayList();
private File m_baseDirectory;

/**
* Invoked by IntrospectionHelper for <code>setXXX(Path p)</code> attribute
* setters.
*/
public Path( final String path )
{
final PathElement pathElement = new PathElement();
m_elements.add( pathElement );
pathElement.setPath( path );
addPath( path );
}

public Path()
@@ -86,6 +80,14 @@ public class Path
m_baseDirectory = baseDir;
}

/**
* Adds an element to the path.
*/
public void setLocation( final File location )
{
addLocation( location );
}

/**
* Adds a element definition to the path.
*
@@ -100,53 +102,29 @@ public class Path
}

/**
* Adds the components on the given path which exist to this Path.
* Components that don't exist, aren't added.
*
* @param source - source path whose components are examined for existence
* Adds a nested <code>&lt;fileset&gt;</code> element.
*/
public void addExisting( final Path source )
throws TaskException
public void addFileset( final FileSet fileSet )
{
final String[] list = source.list();
for( int i = 0; i < list.length; i++ )
{
final File file = new File( list[ i ] );
if( file.exists() )
{
addLocation( file );
}
}
m_elements.add( fileSet );
}

/**
* Adds a nested <code>&lt;fileset&gt;</code> element.
* Adds a path.
*/
public void addFileset( final FileSet fileSet )
public void setPath( final String path )
{
m_elements.add( fileSet );
addPath( path );
}

/**
* Append the contents of the other Path instance to this.
* Adds a path.
*/
public void append( final Path other )
throws TaskException
public void addPath( final String path )
{
if( null == other )
{
throw new NullPointerException( "other" );
}

final String[] list = other.list();
for( int i = 0; i < list.length; i++ )
{
final String file = list[ i ];
if( m_elements.contains( file ) )
{
m_elements.add( file );
}
}
final PathElement pathElement = new PathElement();
m_elements.add( pathElement );
pathElement.setPath( path );
}

/**
@@ -213,45 +191,11 @@ public class Path
}

/**
* How many parts does this Path instance consist of.
* Determines if this path is empty.
*/
public int size()
public boolean isEmpty()
throws TaskException
{
return list().length;
}

/**
* Returns a textual representation of the path, which can be used as
* CLASSPATH or PATH environment variable definition.
*
* @return a textual representation of the path.
*/
public String toString()
{
try
{
final String[] list = list();

// empty path return empty string
if( list.length == 0 )
{
return "";
}

// path containing one or more elements
final StringBuffer result = new StringBuffer( list[ 0 ].toString() );
for( int i = 1; i < list.length; i++ )
{
result.append( File.pathSeparatorChar );
result.append( list[ i ] );
}

return result.toString();
}
catch( final TaskException te )
{
throw new Error( te.toString() );
}
return ( list().length == 0 );
}
}

+ 1
- 1
proposal/myrmidon/src/todo/org/apache/tools/todo/types/PathElement.java View File

@@ -24,7 +24,7 @@ class PathElement
m_location = location.getAbsolutePath();
}

public void setPath( String path )
public void setPath( final String path )
{
m_path = path;
}


+ 36
- 6
proposal/myrmidon/src/todo/org/apache/tools/todo/types/PathUtil.java View File

@@ -23,6 +23,31 @@ import org.apache.tools.todo.types.Path;
*/
public class PathUtil
{
/**
* Formats a Path into its native representation.
*/
public static String formatPath( final Path path )
throws TaskException
{
final String[] list = path.list();

// empty path return empty string
if( list.length == 0 )
{
return "";
}

// path containing one or more elements
final StringBuffer result = new StringBuffer( list[ 0 ].toString() );
for( int i = 1; i < list.length; i++ )
{
result.append( File.pathSeparatorChar );
result.append( list[ i ] );
}

return result.toString();
}

/**
* Returns an array of URLs - useful for building a ClassLoader.
*/
@@ -45,11 +70,13 @@ public class PathUtil
}
catch( final IOException ioe )
{
final String message = "Malformed path entry. Reason:" + ioe;
throw new TaskException( message, ioe );
throw new TaskException( "Malformed path entry.", ioe );
}
}

/**
* Adds the JVM's runtime to a path.
*/
public static void addJavaRuntime( final Path path )
throws TaskException
{
@@ -76,26 +103,29 @@ public class PathUtil
// JDK > 1.1 seems to set java.home to the JRE directory.
final String rt = System.getProperty( "java.home" ) +
File.separator + "lib" + File.separator + "rt.jar";
path.addExisting( new Path( rt ) );
path.addLocation( new File( rt ) );
// Just keep the old version as well and let addExisting
// sort it out.
final String rt2 = System.getProperty( "java.home" ) +
File.separator + "jre" + File.separator + "lib" +
File.separator + "rt.jar";
path.addExisting( new Path( rt2 ) );
path.addLocation( new File( rt2 ) );

// Added for MacOS X
final String classes = System.getProperty( "java.home" ) +
File.separator + ".." + File.separator + "Classes" +
File.separator + "classes.jar";
path.addExisting( new Path( classes ) );
path.addLocation( new File( classes ) );
final String ui = System.getProperty( "java.home" ) +
File.separator + ".." + File.separator + "Classes" +
File.separator + "ui.jar";
path.addExisting( new Path( ui ) );
path.addLocation( new File( ui ) );
}
}

/**
* Adds the contents of a set of directories to a path.
*/
public static void addExtdirs( final Path toPath, final Path extDirs )
throws TaskException
{


+ 5
- 9
proposal/myrmidon/src/todo/org/apache/tools/todo/types/converters/StringToPathConverter.java View File

@@ -14,7 +14,10 @@ import org.apache.tools.todo.types.Path;
/**
* A converter from String to Path.
*
* @author Adam Murdoch
* @author <a href="mailto:adammurdoch@apache.org">Adam Murdoch</a>
* @version $Revision$ $Date$
*
* @ant:converter source="java.lang.String" destination="org.apache.tools.todo.types.Path"
*/
public class StringToPathConverter
extends AbstractConverter
@@ -33,20 +36,13 @@ public class StringToPathConverter
* @param original the original Object
* @param context the context in which to convert
* @return the converted object
* @exception java.lang.Exception if an error occurs
*/
protected Object convert( Object original, Object context )
protected Object convert( final Object original, final Object context )
throws ConverterException
{
/*
String path = (String)original;
TaskContext taskContext = (TaskContext)context;

Path retval = new Path( path );
retval.setBaseDirectory( taskContext.getBaseDirectory() );
return retval;
*/
return null;
}
}


+ 1
- 9
proposal/myrmidon/src/todo/org/apache/tools/todo/util/FileUtils.java View File

@@ -13,8 +13,6 @@ import java.util.Stack;
import java.util.StringTokenizer;
import org.apache.avalon.excalibur.io.FileUtil;
import org.apache.myrmidon.api.TaskException;
import org.apache.tools.todo.types.Path;
import org.apache.tools.todo.util.PathTokenizer;

/**
* This class also encapsulates methods which allow Files to be refered to using
@@ -242,13 +240,7 @@ public class FileUtils
}
}

public static String[] translateCommandline( Path to_process )
throws TaskException
{
return translateCommandline( to_process.toString() );
}

public static String[] translateCommandline( String to_process )
public static String[] translateCommandline( final String to_process )
throws TaskException
{
if( to_process == null || to_process.length() == 0 )


Loading…
Cancel
Save