protoc-jar:run

Full name:

com.github.os72:protoc-jar-maven-plugin:3.11.4:run

Description:

Compiles .proto files using protoc-jar embedded protoc compiler. Also supports pre-installed protoc binary, and downloading binaries (protoc and protoc plugins) from maven repo

Attributes:

  • Requires a Maven project to be executed.
  • Requires dependency resolution of artifacts in scope: runtime.
  • Binds by default to the lifecycle phase: generate-sources.

Optional Parameters

Name Type Since Description
addProtoSources String - Specifies whether to add the source .proto files found in inputDirectories/includeDirectories to the generated jar file. Options: "all" (add all), "inputs" (add only from inputDirectories), "none" (default: "none")
Default value is: none.
User property is: addProtoSources.
addSources String - Specifies whether to add outputDirectory to sources that are going to be compiled. Options: "main", "test", "none" (default: "main")

Ignored when <outputTargets> is given


Default value is: main.
User property is: addSources.
cleanOutputFolder boolean - If this parameter is set to "true" output folder is cleaned prior to the build. This will not let old and new classes coexist after package or class rename in your IDE cache or after non-clean rebuild. Set this to "false" if you are doing multiple plugin invocations per build and it is important to preserve output folder contents

Ignored when <outputTargets> is given


Default value is: false.
User property is: cleanOutputFolder.
compileMavenTypes String - Specifies whether to compile .proto files from Maven dependencies. Options: "none" (do not extract any proto files), "direct" (compile only direct dependencies), "transitive" (compile direct and transitive dependencies).
Default value is: none.
User property is: compileMavenTypes.
extension String - Default extension for protobuf files
Default value is: .proto.
User property is: extension.
includeDirectories File[] - This parameter lets you specify additional include paths to protoc.
User property is: includeDirectories.
includeImports boolean - Specifies whether to include all dependencies of the input files in the descriptor set Options: "true", "false" (default: "true")

Ignored when the type of <outputTarget> is not descriptor


Default value is: true.
User property is: includeImports.
includeMavenTypes String - Specifies whether to extract .proto files from Maven dependencies and add them to the protoc import path. Options: "none" (do not extract any proto files), "direct" (extract only from direct dependencies), "transitive" (extract from direct and transitive dependencies)
Default value is: none.
User property is: includeMavenTypes.
includeStdTypes boolean - If "true", extract the included google.protobuf standard types and add them to protoc import path.
Default value is: false.
User property is: includeStdTypes.
inputDirectories File[] - Input directories that have *.proto files (or the configured extension). If none specified then src/main/protobuf is used.
User property is: inputDirectories.
optimizeCodegen boolean - If "true", skip code generation when .proto input files appear unchanged since last compilation.
Default value is: true.
User property is: optimizeCodegen.
outputDirectory File - Output directory for the generated java files. Defaults to "${project.build.directory}/generated-sources" or "${project.build.directory}/generated-test-sources" depending on the addSources parameter

Ignored when <outputTargets> is given


User property is: outputDirectory.
outputDirectorySuffix String - If this parameter is set, append its value to the outputDirectory path For example, value "protobuf" will set output directory to "${project.build.directory}/generated-sources/protobuf" or "${project.build.directory}/generated-test-sources/protobuf"

Ignored when <outputTargets> is given


User property is: outputDirectorySuffix.
outputOptions String - Output options. Used for example with type "js" to create protoc argument --js_out=[OPTIONS]:output_dir

Ignored when <outputTargets> is given


User property is: outputOptions.
outputTargets OutputTarget[] - This parameter lets you specify multiple protoc output targets. OutputTarget parameters: "type", "addSources", "cleanOutputFolder", "outputDirectory", "outputDirectorySuffix", "outputOptions", "pluginPath", "pluginArtifact". Type options: "java", "cpp", "python", "descriptor" (default: "java"); for proto3 also: "javanano", "csharp", "objc", "ruby", "js"

