wcs
Class JavacTask

java.lang.Object
  extended by wcs.Task
      extended by wcs.ProcessTask
          extended by wcs.JavacTask
All Implemented Interfaces:
Runnable

public class JavacTask
extends ProcessTask

task to run the Java compiler. BUG: this should not use ProcessTask. BUG: this does not support all conceivable options.


Nested Class Summary
 
Nested classes/interfaces inherited from class wcs.Task
Task.Exception, Task.In, Task.Out
 
Field Summary
protected  ArrayList args
          commandline.
 String className
          set by each call to addToSources(wcs.Task.In).
protected  StringBuffer classpath
          classpath.
 String packagePath
          set by each call to addToSources(wcs.Task.In).
protected static Pattern packagePattern
          pattern to extract package path, if any, and public class name.
protected  File src
          root of source file area.
 
Fields inherited from class wcs.ProcessTask
argv
 
Fields inherited from class wcs.Task
env, err, in, out
 
Constructor Summary
JavacTask(File tmpDir, Task.Out err, Properties env)
          required property: javac Java compiler Optional properties: javac.bootclasspath
javac.extdirs
intended for crosscompilation, e.g., version 1.3 for MSIE javac.deprecation true for Java compiler -deprecation option javac.source Java compiler -source value
 
Method Summary
 void addToClasspath(File component)
          add a component to the classpath.
 void addToSources(String packagePath, String className, Task.In in)
          add a source file: move the content to the workarea.
 void addToSources(Task.In in)
          add a source file.
static void main(String[] argv)
          test: run commandline with system properties, keep workarea.
 void run()
          insert args as ProcessTask.argv and insert classpath, delegate to base method.
 
Methods inherited from class wcs.ProcessTask
run
 
Methods inherited from class wcs.Task
In, In, In, Out, Out
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

packagePattern

protected static final Pattern packagePattern
pattern to extract package path, if any, and public class name. BUG: this will fail if a dotted path contains whitespace or comments.


classpath

protected final StringBuffer classpath
classpath.


src

protected final File src
root of source file area.


args

protected final ArrayList args
commandline.


packagePath

public String packagePath
set by each call to addToSources(wcs.Task.In).


className

public String className
set by each call to addToSources(wcs.Task.In).

Constructor Detail

JavacTask

public JavacTask(File tmpDir,
                 Task.Out err,
                 Properties env)
          throws IOException
required property:
javac Java compiler

Optional properties:

javac.bootclasspath
javac.extdirs
intended for crosscompilation, e.g., version 1.3 for MSIE
javac.deprecation true for Java compiler -deprecation option
javac.source Java compiler -source value

Parameters:
tmpDir - root of workarea; src will contain source files, classes will contain class files.
Throws:
IOException
Method Detail

addToClasspath

public void addToClasspath(File component)
                    throws IOException
add a component to the classpath.

Throws:
IOException

addToSources

public void addToSources(Task.In in)
                  throws IOException
add a source file. Does not allow java.lang as a package path or prefix, does not allow System as a classname, silently overwrites duplicate files. Sets packagePath and className.

Throws:
IOException

addToSources

public void addToSources(String packagePath,
                         String className,
                         Task.In in)
                  throws IOException
add a source file: move the content to the workarea.

Throws:
IOException

run

public void run()
         throws Task.Exception
insert args as ProcessTask.argv and insert classpath, delegate to base method.

Specified by:
run in interface Runnable
Overrides:
run in class ProcessTask
Throws:
Task.Exception

main

public static void main(String[] argv)
                 throws Exception
test: run commandline with system properties, keep workarea.

Throws:
Exception