Class JDTCompiler

  • All Implemented Interfaces:
    org.codehaus.plexus.compiler.Compiler, org.codehaus.plexus.logging.LogEnabled

    @Component(role=org.codehaus.plexus.compiler.Compiler.class,
               hint="jdt")
    public class JDTCompiler
    extends org.codehaus.plexus.compiler.AbstractCompiler
    See http://help.eclipse.org/ganymede/topic/org.eclipse.jdt.doc.isv/guide/jdt_api_options.htm
    • Constructor Summary

      Constructors 
      Constructor Description
      JDTCompiler()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private void addExternalJavaHomeArgs​(java.util.List<java.lang.String> jdtCompilerArgs, java.lang.String javaHome)  
      private static void addMessageIfFound​(java.util.List<org.codehaus.plexus.compiler.CompilerMessage> messages, java.lang.String type, java.lang.String file, int line, java.lang.String message)  
      private void addToCompilerArgumentsIfNotSet​(java.lang.String argument, java.lang.String value, java.util.List<java.lang.String> compilerArguments)  
      java.lang.String[] buildCompilerArguments​(org.codehaus.plexus.compiler.CompilerConfiguration config, CustomCompilerConfiguration custom, java.lang.String[] sourceFiles)  
      private void checkCompilerArgs​(java.util.Collection<java.util.Map.Entry<java.lang.String,​java.lang.String>> argEntries, CustomCompilerConfiguration custom)
      check the compiler arguments.
      (package private) org.codehaus.plexus.compiler.CompilerResult compileInProcess​(java.lang.String[] args, CustomCompilerConfiguration custom)
      Compile the java sources in the current JVM, without calling an external executable, using com.sun.tools.javac.Main class
      (package private) org.codehaus.plexus.compiler.CompilerResult compileOutOfProcess​(java.io.File workingDirectory, java.lang.String executable, java.lang.String[] args)
      Compile the java sources in a external process, calling an external executable, like javac.
      private java.lang.String createClasspathArgument​(java.util.List<java.lang.String> classpath, CustomCompilerConfiguration custom)
      Copy the classpath to the command line with access rules included.
      java.lang.String[] createCommandLine​(org.codehaus.plexus.compiler.CompilerConfiguration config)  
      protected static java.util.List<org.codehaus.plexus.compiler.CompilerMessage> parseModernStream​(java.io.BufferedReader input)
      Parse the output from the compiler into a list of CompilerMessage objects
      org.codehaus.plexus.compiler.CompilerResult performCompile​(org.codehaus.plexus.compiler.CompilerConfiguration config)  
      private static boolean suppressEncoding​(org.codehaus.plexus.compiler.CompilerConfiguration config)  
      private static boolean suppressSource​(org.codehaus.plexus.compiler.CompilerConfiguration config)  
      • Methods inherited from class org.codehaus.plexus.compiler.AbstractCompiler

        canUpdateTarget, compile, getCompilerOutputStyle, getInputFileEnding, getOutputFile, getOutputFileEnding, getPathString, getSourceFiles, getSourceFilesForSourceRoot, makeClassName, toStringArray
      • Methods inherited from class org.codehaus.plexus.logging.AbstractLogEnabled

        enableLogging, getLogger, setupLogger, setupLogger, setupLogger
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • SEPARATOR_CHARS

        private static final char[] SEPARATOR_CHARS
      • ADAPTER_PREFIX

        private static final char[] ADAPTER_PREFIX
      • ADAPTER_ENCODING

        private static final char[] ADAPTER_ENCODING
      • ADAPTER_ACCESS

        private static final char[] ADAPTER_ACCESS
      • LINE_PATTERN

        static final java.util.regex.Pattern LINE_PATTERN
    • Constructor Detail

      • JDTCompiler

        public JDTCompiler()
    • Method Detail

      • performCompile

        public org.codehaus.plexus.compiler.CompilerResult performCompile​(org.codehaus.plexus.compiler.CompilerConfiguration config)
                                                                   throws org.codehaus.plexus.compiler.CompilerException
        Specified by:
        performCompile in interface org.codehaus.plexus.compiler.Compiler
        Overrides:
        performCompile in class org.codehaus.plexus.compiler.AbstractCompiler
        Throws:
        org.codehaus.plexus.compiler.CompilerException
      • createCommandLine

        public java.lang.String[] createCommandLine​(org.codehaus.plexus.compiler.CompilerConfiguration config)
                                             throws org.codehaus.plexus.compiler.CompilerException
        Throws:
        org.codehaus.plexus.compiler.CompilerException
      • buildCompilerArguments

        public java.lang.String[] buildCompilerArguments​(org.codehaus.plexus.compiler.CompilerConfiguration config,
                                                         CustomCompilerConfiguration custom,
                                                         java.lang.String[] sourceFiles)
      • suppressSource

        private static boolean suppressSource​(org.codehaus.plexus.compiler.CompilerConfiguration config)
      • suppressEncoding

        private static boolean suppressEncoding​(org.codehaus.plexus.compiler.CompilerConfiguration config)
      • compileOutOfProcess

        org.codehaus.plexus.compiler.CompilerResult compileOutOfProcess​(java.io.File workingDirectory,
                                                                        java.lang.String executable,
                                                                        java.lang.String[] args)
                                                                 throws org.codehaus.plexus.compiler.CompilerException
        Compile the java sources in a external process, calling an external executable, like javac.
        Parameters:
        workingDirectory - base directory where the process will be launched
        executable - name of the executable to launch
        args - arguments for the executable launched
        Returns:
        CompilerResult with the errors and warnings encountered.
        Throws:
        org.codehaus.plexus.compiler.CompilerException
      • compileInProcess

        org.codehaus.plexus.compiler.CompilerResult compileInProcess​(java.lang.String[] args,
                                                                     CustomCompilerConfiguration custom)
                                                              throws org.codehaus.plexus.compiler.CompilerException
        Compile the java sources in the current JVM, without calling an external executable, using com.sun.tools.javac.Main class
        Parameters:
        args - arguments for the compiler as they would be used in the command line javac
        Returns:
        CompilerResult with the errors and warnings encountered.
        Throws:
        org.codehaus.plexus.compiler.CompilerException
      • addExternalJavaHomeArgs

        private void addExternalJavaHomeArgs​(java.util.List<java.lang.String> jdtCompilerArgs,
                                             java.lang.String javaHome)
      • addToCompilerArgumentsIfNotSet

        private void addToCompilerArgumentsIfNotSet​(java.lang.String argument,
                                                    java.lang.String value,
                                                    java.util.List<java.lang.String> compilerArguments)
      • parseModernStream

        protected static java.util.List<org.codehaus.plexus.compiler.CompilerMessage> parseModernStream​(java.io.BufferedReader input)
                                                                                                 throws java.io.IOException
        Parse the output from the compiler into a list of CompilerMessage objects
        Parameters:
        input - The output of the compiler
        Returns:
        List of CompilerMessage objects
        Throws:
        java.io.IOException
      • addMessageIfFound

        private static void addMessageIfFound​(java.util.List<org.codehaus.plexus.compiler.CompilerMessage> messages,
                                              java.lang.String type,
                                              java.lang.String file,
                                              int line,
                                              java.lang.String message)
      • createClasspathArgument

        private java.lang.String createClasspathArgument​(java.util.List<java.lang.String> classpath,
                                                         CustomCompilerConfiguration custom)
        Copy the classpath to the command line with access rules included.
        Parameters:
        cmd - the given command line
        classpath - the given classpath entry
      • checkCompilerArgs

        private void checkCompilerArgs​(java.util.Collection<java.util.Map.Entry<java.lang.String,​java.lang.String>> argEntries,
                                       CustomCompilerConfiguration custom)
        check the compiler arguments. Extract from files specified using @, lines marked with ADAPTER_PREFIX. These lines specify information that needs to be interpreted by us.
        Parameters:
        args - compiler arguments to process