Class Protoc.Builder

  • Enclosing class:
    Protoc

    static final class Protoc.Builder
    extends java.lang.Object
    This class builds Protoc instances.
    • Field Detail

      • executable

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

        private final java.util.LinkedHashSet<java.io.File> protopathElements
      • protoFiles

        private final java.util.List<java.io.File> protoFiles
      • plugins

        private final java.util.List<ProtocPlugin> plugins
      • tempDirectory

        private java.io.File tempDirectory
      • pluginDirectory

        private java.io.File pluginDirectory
      • nativePluginId

        private java.lang.String nativePluginId
      • nativePluginExecutable

        private java.lang.String nativePluginExecutable
      • nativePluginParameter

        private java.lang.String nativePluginParameter
      • javaOutputDirectory

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

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

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

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

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

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

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

        private java.io.File descriptorSetFile
      • includeImportsInDescriptorSet

        private boolean includeImportsInDescriptorSet
      • includeSourceInfoInDescriptorSet

        private boolean includeSourceInfoInDescriptorSet
      • useArgumentFile

        private boolean useArgumentFile
    • Constructor Detail

      • Builder

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

      • setTempDirectory

        public Protoc.Builder setTempDirectory​(java.io.File tempDirectory)
      • setJavaOutputDirectory

        public Protoc.Builder setJavaOutputDirectory​(java.io.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​(java.io.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​(java.io.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​(java.io.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​(java.io.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​(java.io.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​(java.io.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​(java.io.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​(java.io.File pluginDirectory)
      • setNativePluginId

        public Protoc.Builder setNativePluginId​(java.lang.String nativePluginId)
      • setNativePluginExecutable

        public Protoc.Builder setNativePluginExecutable​(java.lang.String nativePluginExecutable)
      • setNativePluginParameter

        public Protoc.Builder setNativePluginParameter​(java.lang.String nativePluginParameter)
      • withDescriptorSetFile

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

        public Protoc.Builder useArgumentFile​(boolean useArgumentFile)
      • checkProtoFileIsInProtopath

        private void checkProtoFileIsInProtopath​(java.io.File protoFile)
      • checkProtoFileIsInProtopathHelper

        private boolean checkProtoFileIsInProtopathHelper​(java.io.File directory)
      • addProtoFiles

        public Protoc.Builder addProtoFiles​(java.lang.Iterable<java.io.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:
        addProtoFile(File)
      • addProtoPathElement

        public Protoc.Builder addProtoPathElement​(java.io.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​(java.lang.Iterable<java.io.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:
        addProtoPathElement(File)
      • 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.