diff --git a/src/main/java/org/xolstice/maven/plugin/protobuf/AbstractProtocMojo.java b/src/main/java/org/xolstice/maven/plugin/protobuf/AbstractProtocMojo.java index 9b993dc6..55e7b474 100644 --- a/src/main/java/org/xolstice/maven/plugin/protobuf/AbstractProtocMojo.java +++ b/src/main/java/org/xolstice/maven/plugin/protobuf/AbstractProtocMojo.java @@ -312,6 +312,19 @@ abstract class AbstractProtocMojo extends AbstractMojo { ) protected boolean useArgumentFile; + /** + * If set to {@code true}, experimental optional feature will be enabled. + * + *
NOTE: This is only supported for protoc 3.12.0 and higher.
+ * + * @since 0.7.0 + */ + @Parameter( + required = false, + defaultValue = "false" + ) + protected boolean useExperimentalOptional; + /** * Specifies one of more custom protoc plugins, written in Java * and available as Maven artifacts. An executable plugin will be created @@ -623,6 +636,7 @@ protected void addProtocBuilderParameters(final Protoc.Builder protocBuilder) { } protocBuilder.setTempDirectory(tempDirectory); protocBuilder.useArgumentFile(useArgumentFile); + protocBuilder.useExperimentalOptional(useExperimentalOptional); } /** diff --git a/src/main/java/org/xolstice/maven/plugin/protobuf/Protoc.java b/src/main/java/org/xolstice/maven/plugin/protobuf/Protoc.java index d8097636..6800b3ab 100644 --- a/src/main/java/org/xolstice/maven/plugin/protobuf/Protoc.java +++ b/src/main/java/org/xolstice/maven/plugin/protobuf/Protoc.java @@ -124,6 +124,11 @@ final class Protoc { */ private final boolean useArgumentFile; + /** + * A boolean indicating if experimental optional feature should be enabled. + */ + private boolean useExperimentalOptional; + /** * Constructs a new instance. This should only be used by the {@link Builder}. * @@ -148,6 +153,7 @@ final class Protoc { * @param nativePluginParameter an optional parameter for a native plugin. * @param tempDirectory a directory where temporary files will be generated. * @param useArgumentFile If {@code true}, parameters to protoc will be put in an argument file + * @param useExperimentalOptional If {@code true}, experimental optional feature will be enabled */ private Protoc( final String executable, @@ -168,7 +174,8 @@ private Protoc( final String nativePluginExecutable, final String nativePluginParameter, final File tempDirectory, - final boolean useArgumentFile + final boolean useArgumentFile, + final boolean useExperimentalOptional ) { if (executable == null) { throw new MojoConfigurationException("'executable' is null"); @@ -198,6 +205,7 @@ private Protoc( this.nativePluginParameter = nativePluginParameter; this.tempDirectory = tempDirectory; this.useArgumentFile = useArgumentFile; + this.useExperimentalOptional = useExperimentalOptional; this.error = new StringStreamConsumer(); this.output = new StringStreamConsumer(); } @@ -255,6 +263,10 @@ public List