uic.anttask
Class UICompiler

java.lang.Object
  extended byMatchingTask
      extended byuic.anttask.UICompiler

public class UICompiler
extends MatchingTask

The class that allows you to compile ui files into java files from ant. Since this class will only be usefull from ant, this javadoc will only discuss ant options.

Before asking questions; always refer to the ant manual first.

Before you start ant; make sure this class (in the form of the uic.jar) is in the classpath of ant. Read that again; ant needs uic.jar in its classpath!

In ant you need 2 parts; the first is to define the uicompile task in this form:

  <path id="uicompiler.classpath">
      <pathelement path="jars/uic.jar"/>
      <pathelement path="${jdomjar}/>
  </path>
  <taskdef name="uicompiler" classname="uic.anttask.UICompiler" classpathref="uicompiler.classpath"/>

Next you provide the ant task inside a target, like this:

  <target name="compile.ui.files">
      <uicompiler srcdir="." includes="**/*.ui" />
  </target>

Wnen called with ant compile.ui.files the java files will be created after which the normal step of compiling can take place.

Automatically creating a java file brings with it a problem that a clean task becomes a lot harder; you can't simply remove all files but need something more intelligent. The following target can also be placed in your ant build file to make sure that intelligence is exactly the thing that happens.

    <!-- clean up -->
    <target name="clean" description="Clean out compiled files">
        <delete>
            <fileset dir="." includes="**/*.java">
                <present targetdir="${src}">
                    <mapper type="glob" from="*.java" to="*.ui"/>
                </present>
            </fileset>
        </delete>
    </target>

 :

Parameters

Attribute Description Required
src The source base dir. Just like the javac task this should point to the dir that contains the base directory for your classes Yes
dest the destination directory where the generated files go. No
includes Comma- or space-separated list of files (may be specified using wildcard patterns) that must be included; all .ui files are included when omitted. No
excludes Comma- or space-separated list of files (may be specified using wildcard patterns) that must be excluded; no files (except default excludes) are excluded when omitted. No
source Generate compatible code with jre [source] version. Defaults to 1.4 No
listfiles Indicates whether the source files to be compiled will be listed; defaults to no. No
widgetset Overrule the widgetset to be used for compiling. Note that the uic.properties version will be used when empty; or when that is also not supplied the default "swing" will be used. No
postProcessor Overrule the postProcessor to be used for compiling. Note that the uic.properties version will be used when empty; or when that is also not supplied the default "fileWriter" will be used. No
debug Create java classes that include a main for quick start and check, defaults to no. No
buildProperties point to an alternative uic.properties file Not when in classpath

Since:
1.1
See Also:
Serialized Form

Field Summary
protected  File[] compileList
           
protected  boolean debug
           
protected  boolean debugGrid
           
protected  boolean listFiles
           
 
Constructor Summary
UICompiler()
           
 
Method Summary
protected  void checkParameters()
          Check that all required attributes have been set and nothing silly has been entered.
protected  void compile()
          Perform the compilation.
 void execute()
           
 boolean getListfiles()
          Get the listfiles flag.
protected  void resetFileLists()
          Clear the list of files to be compiled and copied..
protected  void scanDir(File srcDir, File destDir, String[] files)
          Scans the directory looking for source files to be compiled.
 void setBuildProperties(File propertiesFile)
           
 void setDebug(boolean debug)
           
 void setDestDir(File destDir)
           
 void setDrawGrid(boolean draw)
           
 void setListfiles(boolean list)
          If true, list the source files being handed off to the compiler.
 void setPostProcessor(String post)
           
 void setSource(String sourceVersion)
          Sourcecode version
 void setSrcDir(Path srcDir)
           
 void setWidgetSet(String widgetSet)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

compileList

protected File[] compileList

listFiles

protected boolean listFiles

debug

protected boolean debug

debugGrid

protected boolean debugGrid
Constructor Detail

UICompiler

public UICompiler()
Method Detail

setSrcDir

public void setSrcDir(Path srcDir)

setDestDir

public void setDestDir(File destDir)

setPostProcessor

public void setPostProcessor(String post)

setWidgetSet

public void setWidgetSet(String widgetSet)

setDebug

public void setDebug(boolean debug)

execute

public void execute()
             throws BuildException
Throws:
BuildException

scanDir

protected void scanDir(File srcDir,
                       File destDir,
                       String[] files)
Scans the directory looking for source files to be compiled. The results are returned in the class variable compileList


checkParameters

protected void checkParameters()
                        throws BuildException
Check that all required attributes have been set and nothing silly has been entered.

Throws:
BuildException

resetFileLists

protected void resetFileLists()
Clear the list of files to be compiled and copied..


compile

protected void compile()
Perform the compilation.


setListfiles

public void setListfiles(boolean list)
If true, list the source files being handed off to the compiler.


setDrawGrid

public void setDrawGrid(boolean draw)

getListfiles

public boolean getListfiles()
Get the listfiles flag.


setBuildProperties

public void setBuildProperties(File propertiesFile)

setSource

public void setSource(String sourceVersion)
Sourcecode version



Copyright © 2002,2003 Thomas Zander Available under the Free Apache licence