Class ProtoCompilerMojo

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

    @Mojo(name="compile",
          configurator="include-project-dependencies",
          requiresDependencyResolution=COMPILE_PLUS_RUNTIME)
    public class ProtoCompilerMojo
    extends org.apache.maven.plugin.AbstractMojo
    Compiles proto files to java/gwt/etc.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.io.File baseDir
      Maven module base directory
      private boolean cacheProtos
      When true, the protos are cached for re-use.
      private org.apache.maven.plugin.MojoExecution execution  
      private boolean forceMojoExecution
      Usually most of protostuff mojos will not get executed on parent poms (i.e.
      static java.lang.String GENERATE_TEST_SOURCES_PHASE  
      protected java.io.File modulesFile
      The properties file that contains the modules
      protected java.io.File outputBaseDir
      If not specified, the directory where the file is located will be used as its base dir.
      protected org.apache.maven.project.MavenProject project
      The current Maven project.
      protected java.util.Properties properties
      Plugin properties that are passed to the compiler
      protected ProtoModule[] protoModules
      The modules to generate code from
      private boolean skip
      When true, skip the execution.
      protected java.io.File sourceBaseDir
      If not specified, the directory where the file is located will be used as its base dir.
      private java.util.Properties systemPropertiesBackup  
      • Fields inherited from interface org.apache.maven.plugin.Mojo

        ROLE
    • Field Detail

      • GENERATE_TEST_SOURCES_PHASE

        public static final java.lang.String GENERATE_TEST_SOURCES_PHASE
        See Also:
        Constant Field Values
      • project

        @Parameter(property="project",
                   required=true,
                   readonly=true)
        protected org.apache.maven.project.MavenProject project
        The current Maven project.
      • skip

        @Parameter(property="protostuff.compiler.skip",
                   defaultValue="false")
        private boolean skip
        When true, skip the execution.
        Since:
        1.0.1
      • cacheProtos

        @Parameter(property="protostuff.compiler.cache_protos",
                   defaultValue="false")
        private boolean cacheProtos
        When true, the protos are cached for re-use. This matters when a certain proto is also used/imported by other modules.
        Since:
        1.0.5
      • forceMojoExecution

        @Parameter(property="protostuff.compiler.force",
                   defaultValue="false",
                   required=true)
        private boolean forceMojoExecution
        Usually most of protostuff mojos will not get executed on parent poms (i.e. projects with packaging type 'pom'). Setting this parameter to true will force the execution of this mojo, even if it would usually get skipped in this case.
        Since:
        1.0.1
      • modulesFile

        @Parameter
        protected java.io.File modulesFile
        The properties file that contains the modules
      • sourceBaseDir

        @Parameter
        protected java.io.File sourceBaseDir
        If not specified, the directory where the file is located will be used as its base dir.

        This is only relevent when is provided.

        Since:
        1.0.8
      • outputBaseDir

        @Parameter
        protected java.io.File outputBaseDir
        If not specified, the directory where the file is located will be used as its base dir.

        This is only relevent when is provided.

        Since:
        1.0.8
      • protoModules

        @Parameter
        protected ProtoModule[] protoModules
        The modules to generate code from
      • baseDir

        @Parameter(property="project.basedir",
                   required=true)
        protected java.io.File baseDir
        Maven module base directory
      • properties

        @Parameter
        protected java.util.Properties properties
        Plugin properties that are passed to the compiler
        Since:
        1.3.1
      • execution

        @Component
        private org.apache.maven.plugin.MojoExecution execution
      • systemPropertiesBackup

        private java.util.Properties systemPropertiesBackup
    • Constructor Detail

      • ProtoCompilerMojo

        public ProtoCompilerMojo()
    • Method Detail

      • execute

        public void execute()
                     throws org.apache.maven.plugin.MojoExecutionException,
                            org.apache.maven.plugin.MojoFailureException
        Throws:
        org.apache.maven.plugin.MojoExecutionException
        org.apache.maven.plugin.MojoFailureException
      • updateRelativeOutputLocation

        private void updateRelativeOutputLocation​(ProtoModule m)
      • setSystemProperties

        private void setSystemProperties()
      • resetSystemProperties

        private void resetSystemProperties()
      • skipMojo

        protected boolean skipMojo()

        Determine if the mojo execution should get skipped.

        This is the case if:
        • skip is true
        • if the mojo gets executed on a project with packaging type 'pom' and forceMojoExecution is false
        Returns:
        true if the mojo execution should be skipped.
        Since:
        1.0.1