Class CompilerMojo

  • All Implemented Interfaces:
    org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo

    @Mojo(name="compile",
          defaultPhase=COMPILE,
          threadSafe=true,
          requiresDependencyResolution=COMPILE)
    public class CompilerMojo
    extends AbstractCompilerMojo
    Compiles application sources. By default uses the javac compiler of the JDK used to execute Maven. This can be overwritten through Toolchains or parameter AbstractCompilerMojo.compilerId.
    Since:
    2.0
    See Also:
    javac Command
    • Field Detail

      • compileSourceRoots

        @Parameter(defaultValue="${project.compileSourceRoots}",
                   readonly=false,
                   required=true)
        private java.util.List<java.lang.String> compileSourceRoots
        The source directories containing the sources to be compiled.
      • outputDirectory

        @Parameter(property="maven.compiler.outputDirectory",
                   defaultValue="${project.build.outputDirectory}",
                   required=true,
                   readonly=false)
        private java.io.File outputDirectory
        The directory for compiled classes.

        This parameter should only be modified in special cases. One example is creating a multi-release jar with a lower bytecode level (i.e. setting it to ${project.build.outputDirectory}/META-INF/versions/21 or similar) in an additional execution.

        When the required bytecode level is available though an installed JDK or toolchain, it is recommended to use the <release> property in conjunction with the ${multiReleaseOutput} parameter instead.

      • projectArtifact

        @Parameter(defaultValue="${project.artifact}",
                   readonly=true,
                   required=true)
        private org.apache.maven.artifact.Artifact projectArtifact
        Projects main artifact.
      • includes

        @Parameter
        private java.util.Set<java.lang.String> includes
        A list of inclusion filters for the compiler.
      • excludes

        @Parameter
        private java.util.Set<java.lang.String> excludes
        A list of exclusion filters for the compiler.
      • incrementalExcludes

        @Parameter
        private java.util.Set<java.lang.String> incrementalExcludes
        A list of exclusion filters for the incremental calculation.
        Since:
        3.11
      • generatedSourcesDirectory

        @Parameter(defaultValue="${project.build.directory}/generated-sources/annotations")
        private java.io.File generatedSourcesDirectory
        Specify where to place generated source files created by annotation processing. Only applies to JDK 1.6+
        Since:
        2.2
      • skipMain

        @Parameter(property="maven.main.skip")
        private boolean skipMain
        Set this to true to bypass compilation of main sources. Its use is NOT RECOMMENDED, but quite convenient on occasion.
      • compilePath

        @Parameter(defaultValue="${project.compileClasspathElements}",
                   readonly=true,
                   required=true)
        private java.util.List<java.lang.String> compilePath
      • multiReleaseOutput

        @Parameter
        private boolean multiReleaseOutput

        When set to true, the classes will be placed in META-INF/versions/${release} The release value must be set, otherwise the plugin will fail.

        Note: A jar is only a multirelease jar if META-INF/MANIFEST.MF contains Multi-Release: true. You need to set this by configuring the maven-jar-plugin. This implies that you cannot test a multirelease jar using the outputDirectory.
        Since:
        3.7.1
      • moduleVersion

        @Parameter(property="maven.compiler.moduleVersion",
                   defaultValue="${project.version}")
        private java.lang.String moduleVersion
        The --module-version argument for the Java compiler. This is ignored if not applicable, e.g., in non-modular projects.
        Since:
        3.14.0
        See Also:
        javac --module-version
      • locationManager

        final org.codehaus.plexus.languages.java.jpms.LocationManager locationManager
      • classpathElements

        private java.util.List<java.lang.String> classpathElements
      • modulepathElements

        private java.util.List<java.lang.String> modulepathElements
      • pathElements

        private java.util.Map<java.lang.String,​org.codehaus.plexus.languages.java.jpms.JavaModuleDescriptor> pathElements
    • Constructor Detail

      • CompilerMojo

        public CompilerMojo()