Last active
June 27, 2017 09:04
-
-
Save longforfreedom/afdd651905ab9ad8689f31a688fbf657 to your computer and use it in GitHub Desktop.
maven构建grpc程序
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
src/main/proto目录下存放定义文件 | |
先package一次,会根据定义生成相应文件,可以在代码中引用 | |
## pom.xml 内容类似下面 | |
<?xml version="1.0" encoding="UTF-8"?> | |
<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> | |
<groupId>me.migle.etcdtest</groupId> | |
<artifactId>etcdtest</artifactId> | |
<version>1.0-SNAPSHOT</version> | |
<properties> | |
<grpc.version>1.4.0</grpc.version><!-- CURRENT_GRPC_VERSION --> | |
</properties> | |
<dependencies> | |
<dependency> | |
<groupId>io.grpc</groupId> | |
<artifactId>grpc-netty</artifactId> | |
<version>${grpc.version}</version> | |
</dependency> | |
<dependency> | |
<groupId>io.grpc</groupId> | |
<artifactId>grpc-protobuf</artifactId> | |
<version>${grpc.version}</version> | |
</dependency> | |
<dependency> | |
<groupId>io.grpc</groupId> | |
<artifactId>grpc-stub</artifactId> | |
<version>${grpc.version}</version> | |
</dependency> | |
<dependency> | |
<groupId>io.grpc</groupId> | |
<artifactId>grpc-testing</artifactId> | |
<version>${grpc.version}</version> | |
<scope>test</scope> | |
</dependency> | |
<dependency> | |
<groupId>junit</groupId> | |
<artifactId>junit</artifactId> | |
<version>4.11</version> | |
<scope>test</scope> | |
</dependency> | |
<dependency> | |
<groupId>org.mockito</groupId> | |
<artifactId>mockito-core</artifactId> | |
<version>1.9.5</version> | |
<scope>test</scope> | |
</dependency> | |
</dependencies> | |
<build> | |
<extensions> | |
<extension> | |
<groupId>kr.motd.maven</groupId> | |
<artifactId>os-maven-plugin</artifactId> | |
<version>1.4.1.Final</version> | |
</extension> | |
</extensions> | |
<plugins> | |
<plugin> | |
<groupId>org.xolstice.maven.plugins</groupId> | |
<artifactId>protobuf-maven-plugin</artifactId> | |
<version>0.5.0</version> | |
<configuration> | |
<protocArtifact>com.google.protobuf:protoc:3.3.0:exe:${os.detected.classifier}</protocArtifact> | |
<pluginId>grpc-java</pluginId> | |
<pluginArtifact>io.grpc:protoc-gen-grpc-java:${grpc.version}:exe:${os.detected.classifier}</pluginArtifact> | |
</configuration> | |
<executions> | |
<execution> | |
<goals> | |
<goal>compile</goal> | |
<goal>compile-custom</goal> | |
</goals> | |
</execution> | |
</executions> | |
</plugin> | |
</plugins> | |
</build> | |
</project> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment