Skip to content

Commit

Permalink
Update to 1.8.0 of generator
Browse files Browse the repository at this point in the history
  • Loading branch information
slewi committed Oct 8, 2021
1 parent a39780e commit b83c573
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 47 deletions.
38 changes: 19 additions & 19 deletions generator/dumped helloworld generator.launch
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/generator/src/main/java/org/eclipse/ecf/grpc/osgigenerator/OSGiGenerator.java"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="1"/>
</listAttribute>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_ATTR_USE_ARGFILE" value="false"/>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_SHOW_CODEDETAILS_IN_EXCEPTION_MESSAGES" value="true"/>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_CLASSPATH_ONLY_JAR" value="false"/>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_START_ON_FIRST_THREAD" value="true"/>
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.m2e.launchconfig.classpathProvider"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.ecf.grpc.osgigenerator.OSGiGenerator"/>
<stringAttribute key="org.eclipse.jdt.launching.MODULE_NAME" value="grpc-osgi-generator"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="examples/hello-world/target/generated-sources/protobuf/java/descriptor_dump"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="generator"/>
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.m2e.launchconfig.sourcepathProvider"/>
</launchConfiguration>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/generator/src/main/java/org/eclipse/ecf/grpc/osgigenerator/OSGiGenerator.java"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="1"/>
</listAttribute>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_ATTR_USE_ARGFILE" value="false"/>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_SHOW_CODEDETAILS_IN_EXCEPTION_MESSAGES" value="true"/>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_CLASSPATH_ONLY_JAR" value="false"/>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_START_ON_FIRST_THREAD" value="true"/>
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.m2e.launchconfig.classpathProvider"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.ecf.grpc.osgigenerator.OSGiGenerator"/>
<stringAttribute key="org.eclipse.jdt.launching.MODULE_NAME" value="grpc-osgi-generator"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="examples/hello-world/target/generated-sources/protobuf/java/descriptor_dump -rx3"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="generator"/>
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.m2e.launchconfig.sourcepathProvider"/>
</launchConfiguration>
4 changes: 2 additions & 2 deletions generator/examples/hello-world/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@
<id>grpc-osgi-generator</id>
<groupId>org.eclipse.ecf</groupId>
<artifactId>grpc-osgi-generator</artifactId>
<version>1.6.0</version>
<mainClass>org.eclipse.ecf.grpc.osgigenerator.OSGiGenerator</mainClass>
<version>1.8.0</version>
<mainClass>org.eclipse.ecf.grpc.osgigenerator.RxJava3OSGiGenerator</mainClass>
</protocPlugin>
<protocPlugin>
<id>dump</id>
Expand Down
2 changes: 0 additions & 2 deletions generator/examples/hello-world/src/main/proto/Hello.proto
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ option java_outer_classname = "HelloWorldProto";
* Define the service's operations
*/
service Greeter {
option (generation_type) = GRPC_UNARY;
/*
* Greet
*/
Expand All @@ -23,7 +22,6 @@ service Greeter {
* Define the service's operations
*/
service Greeter1 {
option (service_reactivex_version) = V_3;
/*
* Greet1
*/
Expand Down
23 changes: 1 addition & 22 deletions generator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<version>1.6.0</version>
<version>1.8.0</version>

<artifactId>grpc-osgi-generator</artifactId>

Expand Down Expand Up @@ -74,27 +74,6 @@

<plugins>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<author>false</author>
<breakiterator>true</breakiterator>
<doclint>accessibility,html,reference,syntax</doclint>
<keywords>true</keywords>
<version>false</version>
<source>8</source>
</configuration>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,24 @@ public class OSGiGenerator extends Generator {

private static final String DEFAULT_BODY_NULL_RETURN = "return null";

private boolean useRx3 = false;

protected OSGiGenerator(boolean rx3) {
this.useRx3 = rx3;
}

public static void main(String[] args) throws Exception {
boolean useRx3 = false;
if (args.length > 0) {
List<String> argsList = new ArrayList<String>(Arrays.asList(args));
if (argsList.contains("rxjava3")) {
useRx3 = true;
argsList.remove("rxjava3");
args = argsList.toArray(new String[argsList.size()]);
}
}
List<Generator> generators = new ArrayList<Generator>();
generators.add(new OSGiGenerator());
generators.add(new OSGiGenerator(useRx3));
@SuppressWarnings("rawtypes")
List<GeneratedExtension> extensions = new ArrayList<GeneratedExtension>();
extensions.add(OsgiServiceOptionsProto.generationType);
Expand Down Expand Up @@ -77,7 +92,7 @@ private List<ServiceContext> findServices(List<FileDescriptorProto> protos, Prot
for (int serviceNumber = 0; serviceNumber < fileProto.getServiceCount(); serviceNumber++) {
ServiceContext serviceContext = buildServiceContext(fileProto.getService(serviceNumber), typeMap,
fileProto.getSourceCodeInfo().getLocationList(), serviceNumber,
fileProto.getOptions().getExtension(OsgiServiceOptionsProto.fileReactivexVersion));
useRx3?ReactiveXVersion.V_3:fileProto.getOptions().getExtension(OsgiServiceOptionsProto.fileReactivexVersion));
serviceContext.protoName = fileProto.getName();
serviceContext.packageName = extractPackageName(fileProto);
contexts.add(serviceContext);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package org.eclipse.ecf.grpc.osgigenerator;

import java.util.ArrayList;
import java.util.List;

import com.google.protobuf.GeneratedMessage.GeneratedExtension;
import com.salesforce.jprotoc.Generator;
import com.salesforce.jprotoc.ProtocPlugin;

public class RxJava3OSGiGenerator extends OSGiGenerator {

public RxJava3OSGiGenerator(boolean rx3) {
super(rx3);
}

public static void main(String[] args) {
List<Generator> generators = new ArrayList<Generator>();
generators.add(new RxJava3OSGiGenerator(true));
@SuppressWarnings("rawtypes")
List<GeneratedExtension> extensions = new ArrayList<GeneratedExtension>();
extensions.add(OsgiServiceOptionsProto.generationType);
extensions.add(OsgiServiceOptionsProto.interfaceMethodBodyType);
extensions.add(OsgiServiceOptionsProto.fileReactivexVersion);
extensions.add(OsgiServiceOptionsProto.serviceReactivexVersion);
if (args.length == 0) {
ProtocPlugin.generate(generators, extensions);
} else {
ProtocPlugin.debug(generators, extensions, args[0]);
}
}

}

0 comments on commit b83c573

Please sign in to comment.