Class ProtocTestCompileCustomMojo

java.lang.Object
org.apache.maven.plugin.AbstractMojo
All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo

@Mojo(name="test-compile-custom", defaultPhase=GENERATE_TEST_SOURCES, requiresDependencyResolution=TEST, threadSafe=true) public final class ProtocTestCompileCustomMojo extends AbstractProtocTestCompileMojo
This mojo executes the protoc compiler with the specified plugin executable to generate test sources from protocol buffer definitions. It also searches dependency artifacts for .proto files and includes them in the proto_path so that they can be referenced. Finally, it adds the .proto files to the project as resources so that they can be included in the test-jar artifact.
Since:
0.4.1
  • Field Details

    • pluginId

      @Parameter(required=true, property="protocPluginId") private String pluginId
      A unique id that identifies the plugin to protoc. Cannot be one of the built-in protoc plugins:
      • java
      • javanano
      • js
      • csharp
      • cpp
      • python
      • descriptor-set
    • outputBaseDirectory

      @Parameter(required=true, readonly=true, defaultValue="${project.build.directory}/generated-test-sources/protobuf") private File outputBaseDirectory
      This is the base directory for the generated code. If an explicit outputDirectory parameter is not specified, an output directory named after pluginId will be created inside this base directory.
    • outputDirectory

      @Parameter(required=false, property="protocPluginOutputDirectory") private File outputDirectory
      This is the directory where the generated code will be placed. If this parameter is unspecified, then the default location is constructed as follows:
      ${project.build.directory}/generated-test-sources/protobuf/<pluginId>
    • pluginExecutable

      @Parameter(required=false, property="protocPluginExecutable") private String pluginExecutable
      An optional path to plugin executable. If unspecified, alternative options must be used (e.g. toolchains).
    • pluginParameter

      @Parameter(required=false, property="protocPluginParameter") private String pluginParameter
      An optional parameter to be passed to the plugin. Cannot contain colon (:) symbols.
    • pluginToolchain

      @Parameter(required=false, property="protocPluginToolchain") private String pluginToolchain
      A name of an optional custom toolchain that can be used to locate the plugin executable. The toolchain must be registered as a build extension and initialised properly.
    • pluginTool

      @Parameter(required=false, property="protocPluginTool") private String pluginTool
      If pluginToolchain is specified, this parameter specifies the tool in the toolchain, which is to be resolved as plugin executable.
    • pluginArtifact

      @Parameter(required=false, property="protocPluginArtifact") private String pluginArtifact
      Plugin artifact specification, in groupId:artifactId:version[:type[:classifier]] format. When this parameter is set, the specified artifact will be resolved as a plugin executable.
      Since:
      0.4.1
  • Constructor Details

    • ProtocTestCompileCustomMojo

      public ProtocTestCompileCustomMojo()
  • Method Details

    • addProtocBuilderParameters

      protected void addProtocBuilderParameters(Protoc.Builder protocBuilder)
      Description copied from class: AbstractProtocMojo
      Adds mojo-specific parameters to the protoc builder.
      Overrides:
      addProtocBuilderParameters in class AbstractProtocMojo
      Parameters:
      protocBuilder - the builder to be modified.
    • getOutputDirectory

      protected File getOutputDirectory()
      Description copied from class: AbstractProtocMojo
      Returns the output directory for generated sources. Depends on build phase so must be defined in concrete implementation.
      Specified by:
      getOutputDirectory in class AbstractProtocMojo
      Returns:
      output directory for generated sources.