public class Main
extends java.lang.Object
Has several entrypoints: main
, mainExternal
, mainProgrammatic
,
mainExternalControlled
and mainProgrammaticControlled
.
The first is not intended to be used by applications other than jmake itself, whereas the
rest can be used to call jmake externally with various degrees of control over its behaviour.
See method comments for more details.
Modifier and Type | Field and Description |
---|---|
static int |
DEPJAR_ERROR
Produce an error message (throw an exception) upon a dependent
JAR detection. |
static int |
DEPJAR_NOWARNORERROR
Produce no warning or error message upon a dependent
JAR detection. |
static int |
DEPJAR_WARNING
Produce a warning upon a dependent
JAR detection. |
Constructor and Description |
---|
Main()
Construct a new instance of Main.
|
Modifier and Type | Method and Description |
---|---|
static void |
customizeOutput(boolean printInfoMessages,
boolean printWarningMessages,
boolean printErrorMessages)
Customize the output of jmake.
|
java.lang.String[] |
getUpdatedClasses()
Return the names of all classes that jmake, on this invocation, found updated - either because
jmake itself recompiled them or because they were updated independently (their timestamp/checksum
found different from those contained in the project database).
|
static java.lang.String |
getVersion()
Get the version of this copy of jmake
|
static void |
main(java.lang.String[] args)
Main entrypoint for the standalone jmake application.
|
int |
mainExternal(java.lang.String[] args)
Main entrypoint for applications that want to call jmake externally and would prefer
receiving an error code instead of an exception in case something goes wrong.
|
int |
mainExternalControlled(java.lang.String[] addedJavaFileNames,
java.lang.String[] removedJavaFileNames,
java.lang.String[] updatedJavaFileNames,
java.lang.String destDirName,
java.lang.String pdbFileName,
java.lang.Object externalApp,
java.lang.reflect.Method externalCompileSourceFilesMethod)
Main entrypoint for applications such as IDEs, that themselves keep track of updated/added/removed sources,
want to have full control over compilations that jmake invokes, and do not want to handle exceptions
that it may throw.
|
int |
mainExternalControlled(java.lang.String[] javaFileNames,
java.lang.String destDirName,
java.lang.String pdbFileName,
java.lang.Object externalApp,
java.lang.reflect.Method externalCompileSourceFilesMethod)
Main entrypoint for applications such as Ant, that want to have full control over
compilations that jmake invokes, and do not want to handle exceptions that it
may throw.
|
void |
mainProgrammatic(java.lang.String[] args)
Main entrypoint for applications that want to call jmake externally and are willing
to handle exceptions that it may throw.
|
void |
mainProgrammaticControlled(java.lang.String[] addedJavaFileNames,
java.lang.String[] removedJavaFileNames,
java.lang.String[] updatedJavaFileNames,
java.lang.String destDirName,
java.lang.String pdbFileName,
java.lang.Object externalApp,
java.lang.reflect.Method externalCompileSourceFilesMethod)
Main entrypoint for applications such as IDEs, that themselves keep track of updated/added/removed sources,
want to have full control over compilations that jmake invokes, and are willing to handle exceptions
that it may throw.
|
void |
mainProgrammaticControlled(java.lang.String[] javaFileNames,
java.lang.String destDirName,
java.lang.String pdbFileName,
java.lang.Object externalApp,
java.lang.reflect.Method externalCompileSourceFilesMethod)
Main entrypoint for applications such as Ant, that want to have full control over
compilations that jmake invokes, and are willing to handle exceptions
that it may throw.
|
static void |
setBootClassPath(java.lang.String classPath)
Set the boot class path to be used by the compiler (-bootclasspath option) and also by the dependency
checker (by default, the value of "sun.boot.class.path" property is used).
|
static void |
setClassPath(java.lang.String classPath)
Set the class path to be used by the compiler, and also by the dependency checker for the purposes of
superclass/superinterface change tracking.
|
static void |
setExtDirs(java.lang.String dirs)
Set the extensions location to be used by the compiler (-extdirs option) and also by the dependency
checker (by default, the value of "java.ext.dirs" property is used).
|
static void |
setOutputStreams(java.io.PrintStream out,
java.io.PrintStream warn,
java.io.PrintStream err)
Set the output print streams to be used by jmake.
|
static void |
setProjectClassPath(java.lang.String projectClassPath)
Set the class path to be used by the compiler, and also by the dependency checker for the purposes of
superclass/superinterface change tracking and sourceless class dependency checking.
|
void |
setResponseOnDependentJar(int code)
Set the response of jmake in case a dependence of a class located in a
JAR file on a
class with a .java source is detected (such dependencies are highly discouraged, since it is not
possible to recompile a class in the JAR that has no source). |
static void |
setVirtualPath(java.lang.String dirs)
Set the virtual path used to find both source and class files that are part of the project
but are not in the local directory.
|
public static final int DEPJAR_NOWARNORERROR
JAR
detection.public static final int DEPJAR_WARNING
JAR
detection.public static final int DEPJAR_ERROR
JAR
detection.public void mainProgrammatic(java.lang.String[] args) throws PublicExceptions.NoActionRequestedException, PublicExceptions.InvalidCmdOptionException, PublicExceptions.PDBCorruptedException, PublicExceptions.CommandFileReadException, PublicExceptions.CompilerInteractionException, PublicExceptions.ClassFileParseException, PublicExceptions.ClassNameMismatchException, PublicExceptions.InvalidSourceFileExtensionException, PublicExceptions.JarDependsOnSourceException, PublicExceptions.DoubleEntryException, java.io.FileNotFoundException, java.io.IOException, PublicExceptions.InternalException
args
- command line arguments passed to jmake.PublicExceptions.NoActionRequestedException
- if jmake was not requested to do any real work;PublicExceptions.InvalidCmdOptionException
- if invalid command line option was detected;PublicExceptions.PDBCorruptedException
- if project database is corrupted;PublicExceptions.CommandFileReadException
- if there was error reading a command file;PublicExceptions.CompilerInteractionException
- if there was a problem initializing or calling the compiler,
or compilation errors were detected;PublicExceptions.ClassFileParseException
- if there was error parsing a class file;PublicExceptions.ClassNameMismatchException
- if there is a mismatch between the deduced and the actual class name;PublicExceptions.InvalidSourceFileExtensionException
- if a supplied source file has an invalid extension (not .java);PublicExceptions.JarDependsOnSourceException
- if a class in a JAR
is found dependent on a class with the .java source;PublicExceptions.DoubleEntryException
- if more than one entry for the same class is found in the projectjava.io.FileNotFoundException
- if a .java
or a .class
file was not found;java.io.IOException
- if there was an I/O problem of any kind;PublicExceptions.InternalException
- if an internal problem that should never happen was detected.public int mainExternal(java.lang.String[] args)
args
- command line arguments passed to jmake. 0
if everything was successful;
-1
invalid command line option detected;
-2
error reading command file;
-3
project database corrupted;
-4
error initializing or calling the compiler;
-5
compilation error;
-6
error parsing a class file;
-7
file not found;
-8
I/O exception;
-9
internal jmake exception;
-10
deduced and actual class name mismatch;
-11
invalid source file extension;
-12
a class in a JAR
is found dependent on a class with the .java source;
-13
more than one entry for the same class is found in the project
-20
internal Java error (caused by java.lang.InternalError
);
-30
internal Java error (caused by java.lang.RuntimeException
).
public void mainProgrammaticControlled(java.lang.String[] javaFileNames, java.lang.String destDirName, java.lang.String pdbFileName, java.lang.Object externalApp, java.lang.reflect.Method externalCompileSourceFilesMethod) throws PublicExceptions.NoActionRequestedException, PublicExceptions.InvalidCmdOptionException, PublicExceptions.PDBCorruptedException, PublicExceptions.CommandFileReadException, PublicExceptions.CompilerInteractionException, PublicExceptions.ClassFileParseException, PublicExceptions.ClassNameMismatchException, PublicExceptions.InvalidSourceFileExtensionException, PublicExceptions.JarDependsOnSourceException, PublicExceptions.DoubleEntryException, PublicExceptions.InternalException, java.io.FileNotFoundException, java.io.IOException
javaFileNames
- array of strings that specify .java
file names.destDirName
- name of the destination directory (jmake will look up binary classes
in there, it should be the same as the one used by the Java compiler method).
If null
is passed, classes will be looked up in the same directories
as their sources, in agreement with the default Java compiler behaviour.pdbFileName
- project database file name (if null
is passed,
a file with the default name placed in the current directory will be used).externalApp
- an object on which to invoke externalCompileSourceFilesMethod
method.externalCompileSourceFilesMethod
- a method of the form int x(String[] args)
. It
should return 0
if compilation is successful and any non-zero value
otherwise. jmake passes it a list of the .java
files to
recompile in the form of canonical full path file names.PublicExceptions.NoActionRequestedException
- if jmake was not requested to do any real work;PublicExceptions.InvalidCmdOptionException
- if invalid command line option was detected;PublicExceptions.PDBCorruptedException
- if project database is corrupted;PublicExceptions.CommandFileReadException
- if there was error reading a command file;PublicExceptions.CompilerInteractionException
- if there was a problem initializing or calling the compiler,
or compilation errors were detected;PublicExceptions.ClassFileParseException
- if there was error parsing a class file;PublicExceptions.ClassNameMismatchException
- if there is a mismatch between the deduced and the actual class name;PublicExceptions.InvalidSourceFileExtensionException
- if a specified source file has an invalid extension (not .java);PublicExceptions.JarDependsOnSourceException
- if a class in a JAR
is found dependent on a class with the .java source;PublicExceptions.DoubleEntryException
- if more than one entry for the same class is found in the projectPublicExceptions.InternalException
- if an internal problem that should never happen was detected.java.io.FileNotFoundException
- if a .java
or a .class
file was not found;java.io.IOException
- if there was an I/O problem of any kind;public int mainExternalControlled(java.lang.String[] javaFileNames, java.lang.String destDirName, java.lang.String pdbFileName, java.lang.Object externalApp, java.lang.reflect.Method externalCompileSourceFilesMethod)
mainExternal(String[])
returns.javaFileNames
- array of strings that specify .java
file names.destDirName
- name of the destination directory (jmake will look up binary classes
in there, it should be the same as the one used by the Java compiler method).
If null
is passed, classes will be looked up in the same directories
as their sources, in agreement with the default Java compiler behaviour.pdbFileName
- project database file name (if null
is passed,
a file with the default name placed in the current directory will be used).externalApp
- an object on which to invoke externalCompileSourceFilesMethod
method.externalCompileSourceFilesMethod
- a method of the form int x(String[] args)
. It
should return 0
if compilation is successful and any non-zero value
otherwise. jmake passes it a list of the .java
files to
recompile in the form of canonical full path file names.mainExternal(String[])
public void mainProgrammaticControlled(java.lang.String[] addedJavaFileNames, java.lang.String[] removedJavaFileNames, java.lang.String[] updatedJavaFileNames, java.lang.String destDirName, java.lang.String pdbFileName, java.lang.Object externalApp, java.lang.reflect.Method externalCompileSourceFilesMethod) throws PublicExceptions.NoActionRequestedException, PublicExceptions.InvalidCmdOptionException, PublicExceptions.PDBCorruptedException, PublicExceptions.CommandFileReadException, PublicExceptions.CompilerInteractionException, PublicExceptions.ClassFileParseException, PublicExceptions.ClassNameMismatchException, PublicExceptions.InvalidSourceFileExtensionException, PublicExceptions.JarDependsOnSourceException, PublicExceptions.DoubleEntryException, PublicExceptions.InternalException, java.io.FileNotFoundException, java.io.IOException
addedJavaFileNames
- names of .java
files just added to the projectremovedJavaFileNames
- names of .java
files just removed from the projectupdatedJavaFileNames
- names of updated project .java
filesdestDirName
- name of the destination directory (jmake will look up binary classes
in there, it should be the same as the one used by the Java compiler method).
If null
is passed, classes will be looked up in the same directories
as their sources, in agreement with the default Java compiler behaviour.pdbFileName
- project database file name (if null
is passed,
a file with the default name placed in the current directory will be used).externalApp
- an object on which to invoke externalCompileSourceFilesMethod
method.externalCompileSourceFilesMethod
- a method of the form int x(String[] args)
. It
should return 0
if compilation is successful and any non-zero value
otherwise. jmake passes it a list of the .java
files to
recompile in the form of canonical full path file names.PublicExceptions.NoActionRequestedException
- if jmake was not requested to do any real work;PublicExceptions.InvalidCmdOptionException
- if invalid command line option was detected;PublicExceptions.PDBCorruptedException
- if project database is corrupted;PublicExceptions.CommandFileReadException
- if there was error reading a command file;PublicExceptions.CompilerInteractionException
- if there was a problem initializing or calling the compiler,
or compilation errors were detected;PublicExceptions.ClassFileParseException
- if there was error parsing a class file;PublicExceptions.ClassNameMismatchException
- if there is a mismatch between the deduced and the actual class name;PublicExceptions.InvalidSourceFileExtensionException
- if a specified source file has an invalid extension (not .java);PublicExceptions.JarDependsOnSourceException
- if a class in a JAR
is found dependent on a class with the .java source;PublicExceptions.DoubleEntryException
- if more than one entry for the same class is found in the projectPublicExceptions.InternalException
- if an internal problem that should never happen was detected.java.io.FileNotFoundException
- if a .java
or a .class
file was not found;java.io.IOException
- if there was an I/O problem of any kind;public int mainExternalControlled(java.lang.String[] addedJavaFileNames, java.lang.String[] removedJavaFileNames, java.lang.String[] updatedJavaFileNames, java.lang.String destDirName, java.lang.String pdbFileName, java.lang.Object externalApp, java.lang.reflect.Method externalCompileSourceFilesMethod)
mainExternal(String[])
returns.addedJavaFileNames
- names of .java
files just added to the projectremovedJavaFileNames
- names of .java
files just removed from the projectupdatedJavaFileNames
- names of updated project .java
filesdestDirName
- name of the destination directory (jmake will look up binary classes
in there, it should be the same as the one used by the Java compiler method).
If null
is passed, classes will be looked up in the same directories
as their sources, in agreement with the default Java compiler behaviour.pdbFileName
- project database file name (if null
is passed,
a file with the default name placed in the current directory will be used).externalApp
- an object on which to invoke externalCompileSourceFilesMethod
method.externalCompileSourceFilesMethod
- a method of the form int x(String[] args)
. It
should return 0
if compilation is successful and any non-zero value
otherwise. jmake passes it a list of the .java
files to
recompile in the form of canonical full path file names.mainExternal(String[])
public static void main(java.lang.String[] args)
mainExternal
, and its execution always completes with System.exit(code)
,
where code
is the value returned by mainExternal
.args
- command line arguments passed to jmakemainExternal(String[])
,
mainProgrammatic(String[])
public static void customizeOutput(boolean printInfoMessages, boolean printWarningMessages, boolean printErrorMessages)
printInfoMessages
- specify whether to print information messagesprintWarningMessages
- specify whether to print warning messagesprintErrorMessages
- specify whether to print error messagessetOutputStreams(PrintStream, PrintStream, PrintStream)
public static void setClassPath(java.lang.String classPath) throws PublicExceptions.InvalidCmdOptionException
classPath
- the value of the class path, in the usual format (i.e. entries that are directories
or JARs, separated by colon or semicolon depending on the platform).PublicExceptions.InvalidCmdOptionException
- if invalid class path value is specified.setProjectClassPath(String)
,
setBootClassPath(String)
,
setExtDirs(String)
public static void setProjectClassPath(java.lang.String projectClassPath) throws PublicExceptions.InvalidCmdOptionException
projectClassPath
- the value of the class path, in the usual format (i.e. entries that are directories
or JARs, separated by colon or semicolon depending on the platform).PublicExceptions.InvalidCmdOptionException
- if invalid class path value is specified.setClassPath(String)
public static void setBootClassPath(java.lang.String classPath) throws PublicExceptions.InvalidCmdOptionException
classPath
- the value of the boot class path, in the usual format (i.e. entries that are directories
or JARs, separated by colon or semicolon depending on the platform).PublicExceptions.InvalidCmdOptionException
- if invalid class path value is specified.setClassPath(String)
public static void setExtDirs(java.lang.String dirs) throws PublicExceptions.InvalidCmdOptionException
dirs
- the value of extension directories, in the usual format (one or more directory names
separated by colon or semicolon depending on the platform).PublicExceptions.InvalidCmdOptionException
- if invalid class path value is specified.setClassPath(String)
public static void setVirtualPath(java.lang.String dirs) throws PublicExceptions.InvalidCmdOptionException
dirs
- the value of extension directories, in the usual format (one or more directory names
separated by colon or semicolon depending on the platform).PublicExceptions.InvalidCmdOptionException
- if invalid path value is specified.setClassPath(String)
public void setResponseOnDependentJar(int code)
JAR
file on a
class with a .java
source is detected (such dependencies are highly discouraged, since it is not
possible to recompile a class in the JAR
that has no source).code
- response type: DEPJAR_NOWARNORERROR, DEPJAR_WARNING (default behaviour) or DEPJAR_ERROR.public java.lang.String[] getUpdatedClasses()
public static void setOutputStreams(java.io.PrintStream out, java.io.PrintStream warn, java.io.PrintStream err)
out
- print stream to be used for information ("logging") messages that jmake emitswarn
- print stream to be used for warning messageserr
- print stream to be used for error messagescustomizeOutput(boolean, boolean, boolean)
public static java.lang.String getVersion()