<outputTargets>
        <outputTarget>
                <type>java</type>
                <addSources>none</addSources>
                <outputDirectory>src/main/java</outputDirectory>
        </outputTarget>
        <outputTarget>
                <type>grpc-java</type>
                <addSources>none</addSources>
                <outputDirectory>src/main/java</outputDirectory>
                <pluginArtifact>io.grpc:protoc-gen-grpc-java:1.0.1</pluginArtifact>
        </outputTarget>
        <outputTarget>
                <type>python</type>
                <addSources>none</addSources>
                <outputDirectory>src/main/python</outputDirectory>
        </outputTarget>
        <outputTarget>
                <type>dart</type>
                <addSources>none</addSources>
                <outputDirectory>lib/protobuf</outputDirectory>
                <pluginPath>protoc-gen-dart.exe</pluginPath>
        </outputTarget>
<outputTargets>


User property is: outputTargets.
pluginArtifact String - Maven artifact coordinates of the protoc plugin that generates code for the specified type. Format: "groupId:artifactId:version" (eg, "io.grpc:protoc-gen-grpc-java:1.0.1")

Ignored when <outputTargets> is given


User property is: pluginArtifact.
pluginPath String - Path to the protoc plugin that generates code for the specified type.

Ignored when <outputTargets> is given


User property is: pluginPath.
protocArtifact String - Maven artifact coordinates of the protoc binary to use Format: "groupId:artifactId:version" (eg, "com.google.protobuf:protoc:3.1.0")
User property is: protocArtifact.
protocCommand String - This parameter allows to use a protoc binary instead of the protoc-jar bundle
User property is: protocCommand.
protocVersion String - Specifies the protoc version (default: latest version).
User property is: protocVersion.
type String - Specifies output type. Options: "java", "cpp", "python", "descriptor" (default: "java"); for proto3 also: "javanano", "csharp", "objc", "ruby", "js"

Ignored when <outputTargets> is given


Default value is: java.
User property is: type.

Parameter Details

addProtoSources:

Specifies whether to add the source .proto files found in inputDirectories/includeDirectories to the generated jar file. Options: "all" (add all), "inputs" (add only from inputDirectories), "none" (default: "none")
  • Type: java.lang.String
  • Required: No
  • User Property: addProtoSources
  • Default: none

addSources:

Specifies whether to add outputDirectory to sources that are going to be compiled. Options: "main", "test", "none" (default: "main")

Ignored when <outputTargets> is given

  • Type: java.lang.String
  • Required: No
  • User Property: addSources
  • Default: main

cleanOutputFolder:

If this parameter is set to "true" output folder is cleaned prior to the build. This will not let old and new classes coexist after package or class rename in your IDE cache or after non-clean rebuild. Set this to "false" if you are doing multiple plugin invocations per build and it is important to preserve output folder contents

Ignored when <outputTargets> is given

  • Type: boolean
  • Required: No
  • User Property: cleanOutputFolder
  • Default: false

compileMavenTypes:

Specifies whether to compile .proto files from Maven dependencies. Options: "none" (do not extract any proto files), "direct" (compile only direct dependencies), "transitive" (compile direct and transitive dependencies).
  • Type: java.lang.String
  • Required: No
  • User Property: compileMavenTypes
  • Default: none

extension:

Default extension for protobuf files
  • Type: java.lang.String
  • Required: No
  • User Property: extension
  • Default: .proto

includeDirectories:

This parameter lets you specify additional include paths to protoc.
  • Type: java.io.File[]
  • Required: No
  • User Property: includeDirectories

includeImports:

Specifies whether to include all dependencies of the input files in the descriptor set Options: "true", "false" (default: "true")

Ignored when the type of <outputTarget> is not descriptor

  • Type: boolean
  • Required: No
  • User Property: includeImports
  • Default: true

includeMavenTypes:

Specifies whether to extract .proto files from Maven dependencies and add them to the protoc import path. Options: "none" (do not extract any proto files), "direct" (extract only from direct dependencies), "transitive" (extract from direct and transitive dependencies)
  • Type: java.lang.String
  • Required: No
  • User Property: includeMavenTypes
  • Default: none

includeStdTypes:

If "true", extract the included google.protobuf standard types and add them to protoc import path.
  • Type: boolean
  • Required: No
  • User Property: includeStdTypes
  • Default: false

