Class AbstractCompileMojo

  • All Implemented Interfaces:
    org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo
    Direct Known Subclasses:
    CompileMojo, CompileTestsMojo

    public abstract class AbstractCompileMojo
    extends AbstractGroovySourcesMojo
    The base compile mojo, which all compile mojos extend.
    Since:
    1.0-beta-1
    • Field Detail

      • GROOVY_4_0_0_BETA1

        protected static final Version GROOVY_4_0_0_BETA1
        Groovy 4.0.0 beta-1 version.
      • GROOVY_4_0_0_ALPHA3

        protected static final Version GROOVY_4_0_0_ALPHA3
        Groovy 4.0.0 alpha-3 version.
      • GROOVY_4_0_0_ALPHA1

        protected static final Version GROOVY_4_0_0_ALPHA1
        Groovy 4.0.0 alpha-1 version.
      • GROOVY_3_0_8

        protected static final Version GROOVY_3_0_8
        Groovy 3.0.8 version.
      • GROOVY_3_0_6

        protected static final Version GROOVY_3_0_6
        Groovy 3.0.6 version.
      • GROOVY_3_0_5

        protected static final Version GROOVY_3_0_5
        Groovy 3.0.5 version.
      • GROOVY_3_0_3

        protected static final Version GROOVY_3_0_3
        Groovy 3.0.3 version.
      • GROOVY_3_0_0_BETA2

        protected static final Version GROOVY_3_0_0_BETA2
        Groovy 3.0.0 beta-2 version.
      • GROOVY_3_0_0_BETA1

        protected static final Version GROOVY_3_0_0_BETA1
        Groovy 3.0.0 beta-1 version.
      • GROOVY_3_0_0_ALPHA4

        protected static final Version GROOVY_3_0_0_ALPHA4
        Groovy 3.0.0 alpha-4 version.
      • GROOVY_3_0_0_ALPHA2

        protected static final Version GROOVY_3_0_0_ALPHA2
        Groovy 3.0.0 alpha-2 version.
      • GROOVY_3_0_0_ALPHA1

        protected static final Version GROOVY_3_0_0_ALPHA1
        Groovy 3.0.0 alpha-1 version.
      • GROOVY_2_6_0_ALPHA4

        protected static final Version GROOVY_2_6_0_ALPHA4
        Groovy 2.6.0 alpha-4 version.
      • GROOVY_2_6_0_ALPHA1

        protected static final Version GROOVY_2_6_0_ALPHA1
        Groovy 2.6.0 alpha-1 version.
      • GROOVY_2_5_7

        protected static final Version GROOVY_2_5_7
        Groovy 2.5.7 version.
      • GROOVY_2_5_3

        protected static final Version GROOVY_2_5_3
        Groovy 2.5.3 version.
      • GROOVY_2_5_0_ALPHA1

        protected static final Version GROOVY_2_5_0_ALPHA1
        Groovy 2.5.0 alpha-1 version.
      • GROOVY_2_3_3

        protected static final Version GROOVY_2_3_3
        Groovy 2.3.3 version.
      • GROOVY_2_1_3

        protected static final Version GROOVY_2_1_3
        Groovy 2.1.3 version.
      • GROOVY_2_1_0_BETA1

        protected static final Version GROOVY_2_1_0_BETA1
        Groovy 2.1.0 beta-1 version.
      • GROOVY_2_0_0_BETA3

        protected static final Version GROOVY_2_0_0_BETA3
        Groovy 2.0.0 beta-3 version.
      • GROOVY_1_6_0

        protected static final Version GROOVY_1_6_0
        Groovy 1.6.0 version.
      • sourceEncoding

        @Parameter(defaultValue="${project.build.sourceEncoding}")
        protected java.lang.String sourceEncoding
        The encoding of source files.
      • targetBytecode

        @Parameter(property="maven.compiler.target",
                   defaultValue="1.8")
        protected java.lang.String targetBytecode
        The Groovy compiler bytecode compatibility. One of
        • 1.4
        • 1.5
        • 1.6
        • 1.7
        • 1.8
        • 9
        • 10
        • 11
        • 12
        • 13
        • 14
        • 15
        • 16
        • 17
        • 18
        Using 1.6 or 1.7 requires Groovy >= 2.1.3. Using 1.8 requires Groovy >= 2.3.3. Using 9 requires Groovy >= 2.5.3, or Groovy >= 2.6.0 alpha 4, or Groovy >= 3.0.0 alpha 2. Using 9 with invokedynamic requires Groovy >= 2.5.3, or Groovy >= 3.0.0 alpha 2, but not any 2.6 versions. Using 10, 11, or 12 requires Groovy >= 2.5.3, or Groovy >= 3.0.0 alpha 4, but not any 2.6 versions. Using 13 requires Groovy >= 2.5.7, or Groovy >= 3.0.0-beta-1, but not any 2.6 versions. Using 14 requires Groovy >= 3.0.0 beta-2. Using 15 requires Groovy >= 3.0.3. Using 16 requires Groovy >= 3.0.6. Using 17 requires Groovy >= 3.0.8 or Groovy > 4.0.0-alpha-3. Using 18 requires Groovy > 4.0.0-beta-1.
      • skipBytecodeCheck

        @Parameter(property="skipBytecodeCheck",
                   defaultValue="false")
        protected boolean skipBytecodeCheck
        Whether to check that the version of Groovy used is able to use the requested targetBytecode.
        Since:
        1.9.0
      • debug

        @Parameter(defaultValue="false")
        protected boolean debug
        Whether Groovy compiler should be set to debug.
      • verbose

        @Parameter(defaultValue="false")
        protected boolean verbose
        Whether Groovy compiler should be set to verbose.
      • warningLevel

        @Parameter(defaultValue="1")
        protected int warningLevel
        Groovy compiler warning level. Should be one of:
        0
        None
        1
        Likely Errors
        2
        Possible Errors
        3
        Paranoia
      • tolerance

        @Parameter(defaultValue="0")
        protected int tolerance
        Groovy compiler error tolerance (the number of non-fatal errors (per unit) that should be tolerated before compilation is aborted).
      • invokeDynamic

        @Parameter(defaultValue="false")
        protected boolean invokeDynamic
        Whether to support invokeDynamic (requires Java 7 or greater and Groovy indy 2.0.0-beta-3 or greater). Has no effect for Groovy 4, as it is always enabled.
      • parallelParsing

        @Parameter
        protected java.lang.Boolean parallelParsing
        Whether to enable Groovy's parallel parsing. Requires Groovy 3.0.5. Is enabled by default for Groovy 4.0.0-alpha-1 or newer.
        Since:
        1.11.0
      • configScript

        @Parameter
        protected java.io.File configScript
        A script for tweaking the configuration options (requires Groovy 2.1.0-beta-1 or greater). Note that its encoding must match your source encoding.
      • parameters

        @Parameter(defaultValue="false")
        protected boolean parameters
        Generate metadata for reflection on method parameter names using the functionality provided by JEP 118 (requires Java 8 or greater and Groovy 2.5.0-alpha-1 or greater).
      • includeClasspath

        @Parameter(defaultValue="PROJECT_ONLY")
        protected IncludeClasspath includeClasspath
        What classpath to include. One of
        • PROJECT_ONLY
        • PROJECT_AND_PLUGIN
        • PLUGIN_ONLY
        Uses the same scope as the required dependency resolution of this mojo. Use only if you know what you're doing.
        Since:
        1.8.0
      • previewFeatures

        @Parameter(defaultValue="false")
        protected boolean previewFeatures
        Whether the bytecode version has preview features enabled (JEP 12). Requires Groovy >= 3.0.0-beta-1 or Groovy >= 2.5.7, but not any 2.6 versions and Java >= 12.
        Since:
        1.7.1
    • Constructor Detail

      • AbstractCompileMojo

        public AbstractCompileMojo()
    • Method Detail

      • doCompile

        protected void doCompile​(java.util.Set<java.io.File> sources,
                                 java.util.List classpath,
                                 java.io.File compileOutputDirectory)
                          throws java.lang.ClassNotFoundException,
                                 java.lang.InstantiationException,
                                 java.lang.IllegalAccessException,
                                 java.lang.reflect.InvocationTargetException,
                                 java.net.MalformedURLException
        Performs compilation of compile mojos.
        Parameters:
        sources - the sources to compile
        classpath - the classpath to use for compilation
        compileOutputDirectory - the directory to write the compiled class files to
        Throws:
        java.lang.ClassNotFoundException - when a class needed for compilation cannot be found
        java.lang.InstantiationException - when a class needed for compilation cannot be instantiated
        java.lang.IllegalAccessException - when a method needed for compilation cannot be accessed
        java.lang.reflect.InvocationTargetException - when a reflection invocation needed for compilation cannot be completed
        java.net.MalformedURLException - when a classpath element provides a malformed URL
      • setupCompilationUnit

        protected java.lang.Object setupCompilationUnit​(java.util.Set<java.io.File> sources,
                                                        java.lang.Class<?> compilerConfigurationClass,
                                                        java.lang.Class<?> compilationUnitClass,
                                                        java.lang.Class<?> groovyClassLoaderClass,
                                                        java.lang.Object compilerConfiguration,
                                                        java.lang.Object groovyClassLoader,
                                                        java.lang.Object transformLoader)
                                                 throws java.lang.reflect.InvocationTargetException,
                                                        java.lang.IllegalAccessException,
                                                        java.lang.InstantiationException
        Sets up the CompilationUnit to use for compilation.
        Parameters:
        sources - the sources to compile
        compilerConfigurationClass - the CompilerConfiguration class
        compilationUnitClass - the CompilationUnit class
        groovyClassLoaderClass - the GroovyClassLoader class
        compilerConfiguration - the CompilerConfiguration
        groovyClassLoader - the GroovyClassLoader
        transformLoader - the GroovyClassLoader to use for transformation
        Returns:
        the CompilationUnit
        Throws:
        java.lang.InstantiationException - when a class needed for setting up compilation unit cannot be instantiated
        java.lang.IllegalAccessException - when a method needed for setting up compilation unit cannot be accessed
        java.lang.reflect.InvocationTargetException - when a reflection invocation needed for setting up compilation unit cannot be completed
      • setupCompilerConfiguration

        protected java.lang.Object setupCompilerConfiguration​(java.io.File compileOutputDirectory,
                                                              java.lang.Class<?> compilerConfigurationClass)
                                                       throws java.lang.reflect.InvocationTargetException,
                                                              java.lang.IllegalAccessException,
                                                              java.lang.InstantiationException,
                                                              java.lang.ClassNotFoundException
        Sets up the CompilationConfiguration to use for compilation.
        Parameters:
        compileOutputDirectory - the directory to write the compiled classes to
        compilerConfigurationClass - the CompilerConfiguration class
        Returns:
        the CompilerConfiguration
        Throws:
        java.lang.ClassNotFoundException - when a class needed for setting up CompilerConfiguration cannot be found
        java.lang.InstantiationException - when a class needed for setting up CompilerConfiguration cannot be instantiated
        java.lang.IllegalAccessException - when a method needed for setting up CompilerConfiguration cannot be accessed
        java.lang.reflect.InvocationTargetException - when a reflection invocation needed for setting up CompilerConfiguration cannot be completed
      • verifyGroovyVersionSupportsTargetBytecode

        protected void verifyGroovyVersionSupportsTargetBytecode()
        Throws an exception if targetBytecode is not supported with this version of Groovy. That is, when Groovy added the option to org.codehaus.groovy.control.CompilerConfiguration and used it in org.codehaus.groovy.classgen.asm.WriterController.