Hi, The attached patch makes <path> useable as a data-type in myrmidon.
* Added a String -> Path converter. * Added the appropriate declarations to ant1-ant-descriptor.xml. * PathLocation is now only used internally by Path. This means a <path> may not contain nested <pathlocation> elements any more. Nested <path> elements can be used to do the same thing. * Removed Path.systemClasspath and Path.concatSystemClassPath(). The goal is to add specialised <systemclasspath>, <antruntime>, and <javaruntime> data-types to control this explicitly. I left it unfinished, because the as-yet-unwritten Java util stuff will determine how it should be done. * Removed 'includeantruntime' and 'includejavaruntime' from <javac> and <rmic>. See above for reason. * Moved Path.addExtdirs() -> DefaultCompilerAdaptor. This was the only place it was used. * Cleaned out a few more Path createX() methods. BTW, Avalon's FileUtil.resolveFile() doesn't recognise windows absolute paths for some reason. Didn't bother hunting the problem down, cause the solution depends on what happens with the VFS (which absolutely does recognise them). Adam
? proposal/myrmidon/src/main/org/apache/tools/ant/types/converters Index: proposal/myrmidon/src/manifest/ant1-ant-descriptor.xml =================================================================== RCS file: /home/cvspublic/jakarta-ant/proposal/myrmidon/src/manifest/ant1-ant-descriptor.xml,v retrieving revision 1.2 diff -u -r1.2 ant1-ant-descriptor.xml --- proposal/myrmidon/src/manifest/ant1-ant-descriptor.xml 29 Jun 2001 02:40:09 -0000 1.2 +++ proposal/myrmidon/src/manifest/ant1-ant-descriptor.xml 18 Jan 2002 06:10:25 -0000 @@ -1,5 +1,17 @@ <ant-lib> + <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" /> </types> + + <converters> + <converter + classname="org.apache.tools.ant.types.converters.StringToPathConverter" + source="java.lang.String" + destination="org.apache.tools.ant.types.Path" + /> + </converters> </ant-lib> Index: proposal/myrmidon/build.xml =================================================================== RCS file: /home/cvspublic/jakarta-ant/proposal/myrmidon/build.xml,v retrieving revision 1.38 diff -u -r1.38 build.xml --- proposal/myrmidon/build.xml 15 Jan 2002 10:06:12 -0000 1.38 +++ proposal/myrmidon/build.xml 18 Jan 2002 06:10:26 -0000 @@ -387,14 +387,12 @@ </zipfileset> </jar> - <!-- <jar jarfile="${build.lib}/ant1.atl" basedir="${build.classes}"> <include name="org/apache/antlib/ant1/**"/> <zipfileset dir="${manifest.dir}" fullpath="META-INF/ant-descriptor.xml"> <include name="ant1-ant-descriptor.xml"/> </zipfileset> </jar> - --> </target> Index: proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Javac.java =================================================================== RCS file: /home/cvspublic/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Javac.java,v retrieving revision 1.25 diff -u -r1.25 Javac.java --- proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Javac.java 17 Jan 2002 08:04:54 -0000 1.25 +++ proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Javac.java 18 Jan 2002 06:10:28 -0000 @@ -64,8 +64,6 @@ private boolean deprecation = false; private boolean depend = false; private boolean verbose = false; - private boolean includeAntRuntime = true; - private boolean includeJavaRuntime = false; private String fork = "false"; private String forkedExecutable = null; private boolean nowarn = false; @@ -243,27 +241,6 @@ } /** - * Include ant's own classpath in this task's classpath? - * - * @param include The new Includeantruntime value - */ - public void setIncludeantruntime( boolean include ) - { - includeAntRuntime = include; - } - - /** - * Sets whether or not to include the java runtime libraries to this task's - * classpath. - * - * @param include The new Includejavaruntime value - */ - public void setIncludejavaruntime( boolean include ) - { - includeJavaRuntime = include; - } - - /** * Set the memoryInitialSize flag. * * @param memoryInitialSize The new MemoryInitialSize value @@ -499,28 +476,6 @@ public File[] getFileList() { return compileList; - } - - /** - * Gets whether or not the ant classpath is to be included in the task's - * classpath. - * - * @return The Includeantruntime value - */ - public boolean getIncludeantruntime() - { - return includeAntRuntime; - } - - /** - * Gets whether or not the java runtime should be included in this task's - * classpath. - * - * @return The Includejavaruntime value - */ - public boolean getIncludejavaruntime() - { - return includeJavaRuntime; } /** Index: proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Rmic.java =================================================================== RCS file: /home/cvspublic/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Rmic.java,v retrieving revision 1.23 diff -u -r1.23 Rmic.java --- proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Rmic.java 17 Jan 2002 08:04:54 -0000 1.23 +++ proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Rmic.java 18 Jan 2002 06:10:28 -0000 @@ -65,8 +65,6 @@ private boolean iiop; private boolean idl; private boolean debug; - private boolean includeAntRuntime; - private boolean includeJavaRuntime; private ArrayList compileList = new ArrayList(); @@ -191,27 +189,6 @@ } /** - * Include ant's own classpath in this task's classpath? - * - * @param include The new Includeantruntime value - */ - public void setIncludeantruntime( boolean include ) - { - includeAntRuntime = include; - } - - /** - * Sets whether or not to include the java runtime libraries to this task's - * classpath. - * - * @param include The new Includejavaruntime value - */ - public void setIncludejavaruntime( boolean include ) - { - includeJavaRuntime = include; - } - - /** * Sets the source dirs to find the source java files. * * @param sourceBase The new SourceBase value @@ -334,28 +311,6 @@ public String getIiopopts() { return iiopopts; - } - - /** - * Gets whether or not the ant classpath is to be included in the task's - * classpath. - * - * @return The Includeantruntime value - */ - public boolean getIncludeantruntime() - { - return includeAntRuntime; - } - - /** - * Gets whether or not the java runtime should be included in this task's - * classpath. - * - * @return The Includejavaruntime value - */ - public boolean getIncludejavaruntime() - { - return includeJavaRuntime; } /** Index: proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java =================================================================== RCS file: /home/cvspublic/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java,v retrieving revision 1.23 diff -u -r1.23 DefaultCompilerAdapter.java --- proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java 12 Jan 2002 23:46:22 -0000 1.23 +++ proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java 18 Jan 2002 06:10:29 -0000 @@ -14,10 +14,12 @@ import org.apache.avalon.excalibur.util.StringUtil; import org.apache.avalon.framework.logger.AbstractLogEnabled; import org.apache.myrmidon.api.TaskException; +import org.apache.myrmidon.api.TaskContext; import org.apache.tools.ant.taskdefs.Javac; import org.apache.tools.ant.taskdefs.exec.Execute2; import org.apache.tools.ant.types.Commandline; import org.apache.tools.ant.types.Path; +import org.apache.tools.ant.types.FileSet; /** * This is the default implementation for the CompilerAdapter interface. @@ -77,8 +79,6 @@ m_compileList = attributes.getFileList(); m_compileClasspath = attributes.getClasspath(); m_baseDir = attributes.getBaseDirectory(); - m_includeAntRuntime = attributes.getIncludeantruntime(); - m_includeJavaRuntime = attributes.getIncludejavaruntime(); m_memoryInitialSize = attributes.getMemoryInitialSize(); m_memoryMaximumSize = attributes.getMemoryMaximumSize(); } @@ -283,34 +283,13 @@ if( m_destDir != null ) { - classpath.setLocation( m_destDir ); + classpath.addLocation( m_destDir ); } - // Combine the build classpath with the system classpath, in an - // order determined by the value of build.classpath - - if( m_compileClasspath == null ) + // add the classpath + if ( m_compileClasspath != null ) { - if( m_includeAntRuntime ) - { - classpath.addExisting( Path.systemClasspath ); - } - } - else - { - if( m_includeAntRuntime ) - { - classpath.addExisting( m_compileClasspath.concatSystemClasspath( "last" ) ); - } - else - { - classpath.addExisting( m_compileClasspath.concatSystemClasspath( "ignore" ) ); - } - } - - if( m_includeJavaRuntime ) - { - classpath.addJavaRuntime(); + classpath.addExisting( m_compileClasspath ); } return classpath; @@ -437,5 +416,41 @@ getLogger().debug( niceSourceList.toString() ); } + + /** + * Emulation of extdirs feature in java >= 1.2. This method adds all files + * in the given directories (but not in sub-directories!) to the classpath, + * so that you don't have to specify them all one by one. + */ + protected void addExtdirs( Path path ) + throws TaskException + { + if( m_extdirs == null ) + { + String extProp = System.getProperty( "java.ext.dirs" ); + if( extProp != null ) + { + m_extdirs = new Path( extProp ); + } + else + { + return; + } + } + + final String[] dirs = m_extdirs.list(); + for( int i = 0; i < dirs.length; i++ ) + { + final File dir = new File( dirs[ i ] ); + if( dir.exists() && dir.isDirectory() ) + { + final FileSet fileSet = new FileSet(); + fileSet.setDir( dir ); + fileSet.setIncludes( "*" ); + path.addFileset( fileSet ); + } + } + } + } Index: proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/Gcj.java =================================================================== RCS file: /home/cvspublic/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/Gcj.java,v retrieving revision 1.6 diff -u -r1.6 Gcj.java --- proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/Gcj.java 30 Dec 2001 00:21:51 -0000 1.6 +++ proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/Gcj.java 18 Jan 2002 06:10:30 -0000 @@ -55,7 +55,7 @@ // gcj doesn't support an extension dir (-extdir) // so we'll emulate it for compatibility and convenience. - classpath.addExtdirs( m_extdirs ); + addExtdirs( classpath ); if( ( m_bootclasspath == null ) || ( m_bootclasspath.size() == 0 ) ) { Index: proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/Jikes.java =================================================================== RCS file: /home/cvspublic/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/Jikes.java,v retrieving revision 1.8 diff -u -r1.8 Jikes.java --- proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/Jikes.java 30 Dec 2001 10:46:58 -0000 1.8 +++ proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/Jikes.java 18 Jan 2002 06:10:30 -0000 @@ -52,7 +52,7 @@ // Jikes doesn't support an extension dir (-extdir) // so we'll emulate it for compatibility and convenience. - classpath.addExtdirs( m_extdirs ); + addExtdirs( classpath ); if( ( m_bootclasspath == null ) || ( m_bootclasspath.size() == 0 ) ) { Index: proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/Jvc.java =================================================================== RCS file: /home/cvspublic/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/Jvc.java,v retrieving revision 1.5 diff -u -r1.5 Jvc.java --- proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/Jvc.java 30 Dec 2001 00:21:51 -0000 1.5 +++ proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/Jvc.java 18 Jan 2002 06:10:30 -0000 @@ -40,7 +40,7 @@ // jvc doesn't support an extension dir (-extdir) // so we'll emulate it for compatibility and convenience. - classpath.addExtdirs( m_extdirs ); + addExtdirs( classpath ); if( ( m_bootclasspath == null ) || ( m_bootclasspath.size() == 0 ) ) { Index: proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/Kjc.java =================================================================== RCS file: /home/cvspublic/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/Kjc.java,v retrieving revision 1.7 diff -u -r1.7 Kjc.java --- proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/Kjc.java 30 Dec 2001 00:21:51 -0000 1.7 +++ proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/Kjc.java 18 Jan 2002 06:10:31 -0000 @@ -94,7 +94,7 @@ if( m_extdirs != null ) { - cp.addExtdirs( m_extdirs ); + addExtdirs( cp ); } cp.append( classpath ); Index: proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/javadoc/Javadoc.java =================================================================== RCS file: /home/cvspublic/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/javadoc/Javadoc.java,v retrieving revision 1.13 diff -u -r1.13 Javadoc.java --- proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/javadoc/Javadoc.java 15 Jan 2002 09:51:08 -0000 1.13 +++ proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/javadoc/Javadoc.java 18 Jan 2002 06:10:33 -0000 @@ -559,14 +559,16 @@ cmd.setExecutable( getJavadocExecutableName() ); // ------------------------------------------------ general javadoc arguments - if( m_classpath == null ) - m_classpath = Path.systemClasspath; - else - m_classpath = m_classpath.concatSystemClasspath( "ignore" ); + // Build the classpath to pass to Javadoc + Path classpath = new Path(); + classpath.addPath( m_sourcePath ); + if ( m_classpath != null ) + { + classpath.addPath( m_classpath ); + } cmd.createArgument().setValue( "-classpath" ); - cmd.createArgument().setValue( m_sourcePath.toString() + - System.getProperty( "path.separator" ) + m_classpath.toString() ); + cmd.createArgument().setValue( classpath.toString() ); if( m_version && m_doclet == null ) cmd.createArgument().setValue( "-version" ); Index: proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/Javah.java =================================================================== RCS file: /home/cvspublic/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/Javah.java,v retrieving revision 1.17 diff -u -r1.17 Javah.java --- proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/Javah.java 15 Jan 2002 09:51:08 -0000 1.17 +++ proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/Javah.java 18 Jan 2002 06:10:34 -0000 @@ -14,6 +14,7 @@ import org.apache.avalon.excalibur.util.StringUtil; import org.apache.avalon.framework.logger.AbstractLogEnabled; import org.apache.myrmidon.api.TaskException; +import org.apache.myrmidon.api.AbstractTask; import org.apache.tools.ant.types.Commandline; import org.apache.tools.ant.types.Path; @@ -52,7 +53,7 @@ */ public class Javah - extends AbstractLogEnabled + extends AbstractTask { private final static String FAIL_MSG = "Compile failed, messages should have been provided."; @@ -67,8 +68,10 @@ private String m_cls; private File m_destDir; - public void setBootclasspath( final Path bootclasspath ) - throws TaskException + /** + * Adds an element to the bootclasspath. + */ + public void addBootclasspath( final Path bootclasspath ) { if( m_bootclasspath == null ) { @@ -76,7 +79,7 @@ } else { - m_bootclasspath.append( bootclasspath ); + m_bootclasspath.addPath( bootclasspath ); } } @@ -85,7 +88,10 @@ m_cls = cls; } - public void setClasspath( final Path classpath ) + /** + * Adds an element to the classpath. + */ + public void addClasspath( final Path classpath ) throws TaskException { if( m_classpath == null ) @@ -94,7 +100,7 @@ } else { - m_classpath.append( classpath ); + m_classpath.addPath( classpath ); } } @@ -149,18 +155,6 @@ m_verbose = verbose; } - public Path createBootclasspath() - { - if( m_bootclasspath == null ) - { - m_bootclasspath = new Path(); - } - Path path1 = m_bootclasspath; - final Path path = new Path(); - path1.addPath( path ); - return path; - } - public ClassArgument createClass() { final ClassArgument ga = new ClassArgument(); @@ -169,18 +163,6 @@ return ga; } - public Path createClasspath() - { - if( m_classpath == null ) - { - m_classpath = new Path(); - } - Path path1 = m_classpath; - final Path path = new Path(); - path1.addPath( path ); - return path; - } - /** * Executes the task. */ @@ -188,12 +170,6 @@ throws TaskException { validate(); - - if( m_classpath == null ) - { - m_classpath = Path.systemClasspath; - } - doClassicCompile(); } Index: proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ejb/BorlandGenerateClient.java =================================================================== RCS file: /home/cvspublic/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ejb/BorlandGenerateClient.java,v retrieving revision 1.15 diff -u -r1.15 BorlandGenerateClient.java --- proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ejb/BorlandGenerateClient.java 17 Jan 2002 08:04:54 -0000 1.15 +++ proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ejb/BorlandGenerateClient.java 18 Jan 2002 06:10:34 -0000 @@ -215,7 +215,8 @@ //classpath //add at the end of the classpath //the system classpath in order to find the tools.jar file - execTask.addClasspath( classpath.concatSystemClasspath() ); + // TODO - make sure tools.jar is in the classpath + //execTask.addClasspath( classpath.concatSystemClasspath( "last" ) ); execTask.setFork( true ); execTask.createArg().setValue( "generateclient" ); Index: proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ejb/IPlanetEjbcTask.java =================================================================== RCS file: /home/cvspublic/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ejb/IPlanetEjbcTask.java,v retrieving revision 1.7 diff -u -r1.7 IPlanetEjbcTask.java --- proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ejb/IPlanetEjbcTask.java 15 Jan 2002 09:51:08 -0000 1.7 +++ proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ejb/IPlanetEjbcTask.java 18 Jan 2002 06:10:35 -0000 @@ -198,22 +198,6 @@ } /** - * Returns the CLASSPATH to be used when calling EJBc. If no user CLASSPATH - * is specified, the System classpath is returned instead. - * - * @return Path The classpath to be used for EJBc. - */ - private Path getClasspath() - { - if( classpath == null ) - { - classpath = Path.systemClasspath; - } - - return classpath; - } - - /** * Returns a SAXParser that may be used to process the XML descriptors. * * @return Parser which may be used to process the EJB descriptors. @@ -311,10 +295,16 @@ private void executeEjbc( SAXParser saxParser ) throws TaskException { + String classpath = null; + if( classpath != null ) + { + classpath = this.classpath.toString(); + } + IPlanetEjbc ejbc = new IPlanetEjbc( ejbdescriptor, iasdescriptor, dest, - getClasspath().toString(), + classpath, saxParser ); ejbc.setRetainSource( keepgenerated ); ejbc.setDebugOutput( debug ); Index: proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/javacc/JJTree.java =================================================================== RCS file: /home/cvspublic/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/javacc/JJTree.java,v retrieving revision 1.17 diff -u -r1.17 JJTree.java --- proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/javacc/JJTree.java 15 Jan 2002 09:51:08 -0000 1.17 +++ proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/javacc/JJTree.java 18 Jan 2002 06:10:36 -0000 @@ -17,7 +17,6 @@ import org.apache.tools.ant.types.Argument; import org.apache.tools.ant.types.CommandlineJava; import org.apache.tools.ant.types.Path; -import org.apache.tools.ant.types.PathElement; /** * Taskdef for the JJTree compiler compiler. @@ -175,10 +174,7 @@ throw new TaskException( "Javacchome not set." ); } final Path classpath = cmdl.createClasspath(); - final PathElement pathElement = new PathElement(); - classpath.addPathElement( pathElement ); - pathElement.setPath( javaccHome.getAbsolutePath() + - "/JavaCC.zip" ); + classpath.addLocation( new File( javaccHome, "JavaCC.zip" ) ); classpath.addJavaRuntime(); final Argument arg = cmdl.createVmArgument(); Index: proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/javacc/JavaCC.java =================================================================== RCS file: /home/cvspublic/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/javacc/JavaCC.java,v retrieving revision 1.12 diff -u -r1.12 JavaCC.java --- proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/javacc/JavaCC.java 15 Jan 2002 09:51:08 -0000 1.12 +++ proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/javacc/JavaCC.java 18 Jan 2002 06:10:37 -0000 @@ -18,7 +18,6 @@ import org.apache.tools.ant.types.Commandline; import org.apache.tools.ant.types.CommandlineJava; import org.apache.tools.ant.types.Path; -import org.apache.tools.ant.types.PathElement; import org.apache.avalon.excalibur.util.StringUtil; /** @@ -229,10 +228,7 @@ throw new TaskException( "Javacchome not set." ); } final Path classpath = cmdl.createClasspath(); - final PathElement pathElement = new PathElement(); - classpath.addPathElement( pathElement ); - pathElement.setPath( javaccHome.getAbsolutePath() + - "/JavaCC.zip" ); + classpath.addLocation( new File( javaccHome, "JavaCC.zip" ) ); classpath.addJavaRuntime(); final Argument arg = cmdl.createVmArgument(); Index: proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/jsp/WLJspc.java =================================================================== RCS file: /home/cvspublic/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/jsp/WLJspc.java,v retrieving revision 1.16 diff -u -r1.16 WLJspc.java --- proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/jsp/WLJspc.java 17 Jan 2002 08:04:54 -0000 1.16 +++ proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/jsp/WLJspc.java 18 Jan 2002 06:10:37 -0000 @@ -163,7 +163,9 @@ compileClasspath = new Path(); } - compileClasspath.append( Path.systemClasspath ); + // TODO - make sure tools.jar ends up in the classpath + //compileClasspath.append( Path.systemClasspath ); + String[] files = ds.getIncludedFiles(); //Weblogic.jspc calls System.exit() ... have to fork Index: proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java =================================================================== RCS file: /home/cvspublic/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java,v retrieving revision 1.26 diff -u -r1.26 JUnitTask.java --- proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java 15 Jan 2002 09:51:09 -0000 1.26 +++ proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java 18 Jan 2002 06:10:39 -0000 @@ -463,14 +463,14 @@ int pling = u.indexOf( "!" ); String jarName = u.substring( 9, pling ); getLogger().debug( "Implicitly adding " + jarName + " to classpath" ); - createClasspath().setLocation( new File( ( new File( jarName ) ).getAbsolutePath() ) ); + createClasspath().addLocation( new File( jarName ) ); } else if( u.startsWith( "file:" ) ) { int tail = u.indexOf( resource ); String dirName = u.substring( 5, tail ); getLogger().debug( "Implicitly adding " + dirName + " to classpath" ); - createClasspath().setLocation( new File( ( new File( dirName ) ).getAbsolutePath() ) ); + createClasspath().addLocation( new File( dirName ) ); } else { Index: proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/metamata/AbstractMetamataTask.java =================================================================== RCS file: /home/cvspublic/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/metamata/AbstractMetamataTask.java,v retrieving revision 1.17 diff -u -r1.17 AbstractMetamataTask.java --- proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/metamata/AbstractMetamataTask.java 15 Jan 2002 09:51:10 -0000 1.17 +++ proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/metamata/AbstractMetamataTask.java 18 Jan 2002 06:10:40 -0000 @@ -23,7 +23,6 @@ import org.apache.tools.ant.types.CommandlineJava; import org.apache.tools.ant.types.FileSet; 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 @@ -198,9 +197,7 @@ // set the classpath as the jar file File jar = getMetamataJar( m_metamataHome ); final Path classPath = m_cmdl.createClasspath(); - final PathElement pathElement = new PathElement(); - classPath.addPathElement( pathElement ); - pathElement.setLocation( jar ); + classPath.addLocation( jar ); // set the metamata.home property final Argument vmArgs = m_cmdl.createVmArgument(); Index: proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/metamata/MParse.java =================================================================== RCS file: /home/cvspublic/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/metamata/MParse.java,v retrieving revision 1.16 diff -u -r1.16 MParse.java --- proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/metamata/MParse.java 15 Jan 2002 09:51:10 -0000 1.16 +++ proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/metamata/MParse.java 18 Jan 2002 06:10:41 -0000 @@ -19,7 +19,6 @@ import org.apache.tools.ant.types.Argument; import org.apache.tools.ant.types.CommandlineJava; 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 @@ -204,9 +203,7 @@ final Path classPath = m_cmdl.createClasspath(); for( int i = 0; i < jars.length; i++ ) { - final PathElement pathElement = new PathElement(); - classPath.addPathElement( pathElement ); - pathElement.setLocation( jars[ i ] ); + classPath.addLocation( jars[ i ] ); } // set the metamata.home property Index: proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/rmic/DefaultRmicAdapter.java =================================================================== RCS file: /home/cvspublic/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/rmic/DefaultRmicAdapter.java,v retrieving revision 1.10 diff -u -r1.10 DefaultRmicAdapter.java --- proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/rmic/DefaultRmicAdapter.java 13 Jan 2002 04:45:01 -0000 1.10 +++ proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/rmic/DefaultRmicAdapter.java 18 Jan 2002 06:10:42 -0000 @@ -177,34 +177,14 @@ // add dest dir to classpath so that previously compiled and // untouched classes are on classpath Path classpath = new Path(); - classpath.setLocation( attributes.getBase() ); + classpath.addLocation( attributes.getBase() ); - // Combine the build classpath with the system classpath, in an - // order determined by the value of build.classpath - - if( attributes.getClasspath() == null ) - { - if( attributes.getIncludeantruntime() ) - { - classpath.addExisting( Path.systemClasspath ); - } - } - else + // add the classpath + if ( attributes.getClasspath() != null ) { - if( attributes.getIncludeantruntime() ) - { - classpath.addExisting( attributes.getClasspath().concatSystemClasspath( "last" ) ); - } - else - { - classpath.addExisting( attributes.getClasspath().concatSystemClasspath( "ignore" ) ); - } + classpath.addExisting( attributes.getClasspath() ); } - if( attributes.getIncludejavaruntime() ) - { - classpath.addJavaRuntime(); - } return classpath; } Index: proposal/myrmidon/src/main/org/apache/tools/ant/types/CommandlineJava.java =================================================================== RCS file: /home/cvspublic/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/types/CommandlineJava.java,v retrieving revision 1.16 diff -u -r1.16 CommandlineJava.java --- proposal/myrmidon/src/main/org/apache/tools/ant/types/CommandlineJava.java 12 Jan 2002 23:57:41 -0000 1.16 +++ proposal/myrmidon/src/main/org/apache/tools/ant/types/CommandlineJava.java 18 Jan 2002 06:10:43 -0000 @@ -132,11 +132,10 @@ pos += sysProperties.size(); } // classpath is a vm option too.. - Path fullClasspath = classpath != null ? classpath.concatSystemClasspath( "ignore" ) : null; - if( fullClasspath != null && fullClasspath.toString().trim().length() > 0 ) + if( classpath != null && classpath.toString().trim().length() > 0 ) { result[ pos++ ] = "-classpath"; - result[ pos++ ] = fullClasspath.toString(); + result[ pos++ ] = classpath.toString(); } // this is the classname to run as well as its arguments. // in case of 'executeJar', the executable is a jar file. @@ -215,8 +214,7 @@ { int size = getActualVMCommand().size() + javaCommand.size() + sysProperties.size(); // classpath is "-classpath <classpath>" -> 2 args - Path fullClasspath = classpath != null ? classpath.concatSystemClasspath( "ignore" ) : null; - if( fullClasspath != null && fullClasspath.toString().trim().length() > 0 ) + if( classpath != null && classpath.toString().trim().length() > 0 ) { size += 2; } Index: proposal/myrmidon/src/main/org/apache/tools/ant/types/Path.java =================================================================== RCS file: /home/cvspublic/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/types/Path.java,v retrieving revision 1.17 diff -u -r1.17 Path.java --- proposal/myrmidon/src/main/org/apache/tools/ant/types/Path.java 15 Jan 2002 09:51:10 -0000 1.17 +++ proposal/myrmidon/src/main/org/apache/tools/ant/types/Path.java 18 Jan 2002 06:10:43 -0000 @@ -7,16 +7,15 @@ */ package org.apache.tools.ant.types; +import org.apache.myrmidon.api.TaskException; +import org.apache.myrmidon.framework.DataType; +import org.apache.tools.ant.util.FileUtils; + import java.io.File; import java.io.IOException; import java.net.URL; import java.util.ArrayList; import java.util.Locale; -import org.apache.avalon.framework.logger.AbstractLogEnabled; -import org.apache.avalon.framework.logger.Logger; -import org.apache.myrmidon.api.TaskException; -import org.apache.tools.ant.ProjectComponent; -import org.apache.tools.ant.util.FileUtils; /** * This object represents a path as used by CLASSPATH or PATH environment @@ -50,41 +49,24 @@ * @author <a href="mailto:[EMAIL PROTECTED]">Stefan Bodewig</a> */ public class Path - extends ProjectComponent - implements Cloneable + implements DataType { - public final static Path systemClasspath = createSystemClasspath(); - - private ArrayList m_elements; - - private static Path createSystemClasspath() - { - try - { - return new Path( System.getProperty( "java.class.path" ) ); - } - catch( final TaskException te ) - { - throw new Error( te.toString() ); - } - } + private 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 ) - throws TaskException { - this(); final PathElement pathElement = new PathElement(); - addPathElement( pathElement ); + m_elements.add( pathElement ); pathElement.setPath( path ); } public Path() { - m_elements = new ArrayList(); } /** @@ -99,28 +81,24 @@ } /** - * Adds a element definition to the path. - * - * @param location the location of the element to add (must not be <code>null</code> - * nor empty. + * Sets the base directory for this path. */ - public void setLocation( final File location ) + public void setBaseDirectory( final File baseDir ) { - final PathElement pathElement = new PathElement(); - addPathElement( pathElement ); - pathElement.setLocation( location ); + m_baseDirectory = baseDir; } /** - * Parses a path definition and creates single PathElements. + * Adds a element definition to the path. * - * @param path the path definition. + * @param location the location of the element to add (must not be <code>null</code> + * nor empty. */ - public void setPath( String path ) + public void addLocation( final File location ) { final PathElement pathElement = new PathElement(); - addPathElement( pathElement ); - pathElement.setPath( path ); + m_elements.add( pathElement ); + pathElement.setLocation( location ); } /** @@ -138,42 +116,7 @@ final File file = new File( list[ i ] ); if( file.exists() ) { - setLocation( file ); - } - } - } - - /** - * Emulation of extdirs feature in java >= 1.2. This method adds all files - * in the given directories (but not in sub-directories!) to the classpath, - * so that you don't have to specify them all one by one. - */ - public void addExtdirs( Path extdirs ) - throws TaskException - { - if( extdirs == null ) - { - String extProp = System.getProperty( "java.ext.dirs" ); - if( extProp != null ) - { - extdirs = new Path( extProp ); - } - else - { - return; - } - } - - final String[] dirs = extdirs.list(); - for( int i = 0; i < dirs.length; i++ ) - { - final File dir = resolveFile( dirs[ i ] ); - if( dir.exists() && dir.isDirectory() ) - { - final FileSet fileSet = new FileSet(); - fileSet.setDir( dir ); - fileSet.setIncludes( "*" ); - addFileset( fileSet ); + addLocation( file ); } } } @@ -261,73 +204,6 @@ } /** - * Concatenates the system class path in the order specified by the - * ${build.sysclasspath} property - using "last" as default value. - * - * @return Description of the Returned Value - */ - public Path concatSystemClasspath() - throws TaskException - { - return concatSystemClasspath( "last" ); - } - - /** - * Concatenates the system class path in the order specified by the - * ${build.sysclasspath} property - using the supplied value if - * ${build.sysclasspath} has not been set. - * - * @param defValue Description of Parameter - * @return Description of the Returned Value - */ - public Path concatSystemClasspath( String defValue ) - throws TaskException - { - Path result = new Path(); - - String order = defValue; - if( getProject() != null ) - { - String o = getProject().getProperty( "build.sysclasspath" ); - if( o != null ) - { - order = o; - } - } - - if( order.equals( "only" ) ) - { - // only: the developer knows what (s)he is doing - result.addExisting( Path.systemClasspath ); - } - else if( order.equals( "first" ) ) - { - // first: developer could use a little help - result.addExisting( Path.systemClasspath ); - result.addExisting( this ); - } - else if( order.equals( "ignore" ) ) - { - // ignore: don't trust anyone - result.addExisting( this ); - } - else - { - // last: don't trust the developer - if( !order.equals( "last" ) ) - { - final String message = "invalid value for build.sysclasspath: " + order; - getLogger().warn( message ); - } - - result.addExisting( this ); - result.addExisting( Path.systemClasspath ); - } - - return result; - } - - /** * Creates a nested <code><path></code> element. * * @return Description of the Returned Value @@ -339,15 +215,8 @@ } /** - * Creates the nested <code><pathelement></code> element. - */ - public void addPathElement( final PathElement pathElement ) - { - m_elements.add( pathElement ); - } - - /** * Returns all path elements defined by this and nested path objects. + * The paths returned by this method are absolute. */ public String[] list() throws TaskException @@ -363,9 +232,8 @@ } else if( o instanceof PathElement ) { - final File baseDirectory = getBaseDirectory(); final PathElement element = (PathElement)o; - final String[] parts = element.getParts( baseDirectory, getLogger() ); + final String[] parts = element.getParts( m_baseDirectory ); if( parts == null ) { throw new NullPointerException( "You must either set location or path on <pathelement>" ); Index: proposal/myrmidon/src/main/org/apache/tools/ant/types/PathElement.java =================================================================== RCS file: /home/cvspublic/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/types/PathElement.java,v retrieving revision 1.1 diff -u -r1.1 PathElement.java --- proposal/myrmidon/src/main/org/apache/tools/ant/types/PathElement.java 15 Jan 2002 09:51:10 -0000 1.1 +++ proposal/myrmidon/src/main/org/apache/tools/ant/types/PathElement.java 18 Jan 2002 06:10:44 -0000 @@ -10,17 +10,19 @@ import java.io.File; import org.apache.tools.ant.util.FileUtils; import org.apache.avalon.framework.logger.Logger; +import org.apache.myrmidon.api.TaskException; /** - * Helper class, holds the nested <code><pathelement></code> values. + * Helper class, holds <code><></code> values. */ -public class PathElement +class PathElement { + private String m_location; private String m_path; public void setLocation( final File location ) { - m_path = FileUtils.translateFile( location.getAbsolutePath() ); + m_location = location.getAbsolutePath(); } public void setPath( String path ) @@ -28,8 +30,13 @@ m_path = path; } - protected String[] getParts( final File baseDirectory, final Logger logger ) + protected String[] getParts( final File baseDirectory ) + throws TaskException { - return FileUtils.translatePath( baseDirectory, m_path, logger ); + if ( m_location != null ) + { + return new String[] { m_location }; + } + return FileUtils.translatePath( baseDirectory, m_path ); } } Index: proposal/myrmidon/src/main/org/apache/tools/ant/util/FileUtils.java =================================================================== RCS file: /home/cvspublic/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/util/FileUtils.java,v retrieving revision 1.14 diff -u -r1.14 FileUtils.java --- proposal/myrmidon/src/main/org/apache/tools/ant/util/FileUtils.java 15 Jan 2002 09:51:10 -0000 1.14 +++ proposal/myrmidon/src/main/org/apache/tools/ant/util/FileUtils.java 18 Jan 2002 06:10:45 -0000 @@ -390,11 +390,7 @@ return ""; final StringBuffer result = new StringBuffer( source ); - for( int i = 0; i < result.length(); i++ ) - { - translateFileSep( result, i ); - } - + translateFileSep( result ); return result.toString(); } @@ -406,22 +402,25 @@ * @param pos Description of Parameter * @return Description of the Returned Value */ - public static boolean translateFileSep( StringBuffer buffer, int pos ) + public static void translateFileSep( StringBuffer buffer ) { - if( buffer.charAt( pos ) == '/' || buffer.charAt( pos ) == '\\' ) + int len = buffer.length(); + for ( int pos = 0; pos < len; pos++ ) { - buffer.setCharAt( pos, File.separatorChar ); - return true; + char ch = buffer.charAt( pos ); + if( ch == '/' || ch == '\\' ) + { + buffer.setCharAt( pos, File.separatorChar ); + } } - return false; } /** * Splits a PATH (with : or ; as separators) into its parts. */ public static String[] translatePath( final File baseDirectory, - String source, - final Logger logger ) + String source ) + throws TaskException { final ArrayList result = new ArrayList(); if( source == null ) @@ -431,23 +430,13 @@ StringBuffer element = new StringBuffer(); for( int i = 0; i < elements.length; i++ ) { + // Resolve the file relative to the base directory 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 ); - } + element.append( resolveFile( baseDirectory, pathElement ) ); - for( int j = 0; j < element.length(); j++ ) - { - translateFileSep( element, j ); - } + // Tidy up the separators + translateFileSep( element ); result.add( element.toString() ); }
StringToPathConverter.java
Description: Binary data
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>