Skip to content

Commit

Permalink
Added new goals to generate JavaScript sources from protobuf definitions
Browse files Browse the repository at this point in the history
Fixes #4
  • Loading branch information
sergei-ivanov committed Oct 1, 2018
1 parent 29cfce8 commit 0d4d6f7
Show file tree
Hide file tree
Showing 24 changed files with 793 additions and 17 deletions.
5 changes: 4 additions & 1 deletion src/changes/changes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

<body>

<release version="0.6.0" date="Pending" description="Additional protoc options">
<release version="0.6.0" date="2018-10-01" description="Additional protoc options">
<action dev="sergei-ivanov" type="update" issue="43">
Address vulnerabilities reported by Snyk.
</action>
Expand All @@ -36,6 +36,9 @@
<action dev="sergei-ivanov" type="add" issue="1">
Added new goals to generate C# sources from protobuf definitions.
</action>
<action dev="sergei-ivanov" type="add" issue="4">
Added new goals to generate JavaScript sources from protobuf definitions.
</action>
</release>

<release version="0.5.0" date="2016-01-28" description="Rebranding">
Expand Down
2 changes: 1 addition & 1 deletion src/it/TEST-30/invoker.properties
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ invoker.description=\

# 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 compile
invoker.goals=clean generate-sources
8 changes: 4 additions & 4 deletions src/it/TEST-30/verify.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ outputDirectory = new File(basedir, 'target/generated-sources/protobuf/csharp');
assert outputDirectory.exists();
assert outputDirectory.isDirectory();

generatedPythonFile = new File(outputDirectory, 'Test.cs');
assert generatedPythonFile.exists();
assert generatedPythonFile.isFile();
generatedFile = new File(outputDirectory, 'Test.cs');
assert generatedFile.exists();
assert generatedFile.isFile();

content = generatedPythonFile.text;
content = generatedFile.text;
assert content.contains('TestMessage');
assert content.contains('NestedMessage');

Expand Down
2 changes: 1 addition & 1 deletion src/it/TEST-31/invoker.properties
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ invoker.description=\

# 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 test-compile
invoker.goals=clean generate-test-sources
8 changes: 4 additions & 4 deletions src/it/TEST-31/verify.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ outputDirectory = new File(basedir, 'target/generated-test-sources/protobuf/csha
assert outputDirectory.exists();
assert outputDirectory.isDirectory();

generatedPythonFile = new File(outputDirectory, 'Test.cs');
assert generatedPythonFile.exists();
assert generatedPythonFile.isFile();
generatedFile = new File(outputDirectory, 'Test.cs');
assert generatedFile.exists();
assert generatedFile.isFile();

content = generatedPythonFile.text;
content = generatedFile.text;
assert content.contains('TestMessage');
assert content.contains('NestedMessage');

Expand Down
22 changes: 22 additions & 0 deletions src/it/TEST-32/invoker.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#
# Copyright (c) 2018 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 JavaScript generation works

# 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
57 changes: 57 additions & 0 deletions src/it/TEST-32/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--
~ Copyright (c) 2018 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-32</artifactId>
<version>1.0.0</version>

<name>Integration Test 32</name>

<build>
<plugins>
<plugin>
<groupId>org.xolstice.maven.plugins</groupId>
<artifactId>protobuf-maven-plugin</artifactId>
<version>@project.version@</version>
<executions>
<execution>
<goals>
<goal>compile-js</goal>
</goals>
</execution>
</executions>
<configuration>
<protocArtifact>
com.google.protobuf:protoc:${protobufVersion}:exe:${os.detected.classifier}
</protocArtifact>
</configuration>
</plugin>
</plugins>
</build>
</project>
32 changes: 32 additions & 0 deletions src/it/TEST-32/src/main/proto/test.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//
// Copyright (c) 2018 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";

message TestMessage {
message NestedMessage {
int32 bb = 1;
}

enum NestedEnum {
FOO = 0;
BAR = 1;
BAZ = 2;
}

// Singular
int32 optional_int32 = 1;
}
29 changes: 29 additions & 0 deletions src/it/TEST-32/verify.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright (c) 2018 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/js');
assert outputDirectory.exists();
assert outputDirectory.isDirectory();

generatedFile = new File(outputDirectory, 'testmessage.js');
assert generatedFile.exists();
assert generatedFile.isFile();

content = generatedFile.text;
assert content.contains('TestMessage');
assert content.contains('NestedMessage');

return true;
22 changes: 22 additions & 0 deletions src/it/TEST-33/invoker.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#
# Copyright (c) 2018 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 JavaScript generation works, using additional generator options

# 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
60 changes: 60 additions & 0 deletions src/it/TEST-33/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--
~ Copyright (c) 2018 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-33</artifactId>
<version>1.0.0</version>

<name>Integration Test 33</name>

<build>
<plugins>
<plugin>
<groupId>org.xolstice.maven.plugins</groupId>
<artifactId>protobuf-maven-plugin</artifactId>
<version>@project.version@</version>
<executions>
<execution>
<goals>
<goal>compile-js</goal>
</goals>
<configuration>
<javaScriptOptions>import_style=commonjs,binary</javaScriptOptions>
</configuration>
</execution>
</executions>
<configuration>
<protocArtifact>
com.google.protobuf:protoc:${protobufVersion}:exe:${os.detected.classifier}
</protocArtifact>
</configuration>
</plugin>
</plugins>
</build>
</project>
32 changes: 32 additions & 0 deletions src/it/TEST-33/src/main/proto/test.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//
// Copyright (c) 2018 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";

message TestMessage {
message NestedMessage {
int32 bb = 1;
}

enum NestedEnum {
FOO = 0;
BAR = 1;
BAZ = 2;
}

// Singular
int32 optional_int32 = 1;
}
29 changes: 29 additions & 0 deletions src/it/TEST-33/verify.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright (c) 2018 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/js');
assert outputDirectory.exists();
assert outputDirectory.isDirectory();

generatedFile = new File(outputDirectory, 'test_pb.js');
assert generatedFile.exists();
assert generatedFile.isFile();

content = generatedFile.text;
assert content.contains('TestMessage');
assert content.contains('NestedMessage');

return true;
22 changes: 22 additions & 0 deletions src/it/TEST-34/invoker.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#
# Copyright (c) 2018 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 JavaScript generation works for test protos

# 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-test-sources
Loading

0 comments on commit 0d4d6f7

Please sign in to comment.