inputDirectories:

Input directories that have *.proto files (or the configured extension). If none specified then src/main/protobuf is used.
  • Type: java.io.File[]
  • Required: No
  • User Property: inputDirectories

optimizeCodegen:

If "true", skip code generation when .proto input files appear unchanged since last compilation.
  • Type: boolean
  • Required: No
  • User Property: optimizeCodegen
  • Default: true

outputDirectory:

Output directory for the generated java files. Defaults to "${project.build.directory}/generated-sources" or "${project.build.directory}/generated-test-sources" depending on the addSources parameter

Ignored when <outputTargets> is given

  • Type: java.io.File
  • Required: No
  • User Property: outputDirectory

outputDirectorySuffix:

If this parameter is set, append its value to the outputDirectory path For example, value "protobuf" will set output directory to "${project.build.directory}/generated-sources/protobuf" or "${project.build.directory}/generated-test-sources/protobuf"

Ignored when <outputTargets> is given

  • Type: java.lang.String
  • Required: No
  • User Property: outputDirectorySuffix

outputOptions:

Output options. Used for example with type "js" to create protoc argument --js_out=[OPTIONS]:output_dir

Ignored when <outputTargets> is given

  • Type: java.lang.String
  • Required: No
  • User Property: outputOptions

outputTargets:

This parameter lets you specify multiple protoc output targets. OutputTarget parameters: "type", "addSources", "cleanOutputFolder", "outputDirectory", "outputDirectorySuffix", "outputOptions", "pluginPath", "pluginArtifact". Type options: "java", "cpp", "python", "descriptor" (default: "java"); for proto3 also: "javanano", "csharp", "objc", "ruby", "js"

<outputTargets>
        <outputTarget>
                <type>java</type>
                <addSources>none</addSources>
                <outputDirectory>src/main/java</outputDirectory>
        </outputTarget>
        <outputTarget>
                <type>grpc-java</type>
                <addSources>none</addSources>
                <outputDirectory>src/main/java</outputDirectory>
                <pluginArtifact>io.grpc:protoc-gen-grpc-java:1.0.1</pluginArtifact>
        </outputTarget>
        <outputTarget>
                <type>python</type>
                <addSources>none</addSources>
                <outputDirectory>src/main/python</outputDirectory>
        </outputTarget>
        <outputTarget>
                <type>dart</type>
                <addSources>none</addSources>
                <outputDirectory>lib/protobuf</outputDirectory>
                <pluginPath>protoc-gen-dart.exe</pluginPath>
        </outputTarget>
<outputTargets>

  • Type: com.github.os72.protocjar.maven.OutputTarget[]
  • Required: No
  • User Property: outputTargets

pluginArtifact:

Maven artifact coordinates of the protoc plugin that generates code for the specified type. Format: "groupId:artifactId:version" (eg, "io.grpc:protoc-gen-grpc-java:1.0.1")

Ignored when <outputTargets> is given

  • Type: java.lang.String
  • Required: No
  • User Property: pluginArtifact

pluginPath:

Path to the protoc plugin that generates code for the specified type.

Ignored when <outputTargets> is given

  • Type: java.lang.String
  • Required: No
  • User Property: pluginPath

protocArtifact:

Maven artifact coordinates of the protoc binary to use Format: "groupId:artifactId:version" (eg, "com.google.protobuf:protoc:3.1.0")
  • Type: java.lang.String
  • Required: No
  • User Property: protocArtifact

protocCommand:

This parameter allows to use a protoc binary instead of the protoc-jar bundle
  • Type: java.lang.String
  • Required: No
  • User Property: protocCommand

protocVersion:

Specifies the protoc version (default: latest version).
  • Type: java.lang.String
  • Required: No
  • User Property: protocVersion

type:

Specifies output type. Options: "java", "cpp", "python", "descriptor" (default: "java"); for proto3 also: "javanano", "csharp", "objc", "ruby", "js"

Ignored when <outputTargets> is given

  • Type: java.lang.String
  • Required: No
  • User Property: type
  • Default: java