Class ProtocCompileCustomMojo
java.lang.Object
org.apache.maven.plugin.AbstractMojo
org.xolstice.maven.plugin.protobuf.AbstractProtocMojo
org.xolstice.maven.plugin.protobuf.AbstractProtocCompileMojo
org.xolstice.maven.plugin.protobuf.ProtocCompileCustomMojo
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled
,org.apache.maven.plugin.Mojo
@Mojo(name="compile-custom",
defaultPhase=GENERATE_SOURCES,
requiresDependencyResolution=COMPILE,
threadSafe=true)
public final class ProtocCompileCustomMojo
extends AbstractProtocCompileMojo
This mojo executes the
protoc
compiler with the specified plugin
executable to generate main 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 are included in the final artifact.- Since:
- 0.4.1
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate File
This is the base directory for the generated code.private File
This is the directory where the generated code will be placed.private String
Plugin artifact specification, ingroupId:artifactId:version[:type[:classifier]]
format.private String
An optional path to plugin executable.private String
A unique id that identifies the plugin to protoc.private String
An optional parameter to be passed to the plugin.private String
IfpluginToolchain
is specified, this parameter specifies the tool in the toolchain, which is to be resolved as plugin executable.private String
A name of an optional custom toolchain that can be used to locate the plugin executable.Fields inherited from class org.xolstice.maven.plugin.protobuf.AbstractProtocCompileMojo
descriptorSetClassifier
Fields inherited from class org.xolstice.maven.plugin.protobuf.AbstractProtocMojo
attachDescriptorSet, attachProtoSources, buildContext, descriptorSetFileName, includeDependenciesInDescriptorSet, includeSourceInfoInDescriptorSet, project, projectHelper, session, toolchainManager, useArgumentFile, writeDescriptorSet
Fields inherited from interface org.apache.maven.plugin.Mojo
ROLE
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
addProtocBuilderParameters
(Protoc.Builder protocBuilder) Adds mojo-specific parameters to the protoc builder.protected File
Returns the output directory for generated sources.Methods inherited from class org.xolstice.maven.plugin.protobuf.AbstractProtocCompileMojo
doAttachGeneratedFiles, doAttachProtoSources, getDependencyArtifacts, getDescriptorSetOutputDirectory, getProtoSourceRoot
Methods inherited from class org.xolstice.maven.plugin.protobuf.AbstractProtocMojo
checkFilesUpToDate, checkParameters, createDependencyArtifact, createDependencyArtifact, createProtocPlugins, detectJavaHome, doAttachFiles, execute, findGeneratedFilesInDirectory, findProtoFilesInDirectories, findProtoFilesInDirectory, getDependencyArtifactFiles, getExcludes, getIncludes, hasDelta, lastModified, makeProtoPathFromJars, resolveBinaryArtifact, skipMojo, toHexString, truncatePath
Methods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
-
Field Details
-
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-sources/protobuf") private File outputBaseDirectoryThis is the base directory for the generated code. If an explicitoutputDirectory
parameter is not specified, an output directory named afterpluginId
will be created inside this base directory. -
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-sources/protobuf/<pluginId>
-
pluginExecutable
An optional path to plugin executable. If unspecified, alternative options must be used (e.g. toolchains). -
pluginParameter
An optional parameter to be passed to the plugin. Cannot contain colon (:) symbols. -
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
IfpluginToolchain
is specified, this parameter specifies the tool in the toolchain, which is to be resolved as plugin executable. -
pluginArtifact
Plugin artifact specification, ingroupId: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
-
ProtocCompileCustomMojo
public ProtocCompileCustomMojo()
-
-
Method Details
-
addProtocBuilderParameters
Description copied from class:AbstractProtocMojo
Adds mojo-specific parameters to the protoc builder.- Overrides:
addProtocBuilderParameters
in classAbstractProtocMojo
- Parameters:
protocBuilder
- the builder to be modified.
-
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 classAbstractProtocMojo
- Returns:
- output directory for generated sources.
-