Skip to content

Commit 9a5cce4

Browse files
authored
chore: Generate grpc classes from protobuf in build (#217)
# Description Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly: - [x] Follow the [`CONTRIBUTING` Guide](../CONTRIBUTING.md). - [x] Make your Pull Request title in the <https://www.conventionalcommits.org/> specification. - Important Prefixes for [release-please](https://github.com/googleapis/release-please): - `fix:` which represents bug fixes, and correlates to a [SemVer](https://semver.org/) patch. - `feat:` represents a new feature, and correlates to a SemVer minor. - `feat!:`, or `fix!:`, `refactor!:`, etc., which represent a breaking change (indicated by the `!`) and will result in a SemVer major. - [x] Ensure the tests pass - [x] Appropriate READMEs were updated (if necessary) Fixes #<issue_number_goes_here> 🦕
1 parent a788f03 commit 9a5cce4

File tree

91 files changed

+2681
-1962
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+2681
-1962
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@ You can build the A2A Java SDK using `mvn`:
1919
mvn clean install
2020
```
2121

22+
### Regeneration of gRPC files
23+
We copy https://github.com/a2aproject/A2A/blob/main/specification/grpc/a2a.proto to the [`spec-grpc/`](./spec-grpc) project, and adjust the `java_package` option to be as follows:
24+
```
25+
option java_package = "io.a2a.grpc";
26+
```
27+
Then build the `spec-grpc` module with `mvn clean install -Pproto-compile` to regenerate the gRPC classes in the `io.a2a.grpc` package.
28+
2229
## Examples
2330

2431
You can find an example of how to use the A2A Java SDK in the [a2a-samples repository](https://github.com/a2aproject/a2a-samples/tree/main/samples/multi_language/python_and_java_multiagent/weather_agent).

pom.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
<properties>
4141
<grpc.version>1.73.0</grpc.version>
4242
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
43+
<maven-clean-plugin.version>3.5.0</maven-clean-plugin.version>
4344
<maven-compiler-plugin.version>3.11.0</maven-compiler-plugin.version>
4445
<maven-jar-plugin.version>3.4.2</maven-jar-plugin.version>
4546
<maven-source-plugin.version>3.3.1</maven-source-plugin.version>
@@ -56,7 +57,9 @@
5657
<mockito-core.version>5.17.0</mockito-core.version>
5758
<mockserver.version>5.15.0</mockserver.version>
5859
<mutiny-zero.version>1.1.1</mutiny-zero.version>
60+
<os-maven-plugin.version>1.7.1</os-maven-plugin.version>
5961
<protobuf.version>4.31.1</protobuf.version>
62+
<protobuf-maven-plugin.version>0.6.1</protobuf-maven-plugin.version>
6063
<quarkus.platform.version>3.24.5</quarkus.platform.version>
6164
<rest-assured.version>5.5.1</rest-assured.version>
6265
<slf4j.version>2.0.17</slf4j.version>

spec-grpc/pom.xml

Lines changed: 84 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,89 @@
4242
<groupId>jakarta.inject</groupId>
4343
<artifactId>jakarta.inject-api</artifactId>
4444
</dependency>
45+
<dependency>
46+
<groupId>com.google.api.grpc</groupId>
47+
<artifactId>proto-google-common-protos</artifactId>
48+
</dependency>
49+
50+
<!-- Annotation dependency for generated code -->
51+
<dependency>
52+
<groupId>javax.annotation</groupId>
53+
<artifactId>javax.annotation-api</artifactId>
54+
<scope>provided</scope>
55+
</dependency>
4556
</dependencies>
46-
57+
58+
<build>
59+
<extensions>
60+
<!--
61+
Seems to be needed by the protobuf-maven-plugin.
62+
Adding these extensions to the profile is not possible
63+
-->
64+
<extension>
65+
<groupId>kr.motd.maven</groupId>
66+
<artifactId>os-maven-plugin</artifactId>
67+
<version>${os-maven-plugin.version}</version>
68+
</extension>
69+
</extensions>
70+
</build>
71+
72+
<profiles>
73+
<profile>
74+
<id>proto-compile</id>
75+
<build>
76+
77+
<plugins>
78+
<plugin>
79+
<groupId>org.apache.maven.plugins</groupId>
80+
<artifactId>maven-clean-plugin</artifactId>
81+
<version>${maven-clean-plugin.version}</version>
82+
<executions>
83+
<execution>
84+
<id>remove-generated-files</id>
85+
<phase>initialize</phase>
86+
<goals>
87+
<goal>clean</goal>
88+
</goals>
89+
<configuration>
90+
<excludeDefaultDirectories>true</excludeDefaultDirectories>
91+
<filesets>
92+
<fileset>
93+
<directory>${project.basedir}/src/main/java/io/a2a/grpc</directory>
94+
<followSymlinks>false</followSymlinks>
95+
<includes>
96+
<include>*.java</include>
97+
</includes>
98+
</fileset>
99+
</filesets>
100+
</configuration>
101+
</execution>
102+
</executions>
103+
</plugin>
104+
<!-- Protocol Buffers Compiler Plugin -->
105+
<plugin>
106+
<groupId>org.xolstice.maven.plugins</groupId>
107+
<artifactId>protobuf-maven-plugin</artifactId>
108+
<version>${protobuf-maven-plugin.version}</version>
109+
<configuration>
110+
<protocArtifact>com.google.protobuf:protoc:${protobuf.version}:exe:${os.detected.classifier}</protocArtifact>
111+
<pluginId>grpc-java</pluginId>
112+
<pluginArtifact>io.grpc:protoc-gen-grpc-java:${grpc.version}:exe:${os.detected.classifier}</pluginArtifact>
113+
<outputDirectory>src/main/java</outputDirectory>
114+
<clearOutputDirectory>false</clearOutputDirectory>
115+
</configuration>
116+
<executions>
117+
<execution>
118+
<goals>
119+
<goal>compile</goal>
120+
<goal>compile-custom</goal>
121+
</goals>
122+
</execution>
123+
</executions>
124+
</plugin>
125+
</plugins>
126+
</build>
127+
128+
</profile>
129+
</profiles>
47130
</project>

0 commit comments

Comments
 (0)