Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add useArgumentFile option to help with Command line is too long error #42

Merged
merged 4 commits into from
May 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
Alexander Torstling (atorstling) <[email protected]>
Andrey Batalev <[email protected]>
Brice Figureau (masterzen) <[email protected]>
Chris Heisterkamp (cheister) <[email protected]>
Daniel Evans (devans) <[email protected]> <[email protected]>
David Trott (dtrott) <[email protected]>
Gregory Kick <[email protected]>
Expand Down
6 changes: 5 additions & 1 deletion src/it/TEST-25/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@

<name>Integration Test 25</name>

<properties>
<protobufVersion>3.4.0</protobufVersion>
</properties>

<build>
<plugins>
<plugin>
Expand All @@ -45,7 +49,7 @@
<goal>compile</goal>
</goals>
<configuration>
<protocArtifact>com.google.protobuf:protoc:3.4.0:exe:${os.detected.classifier}
<protocArtifact>com.google.protobuf:protoc:${protobufVersion}:exe:${os.detected.classifier}
</protocArtifact>
</configuration>
</execution>
Expand Down
2 changes: 2 additions & 0 deletions src/it/TEST-25/src/main/proto/test.proto
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
// limitations under the License.
//

syntax = "proto3";

option java_package = "test";
option java_outer_classname = "TestProtos";
option optimize_for = SPEED;
Expand Down
22 changes: 22 additions & 0 deletions src/it/TEST-29/invoker.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#
# Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

# An optional description for this build job to be included in the build reports.
invoker.description = Verifies that protoc can be invoked with an @args file and that unicode file names are properly handled.

# A comma or space separated list of goals/phases to execute, may
# specify an empty list to execute the default goal of the IT project
invoker.goals = clean generate-sources
62 changes: 62 additions & 0 deletions src/it/TEST-29/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--
~ Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.xolstice.maven.plugins.protobuf.its</groupId>
<artifactId>it-parent</artifactId>
<version>1.0.0</version>
</parent>

<artifactId>test-29</artifactId>
<version>1.0.0</version>

<name>Integration Test 29</name>

<properties>
<!-- @args files are supported by protoc starting with version 3.5.0 -->
<protobufVersion>3.5.1</protobufVersion>
</properties>

<build>
<plugins>
<plugin>
<groupId>org.xolstice.maven.plugins</groupId>
<artifactId>protobuf-maven-plugin</artifactId>
<version>@project.version@</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<protocArtifact>com.google.protobuf:protoc:${protobufVersion}:exe:${os.detected.classifier}
</protocArtifact>
<useArgumentFile>true</useArgumentFile>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
24 changes: 24 additions & 0 deletions src/it/TEST-29/src/main/proto/test.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//
// Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

syntax = "proto3";

option java_package = "test";
option java_outer_classname = "TestProtos";
option optimize_for = SPEED;

message TestMessage {
}
24 changes: 24 additions & 0 deletions src/it/TEST-29/src/main/proto/тест.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//
// Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

syntax = "proto3";

option java_package = "test";
option java_outer_classname = "TestProtosRu";
option optimize_for = SPEED;

message TestMessageRu {
}
24 changes: 24 additions & 0 deletions src/it/TEST-29/src/main/proto/テスト.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//
// Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

syntax = "proto3";

option java_package = "test";
option java_outer_classname = "TestProtosJp";
option optimize_for = SPEED;

message TestMessageJp {
}
48 changes: 48 additions & 0 deletions src/it/TEST-29/verify.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright (c) 2016 Maven Protocol Buffers Plugin Authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

outputDirectory = new File(basedir, 'target/generated-sources/protobuf/java');
assert outputDirectory.exists();
assert outputDirectory.isDirectory();

generatedJavaFile = new File(outputDirectory, 'test/TestProtos.java');
assert generatedJavaFile.exists();
assert generatedJavaFile.isFile();

content = generatedJavaFile.text;
assert content.contains('package test');
assert content.contains('class TestProtos');
assert content.contains('class TestMessage');

generatedJavaFile = new File(outputDirectory, 'test/TestProtosJp.java');
assert generatedJavaFile.exists();
assert generatedJavaFile.isFile();

content = generatedJavaFile.text;
assert content.contains('package test');
assert content.contains('class TestProtosJp');
assert content.contains('class TestMessageJp');

generatedJavaFile = new File(outputDirectory, 'test/TestProtosRu.java');
assert generatedJavaFile.exists();
assert generatedJavaFile.isFile();

content = generatedJavaFile.text;
assert content.contains('package test');
assert content.contains('class TestProtosRu');
assert content.contains('class TestMessageRu');

return true;
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,18 @@ abstract class AbstractProtocMojo extends AbstractMojo {
)
private List<ArtifactRepository> remoteRepositories;

/**
* A directory where temporary files will be generated.
*
* @since 0.6.0
*/
@Parameter(
required = true,
readonly = true,
defaultValue = "${project.build.directory}"
)
private File tempDirectory;

/**
* A directory where native launchers for java protoc plugins will be generated.
*
Expand Down Expand Up @@ -345,6 +357,19 @@ abstract class AbstractProtocMojo extends AbstractMojo {
)
protected boolean includeSourceInfoInDescriptorSet;

/**
* If set to {@code true}, the arguments to protoc will be put in a file and run as an argument
* file. This is helpful if you are getting Command line is too long errors
* This is only supported for protoc 3.5.0 and higher
*
* @since 0.6.0
*/
@Parameter(
required = false,
defaultValue = "false"
)
protected boolean useArgumentFile;

/**
* Specifies one of more custom protoc plugins, written in Java
* and available as Maven artifacts. An executable plugin will be created
Expand Down Expand Up @@ -661,6 +686,8 @@ protected void addProtocBuilderParameters(final Protoc.Builder protocBuilder) th
includeDependenciesInDescriptorSet,
includeSourceInfoInDescriptorSet);
}
protocBuilder.setTempDirectory(tempDirectory);
protocBuilder.useArgumentFile(useArgumentFile);
}

/**
Expand Down
Loading