com.izforge.izpack.installer
Class CompileWorker

java.lang.Object
  extended by com.izforge.izpack.installer.CompileWorker
All Implemented Interfaces:
java.lang.Runnable

public class CompileWorker
extends java.lang.Object
implements java.lang.Runnable

This class does alle the work for compiling sources.

It responsible for

Author:
Tino Schwarze

Nested Class Summary
private static class CompileWorker.CompilationJob
          a compilation job
private static class CompileWorker.EclipseStdErrHandler
          This PrintStream is used to track the Eclipse compiler error output.
private static class CompileWorker.EclipseStdOutHandler
          This PrintStream is used to track the Eclipse compiler output.
private static class CompileWorker.StdErrParser
           
private static class CompileWorker.StdOutParser
           
private static class CompileWorker.StreamParser
          Common class for parsing Eclipse compiler output.
 
Field Summary
private  java.util.ArrayList<java.lang.String> compilerArgumentsList
           
private  XMLElement compilerArgumentsSpec
           
private  java.lang.String compilerArgumentsToUse
           
private  java.util.ArrayList<java.lang.String> compilerList
           
private  XMLElement compilerSpec
           
private  java.lang.String compilerToUse
           
private static java.lang.String ECLIPSE_COMPILER_CLASS
           
private static java.lang.String ECLIPSE_COMPILER_NAME
           
private  CompileHandler handler
           
private  AutomatedInstallData idata
           
private  java.util.ArrayList<CompileWorker.CompilationJob> jobs
          Compilation jobs
private  CompileResult result
           
private  XMLElement spec
           
private static java.lang.String SPEC_RESOURCE_NAME
          Name of resource for specifying compilation parameters.
private  VariableSubstitutor vs
           
 
Constructor Summary
CompileWorker(AutomatedInstallData idata, CompileHandler handler)
          The constructor.
 
Method Summary
private  void changeClassPath(java.util.ArrayList classpath, XMLElement child)
          helper: process a <classpath> tag.
private  boolean collectJobs()
          Parse the compilation specification file and create jobs.
private  CompileWorker.CompilationJob collectJobsRecursive(XMLElement node, java.util.ArrayList classpath)
           
private  CompileResult compileJobs()
          perform the actual compilation
 java.util.ArrayList<java.lang.String> getAvailableArguments()
          Return list of compiler arguments to choose from.
 java.util.ArrayList<java.lang.String> getAvailableCompilers()
          Return list of compilers to choose from.
 java.lang.String getCompiler()
          Get the compiler used.
 java.lang.String getCompilerArguments()
          Get the compiler arguments used.
 CompileResult getResult()
          Get the result of the compilation.
private  void readChoices(XMLElement element, java.util.ArrayList<java.lang.String> choiceList)
           
private  boolean readSpec()
           
 void run()
          This is called when the compilation thread is activated.
private  java.util.ArrayList<java.io.File> scanDirectory(java.io.File path)
          helper: recursively scan given directory.
 void setCompiler(java.lang.String compiler)
          Set the compiler to use.
 void setCompilerArguments(java.lang.String arguments)
          Set the compiler arguments to use.
 void startThread()
          Start the compilation in a separate thread.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

jobs

private java.util.ArrayList<CompileWorker.CompilationJob> jobs
Compilation jobs


SPEC_RESOURCE_NAME

private static final java.lang.String SPEC_RESOURCE_NAME
Name of resource for specifying compilation parameters.

See Also:
Constant Field Values

ECLIPSE_COMPILER_NAME

private static final java.lang.String ECLIPSE_COMPILER_NAME
See Also:
Constant Field Values

ECLIPSE_COMPILER_CLASS

private static final java.lang.String ECLIPSE_COMPILER_CLASS
See Also:
Constant Field Values

vs

private VariableSubstitutor vs

spec

private XMLElement spec

idata

private AutomatedInstallData idata

handler

private CompileHandler handler

compilerSpec

private XMLElement compilerSpec

compilerList

private java.util.ArrayList<java.lang.String> compilerList

compilerToUse

private java.lang.String compilerToUse

compilerArgumentsSpec

private XMLElement compilerArgumentsSpec

compilerArgumentsList

private java.util.ArrayList<java.lang.String> compilerArgumentsList

compilerArgumentsToUse

private java.lang.String compilerArgumentsToUse

result

private CompileResult result
Constructor Detail

CompileWorker

public CompileWorker(AutomatedInstallData idata,
                     CompileHandler handler)
              throws java.io.IOException
The constructor.

Parameters:
idata - The installation data.
handler - The handler to notify of progress.
Throws:
java.io.IOException
Method Detail

getAvailableCompilers

public java.util.ArrayList<java.lang.String> getAvailableCompilers()
Return list of compilers to choose from.

Returns:
ArrayList of String

setCompiler

public void setCompiler(java.lang.String compiler)
Set the compiler to use.

The compiler is checked before compilation starts.

Parameters:
compiler - compiler to use (not checked)

getCompiler

public java.lang.String getCompiler()
Get the compiler used.

Returns:
the compiler.

getAvailableArguments

public java.util.ArrayList<java.lang.String> getAvailableArguments()
Return list of compiler arguments to choose from.

Returns:
ArrayList of String

setCompilerArguments

public void setCompilerArguments(java.lang.String arguments)
Set the compiler arguments to use.

Parameters:
arguments - The argument to use.

getCompilerArguments

public java.lang.String getCompilerArguments()
Get the compiler arguments used.

Returns:
The arguments used for compiling.

getResult

public CompileResult getResult()
Get the result of the compilation.

Returns:
The result.

startThread

public void startThread()
Start the compilation in a separate thread.


run

public void run()
This is called when the compilation thread is activated.

Can also be called directly if asynchronous processing is not desired.

Specified by:
run in interface java.lang.Runnable

readSpec

private boolean readSpec()

readChoices

private void readChoices(XMLElement element,
                         java.util.ArrayList<java.lang.String> choiceList)

collectJobs

private boolean collectJobs()
                     throws java.lang.Exception
Parse the compilation specification file and create jobs.

Throws:
java.lang.Exception

compileJobs

private CompileResult compileJobs()
perform the actual compilation


collectJobsRecursive

private CompileWorker.CompilationJob collectJobsRecursive(XMLElement node,
                                                          java.util.ArrayList classpath)
                                                   throws java.lang.Exception
Throws:
java.lang.Exception

changeClassPath

private void changeClassPath(java.util.ArrayList classpath,
                             XMLElement child)
                      throws java.lang.Exception
helper: process a <classpath> tag.

Throws:
java.lang.Exception

scanDirectory

private java.util.ArrayList<java.io.File> scanDirectory(java.io.File path)
helper: recursively scan given directory.

Returns:
list of files found (might be empty)