liusheng / liusheng.github.io

Liusheng's blog
http://liusheng.github.io
5 stars 1 forks source link

Compile grpc-java-1.15.1 on Ubuntu 16.04 of ARM64 platform #13

Open liusheng opened 4 years ago

liusheng commented 4 years ago

0. Enironment info

I am using java 11 on a Ubuntu 16.04 VM

liusheng@ecs-791c-0003:~$ uname -a
Linux ecs-791c-0003 4.15.0-29-generic #31-Ubuntu SMP Tue Jul 17 15:41:03 UTC 2018 aarch64 aarch64 aarch64 GNU/Linux
liusheng@ecs-791c-0003:~$ java --versionopenjdk 11.0.4 2019-07-16
OpenJDK Runtime Environment (build 11.0.4+11-post-Ubuntu-1ubuntu218.04.3)OpenJDK 64-Bit Server VM (build 11.0.4+11-post-Ubuntu-1ubuntu218.04.3, mixed mode)

1. Compile protobuf-3.5.1

grpc-java-1.15.1 require protobuf-3.5.1

git clone https://github.com/google/protobuf.git
pushd protobuf
git checkout v3.5.1.1
./autogen.sh && ./configure && make clean install

2. compile grpc-java-1.15.1

git clone https://github.com/grpc/grpc-java.git pushd grpc-java git checkout v1.15.1 ./gradlew build -x test -x javadoc -PskipCodegen=true popd

3. Issues while building

a) building doc failure

The code being documented uses modules but the packages defined in https://docs.oracle.com/javase/8/docs/api/ are in the unnamed module

exist similar issue: https://github.com/joel-costigliola/assertj-core/issues/1403 solution: add -x javadoc arguments to gradlew command to skip doc generation

b) error: cannot find symbol javax.annotation.Generated

existing issue: https://github.com/grpc/grpc-java/issues/5343 solution: upgrade the version of javax.annotation-api

diff --git a/build.gradle b/build.gradle
index d9d8b2bba..7a8e0b7e8 100644
--- a/build.gradle
+++ b/build.gradle
@@ -122,7 +122,7 @@ subprojects {
             gson: "com.google.code.gson:gson:2.8.5",
             guava: "com.google.guava:guava:${guavaVersion}",
             hpack: 'com.twitter:hpack:0.10.1',
-            javax_annotation: 'javax.annotation:javax.annotation-api:1.2',
+            javax_annotation: 'javax.annotation:javax.annotation-api:1.3.2',
             jsr305: 'com.google.code.findbugs:jsr305:3.0.2',
             google_api_protos: 'com.google.api.grpc:proto-google-common-protos:1.12.0',
             google_auth_credentials: "com.google.auth:google-auth-library-credentials:${googleauthVersion}",

c) missing protobuf-javalite of aarch64 dependency

3. Execution failed for task ':grpc-protobuf-lite:generateTestProto'.                                                                                                      
> Could not resolve all files for configuration ':grpc-protobuf-lite:protobufToolsLocator_javalite'.                                                                    
   > Could not find protoc-gen-javalite-linux-aarch_64.exe (com.google.protobuf:protoc-gen-javalite:3.0.0).                                                            
     Searched in the following locations:                                                                                                  
         https://maven-central.storage-download.googleapis.com/repos/central/data/com/google/protobuf/protoc-gen-javalite/3.0.0/protoc-gen-javalite-3.0.0-linux-aarch_64.exe

solution: compile protobuf-v3.0.0-javalite manually

pushd protobuf
git checkout v3.0.0-javalite
./autogen.sh && ./configure && make clean install
popd

4. build again with protoc-gen-javalite specified

pushd grpc-java
export CXXFLAGS="-I/usr/local/include -L/usr/local/lib"
export LDFLAGS="$CXXFLAGS"
export LD_LIBRARY_PATH="/usr/local/lib"
./gradlew build -x test -x javadoc -PskipCodegen=true -Pprotoc-gen-javalite=/usr/local/bin/protoc-gen-javalite
./gradlew install
popd