Class Protoc.Builder

java.lang.Object
org.xolstice.maven.plugin.protobuf.Protoc.Builder
Enclosing class:
Protoc

static final class Protoc.Builder extends Object
This class builds Protoc instances.
  • Field Details

    • executable

      private final String executable
      Path to the protoc executable.
    • protopathElements

      private final LinkedHashSet<File> protopathElements
    • protoFiles

      private final List<File> protoFiles
    • plugins

      private final List<ProtocPlugin> plugins
    • tempDirectory

      private File tempDirectory
    • pluginDirectory

      private File pluginDirectory
    • nativePluginId

      private String nativePluginId
    • nativePluginExecutable

      private String nativePluginExecutable
    • nativePluginParameter

      private String nativePluginParameter
    • javaOutputDirectory

      private File javaOutputDirectory
      A directory into which Java source files will be generated.
    • javaNanoOutputDirectory

      private File javaNanoOutputDirectory
      A directory into which Java Nano source files will be generated.
    • cppOutputDirectory

      private File cppOutputDirectory
      A directory into which C++ source files will be generated.
    • pythonOutputDirectory

      private File pythonOutputDirectory
      A directory into which Python source files will be generated.
    • csharpOutputDirectory

      private File csharpOutputDirectory
      A directory into which C# source files will be generated.
    • javaScriptOutputDirectory

      private File javaScriptOutputDirectory
      A directory into which JavaScript source files will be generated.
    • customOutputDirectory

      private File customOutputDirectory
      A directory into which a custom protoc plugin will generate files.
    • descriptorSetFile

      private File descriptorSetFile
    • includeImportsInDescriptorSet

      private boolean includeImportsInDescriptorSet
    • includeSourceInfoInDescriptorSet

      private boolean includeSourceInfoInDescriptorSet
    • useArgumentFile

      private boolean useArgumentFile
  • Constructor Details

    • Builder

      Builder(String executable)
      Constructs a new builder.
      Parameters:
      executable - The path to the protoc executable.
  • Method Details

    • setTempDirectory

      public Protoc.Builder setTempDirectory(File tempDirectory)
    • setJavaOutputDirectory

      public Protoc.Builder setJavaOutputDirectory(File javaOutputDirectory)
      Sets the directory into which Java source files will be generated.
      Parameters:
      javaOutputDirectory - a directory into which Java source files will be generated.
      Returns:
      this builder instance.
    • setJavaNanoOutputDirectory

      public Protoc.Builder setJavaNanoOutputDirectory(File javaNanoOutputDirectory)
      Sets the directory into which JavaNano source files will be generated.
      Parameters:
      javaNanoOutputDirectory - a directory into which Java source files will be generated.
      Returns:
      this builder instance.
    • setCppOutputDirectory

      public Protoc.Builder setCppOutputDirectory(File cppOutputDirectory)
      Sets the directory into which C++ source files will be generated.
      Parameters:
      cppOutputDirectory - a directory into which C++ source files will be generated.
      Returns:
      this builder instance.
    • setPythonOutputDirectory

      public Protoc.Builder setPythonOutputDirectory(File pythonOutputDirectory)
      Sets the directory into which Python source files will be generated.
      Parameters:
      pythonOutputDirectory - a directory into which Python source files will be generated.
      Returns:
      this builder instance.
    • setCsharpOutputDirectory

      public Protoc.Builder setCsharpOutputDirectory(File csharpOutputDirectory)
      Sets the directory into which C# source files will be generated.
      Parameters:
      csharpOutputDirectory - a directory into which C# source files will be generated.
      Returns:
      this builder instance.
    • setJavaScriptOutputDirectory

      public Protoc.Builder setJavaScriptOutputDirectory(File javaScriptOutputDirectory)
      Sets the directory into which JavaScript source files will be generated.
      Parameters:
      javaScriptOutputDirectory - a directory into which JavaScript source files will be generated.
      Returns:
      this builder instance.
    • setCustomOutputDirectory

      public Protoc.Builder setCustomOutputDirectory(File customOutputDirectory)
      Sets the directory into which a custom protoc plugin will generate files.
      Parameters:
      customOutputDirectory - a directory into which a custom protoc plugin will generate files.
      Returns:
      this builder instance.
    • addProtoFile

      public Protoc.Builder addProtoFile(File protoFile)
      Adds a proto file to be compiled. Proto files must be on the protopath and this method will fail if a proto file is added without first adding a parent directory to the protopath.
      Parameters:
      protoFile - source protobuf definitions file.
      Returns:
      The builder.
    • addPlugin

      public Protoc.Builder addPlugin(ProtocPlugin plugin)
      Adds a protoc plugin definition for custom code generation.
      Parameters:
      plugin - plugin definition
      Returns:
      this builder instance.
    • setPluginDirectory

      public Protoc.Builder setPluginDirectory(File pluginDirectory)
    • setNativePluginId

      public Protoc.Builder setNativePluginId(String nativePluginId)
    • setNativePluginExecutable

      public Protoc.Builder setNativePluginExecutable(String nativePluginExecutable)
    • setNativePluginParameter

      public Protoc.Builder setNativePluginParameter(String nativePluginParameter)
    • withDescriptorSetFile

      public Protoc.Builder withDescriptorSetFile(File descriptorSetFile, boolean includeImports, boolean includeSourceInfoInDescriptorSet)
    • useArgumentFile

      public Protoc.Builder useArgumentFile(boolean useArgumentFile)
    • checkProtoFileIsInProtopath

      private void checkProtoFileIsInProtopath(File protoFile)
    • checkProtoFileIsInProtopathHelper

      private boolean checkProtoFileIsInProtopathHelper(File directory)
    • addProtoFiles

      public Protoc.Builder addProtoFiles(Iterable<File> protoFiles)
      Adds a collection of proto files to be compiled.
      Parameters:
      protoFiles - a collection of source protobuf definition files.
      Returns:
      this builder instance.
      See Also:
    • addProtoPathElement

      public Protoc.Builder addProtoPathElement(File protopathElement)
      Adds the protopathElement to the protopath.
      Parameters:
      protopathElement - A directory to be searched for imported protocol buffer definitions.
      Returns:
      The builder.
    • addProtoPathElements

      public Protoc.Builder addProtoPathElements(Iterable<File> protopathElements)
      Adds a number of elements to the protopath.
      Parameters:
      protopathElements - directories to be searched for imported protocol buffer definitions.
      Returns:
      this builder instance.
      See Also:
    • validateState

      private void validateState()
      Validates the internal state for consistency and completeness.
    • build

      public Protoc build()
      Builds and returns a fully configured instance of Protoc wrapper.
      Returns:
      a configured Protoc instance.