donaldp 02/01/18 23:26:23
Modified: proposal/myrmidon build.xml
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers
DefaultCompilerAdapter.java Gcj.java Jikes.java
Jvc.java Kjc.java
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/javadoc
Javadoc.java
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional
Javah.java
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ejb
BorlandGenerateClient.java IPlanetEjbcTask.java
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/javacc
JJTree.java JavaCC.java
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/jsp
WLJspc.java
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit
JUnitTask.java
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/metamata
AbstractMetamataTask.java MParse.java
proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/rmic
DefaultRmicAdapter.java
proposal/myrmidon/src/main/org/apache/tools/ant/types
CommandlineJava.java Path.java PathElement.java
proposal/myrmidon/src/main/org/apache/tools/ant/util
FileUtils.java
proposal/myrmidon/src/manifest ant1-ant-descriptor.xml
Added: proposal/myrmidon/src/main/org/apache/tools/ant/types/converters
StringToPathConverter.java
Log:
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.
* Moved Path.addExtdirs() -> DefaultCompilerAdaptor. This was the only
place it was used.
* Cleaned out a few more Path createX() methods.
Revision Changes Path
1.39 +0 -2 jakarta-ant/proposal/myrmidon/build.xml
Index: build.xml
===================================================================
RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/build.xml,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -r1.38 -r1.39
--- build.xml 15 Jan 2002 10:06:12 -0000 1.38
+++ build.xml 19 Jan 2002 07:26:21 -0000 1.39
@@ -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>
1.24 +42 -27
jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java
Index: DefaultCompilerAdapter.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- DefaultCompilerAdapter.java 12 Jan 2002 23:46:22 -0000 1.23
+++ DefaultCompilerAdapter.java 19 Jan 2002 07:26:21 -0000 1.24
@@ -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 );
+ }
+ }
+ }
+
}
1.7 +1 -1
jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/Gcj.java
Index: Gcj.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/Gcj.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- Gcj.java 30 Dec 2001 00:21:51 -0000 1.6
+++ Gcj.java 19 Jan 2002 07:26:21 -0000 1.7
@@ -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 ) )
{
1.9 +1 -1
jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/Jikes.java
Index: Jikes.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/Jikes.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- Jikes.java 30 Dec 2001 10:46:58 -0000 1.8
+++ Jikes.java 19 Jan 2002 07:26:21 -0000 1.9
@@ -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 ) )
{
1.6 +1 -1
jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/Jvc.java
Index: Jvc.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/Jvc.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- Jvc.java 30 Dec 2001 00:21:51 -0000 1.5
+++ Jvc.java 19 Jan 2002 07:26:21 -0000 1.6
@@ -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 ) )
{
1.8 +1 -1
jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/Kjc.java
Index: Kjc.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/compilers/Kjc.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- Kjc.java 30 Dec 2001 00:21:51 -0000 1.7
+++ Kjc.java 19 Jan 2002 07:26:21 -0000 1.8
@@ -94,7 +94,7 @@
if( m_extdirs != null )
{
- cp.addExtdirs( m_extdirs );
+ addExtdirs( cp );
}
cp.append( classpath );
1.14 +8 -6
jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/javadoc/Javadoc.java
Index: Javadoc.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/javadoc/Javadoc.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- Javadoc.java 15 Jan 2002 09:51:08 -0000 1.13
+++ Javadoc.java 19 Jan 2002 07:26:22 -0000 1.14
@@ -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" );
1.18 +12 -36
jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/Javah.java
Index: Javah.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/Javah.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- Javah.java 15 Jan 2002 09:51:08 -0000 1.17
+++ Javah.java 19 Jan 2002 07:26:22 -0000 1.18
@@ -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();
}
1.16 +2 -1
jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ejb/BorlandGenerateClient.java
Index: BorlandGenerateClient.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ejb/BorlandGenerateClient.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- BorlandGenerateClient.java 17 Jan 2002 08:04:54 -0000 1.15
+++ BorlandGenerateClient.java 19 Jan 2002 07:26:22 -0000 1.16
@@ -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" );
1.8 +7 -17
jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ejb/IPlanetEjbcTask.java
Index: IPlanetEjbcTask.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/ejb/IPlanetEjbcTask.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- IPlanetEjbcTask.java 15 Jan 2002 09:51:08 -0000 1.7
+++ IPlanetEjbcTask.java 19 Jan 2002 07:26:22 -0000 1.8
@@ -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 );
1.18 +1 -5
jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/javacc/JJTree.java
Index: JJTree.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/javacc/JJTree.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- JJTree.java 15 Jan 2002 09:51:08 -0000 1.17
+++ JJTree.java 19 Jan 2002 07:26:22 -0000 1.18
@@ -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();
1.13 +1 -5
jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/javacc/JavaCC.java
Index: JavaCC.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/javacc/JavaCC.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- JavaCC.java 15 Jan 2002 09:51:08 -0000 1.12
+++ JavaCC.java 19 Jan 2002 07:26:22 -0000 1.13
@@ -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();
1.17 +3 -1
jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/jsp/WLJspc.java
Index: WLJspc.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/jsp/WLJspc.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- WLJspc.java 17 Jan 2002 08:04:54 -0000 1.16
+++ WLJspc.java 19 Jan 2002 07:26:22 -0000 1.17
@@ -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
1.27 +2 -2
jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java
Index: JUnitTask.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- JUnitTask.java 15 Jan 2002 09:51:09 -0000 1.26
+++ JUnitTask.java 19 Jan 2002 07:26:22 -0000 1.27
@@ -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
{
1.18 +1 -4
jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/metamata/AbstractMetamataTask.java
Index: AbstractMetamataTask.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/metamata/AbstractMetamataTask.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- AbstractMetamataTask.java 15 Jan 2002 09:51:10 -0000 1.17
+++ AbstractMetamataTask.java 19 Jan 2002 07:26:22 -0000 1.18
@@ -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();
1.17 +1 -4
jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/metamata/MParse.java
Index: MParse.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/metamata/MParse.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- MParse.java 15 Jan 2002 09:51:10 -0000 1.16
+++ MParse.java 19 Jan 2002 07:26:22 -0000 1.17
@@ -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
1.11 +4 -24
jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/rmic/DefaultRmicAdapter.java
Index: DefaultRmicAdapter.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/rmic/DefaultRmicAdapter.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- DefaultRmicAdapter.java 13 Jan 2002 04:45:01 -0000 1.10
+++ DefaultRmicAdapter.java 19 Jan 2002 07:26:22 -0000 1.11
@@ -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;
}
1.17 +3 -5
jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/types/CommandlineJava.java
Index: CommandlineJava.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/types/CommandlineJava.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- CommandlineJava.java 12 Jan 2002 23:57:41 -0000 1.16
+++ CommandlineJava.java 19 Jan 2002 07:26:22 -0000 1.17
@@ -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;
}
1.18 +20 -152
jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/types/Path.java
Index: Path.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/types/Path.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- Path.java 15 Jan 2002 09:51:10 -0000 1.17
+++ Path.java 19 Jan 2002 07:26:22 -0000 1.18
@@ -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>" );
1.2 +12 -5
jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/types/PathElement.java
Index: PathElement.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/types/PathElement.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- PathElement.java 15 Jan 2002 09:51:10 -0000 1.1
+++ PathElement.java 19 Jan 2002 07:26:22 -0000 1.2
@@ -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 );
}
}
1.1
jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/types/converters/StringToPathConverter.java
Index: StringToPathConverter.java
===================================================================
/*
* 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.converters;
import org.apache.avalon.framework.context.Context;
import org.apache.myrmidon.converter.AbstractConverter;
import org.apache.myrmidon.converter.ConverterException;
import org.apache.tools.ant.types.Path;
/**
* A converter from String to Path.
*
* @author Adam Murdoch
*/
public class StringToPathConverter
extends AbstractConverter
{
/**
* Constructors a converter.
*/
public StringToPathConverter()
{
super( String.class, Path.class );
}
/**
* Converts from String to Path
*
* @param original the original Object
* @param context the context in which to convert
* @return the converted object
* @exception Exception if an error occurs
*/
protected Object convert( Object original, Context 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.15 +16 -27
jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/util/FileUtils.java
Index: FileUtils.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/util/FileUtils.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- FileUtils.java 15 Jan 2002 09:51:10 -0000 1.14
+++ FileUtils.java 19 Jan 2002 07:26:23 -0000 1.15
@@ -31,7 +31,7 @@
* @author [EMAIL PROTECTED]
* @author <a href="mailto:[EMAIL PROTECTED]">Conor MacNeill</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Stefan Bodewig</a>
- * @version $Revision: 1.14 $
+ * @version $Revision: 1.15 $
*/
public class FileUtils
{
@@ -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() );
}
1.3 +12 -0
jakarta-ant/proposal/myrmidon/src/manifest/ant1-ant-descriptor.xml
Index: ant1-ant-descriptor.xml
===================================================================
RCS file:
/home/cvs/jakarta-ant/proposal/myrmidon/src/manifest/ant1-ant-descriptor.xml,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ant1-ant-descriptor.xml 29 Jun 2001 02:40:09 -0000 1.2
+++ ant1-ant-descriptor.xml 19 Jan 2002 07:26:23 -0000 1.3
@@ -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>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>