Skip to content

buildscripts: Build Android with main build in linux_artifacts #10299

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion android-interop-testing/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ import net.ltgt.gradle.errorprone.CheckSeverity

tasks.withType(JavaCompile).configureEach {
options.compilerArgs += [
"-Xlint:-cast"
"-Xlint:-cast",
"-Xlint:-deprecation", // https://github.com/grpc/grpc-java/issues/10298
]
appendToProperty(it.options.errorprone.excludedPaths, ".*/R.java", "|")
appendToProperty(
Expand Down
1 change: 1 addition & 0 deletions binder/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ tasks.withType(JavaCompile).configureEach {
options.compilerArgs += [
"-Xlint:-cast"
]
options.compilerArgs -= ["-Werror"] // https://github.com/grpc/grpc-java/issues/10297
appendToProperty(it.options.errorprone.excludedPaths, ".*/R.java", "|")
}

Expand Down
3 changes: 3 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ subprojects {
"-Xlint:-try"
]
it.options.encoding = "UTF-8"
// Avoid Gradle OOM.
// https://docs.gradle.org/current/userguide/performance.html#run_the_compiler_as_a_separate_process
it.options.fork = true
if (rootProject.hasProperty('failOnWarnings') && rootProject.failOnWarnings.toBoolean()) {
it.options.compilerArgs += ["-Werror"]
}
Expand Down
12 changes: 11 additions & 1 deletion buildscripts/grpc-java-artifacts/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,28 @@ RUN yum install -y \
gcc-c++.i686 \
glibc-devel \
glibc-devel.i686 \
java-1.8.0-openjdk-devel \
java-11-openjdk-devel \
libstdc++-devel \
libstdc++-devel.i686 \
libstdc++-static \
libstdc++-static.i686 \
libtool \
make \
tar \
unzip \
which \
&& \
yum clean all

ENV ANDROID_HOME=/opt/Android/Sdk
RUN mkdir -p "$ANDROID_HOME/cmdline-tools" && \
curl -Ls -o cmdline.zip \
"https://dl.google.com/android/repository/commandlinetools-linux-9477386_latest.zip" && \
unzip -qd "$ANDROID_HOME/cmdline-tools" cmdline.zip && \
rm cmdline.zip && \
mv "$ANDROID_HOME/cmdline-tools/cmdline-tools" "$ANDROID_HOME/cmdline-tools/latest" && \
yes | "$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager" --licenses

# Install Maven
RUN curl -Ls https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.3.9/apache-maven-3.3.9-bin.tar.gz | \
tar xz -C /var/local
Expand Down
2 changes: 1 addition & 1 deletion buildscripts/kokoro/android-interop.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export CXXFLAGS=-I/tmp/protobuf/include
export LD_LIBRARY_PATH=/tmp/protobuf/lib
export OS_NAME=$(uname)

echo y | ${ANDROID_HOME}/tools/bin/sdkmanager "build-tools;28.0.3"
(yes || true) | "${ANDROID_HOME}/tools/bin/sdkmanager" --licenses

# Proto deps
buildscripts/make_dependencies.sh
Expand Down
2 changes: 1 addition & 1 deletion buildscripts/kokoro/android.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ cat <<EOF >> gradle.properties
org.gradle.jvmargs=-Xmx2048m -XX:MaxMetaspaceSize=1024m
EOF

echo y | ${ANDROID_HOME}/tools/bin/sdkmanager "build-tools;28.0.3"
(yes || true) | "${ANDROID_HOME}/tools/bin/sdkmanager" --licenses

# Proto deps
buildscripts/make_dependencies.sh
Expand Down
39 changes: 0 additions & 39 deletions buildscripts/kokoro/linux_artifacts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,45 +13,6 @@ trap spongify_logs EXIT
"$GRPC_JAVA_DIR"/buildscripts/build_docker.sh
"$GRPC_JAVA_DIR"/buildscripts/run_in_docker.sh grpc-java-artifacts-x86 /grpc-java/buildscripts/build_artifacts_in_docker.sh

# grpc-android, grpc-cronet and grpc-binder require the Android SDK, so build outside of Docker and
# use --include-build for its grpc-core dependency
echo y | ${ANDROID_HOME}/tools/bin/sdkmanager "build-tools;28.0.3"

# The sdkmanager needs Java 8, but now we switch to 11 as the Android builds
# require it
sudo update-java-alternatives --set java-1.11.0-openjdk-amd64
unset JAVA_HOME

LOCAL_MVN_TEMP=$(mktemp -d)
GRADLE_FLAGS="-Pandroid.useAndroidX=true"
pushd "$GRPC_JAVA_DIR/android"
../gradlew publish \
-Dorg.gradle.parallel=false \
-PskipCodegen=true \
-PrepositoryDir="$LOCAL_MVN_TEMP" \
$GRADLE_FLAGS
popd

pushd "$GRPC_JAVA_DIR/cronet"
../gradlew publish \
-Dorg.gradle.parallel=false \
-PskipCodegen=true \
-PrepositoryDir="$LOCAL_MVN_TEMP" \
$GRADLE_FLAGS
popd

pushd "$GRPC_JAVA_DIR/binder"
../gradlew publish \
-Dorg.gradle.parallel=false \
-PskipCodegen=true \
-PrepositoryDir="$LOCAL_MVN_TEMP" \
$GRADLE_FLAGS
popd

readonly MVN_ARTIFACT_DIR="${MVN_ARTIFACT_DIR:-$GRPC_JAVA_DIR/mvn-artifacts}"
mkdir -p "$MVN_ARTIFACT_DIR"
cp -r "$LOCAL_MVN_TEMP"/* "$MVN_ARTIFACT_DIR"/

"$GRPC_JAVA_DIR"/buildscripts/run_in_docker.sh grpc-java-artifacts-multiarch env \
SKIP_TESTS=true ARCH=aarch_64 /grpc-java/buildscripts/kokoro/unix.sh
"$GRPC_JAVA_DIR"/buildscripts/run_in_docker.sh grpc-java-artifacts-multiarch env \
Expand Down
6 changes: 5 additions & 1 deletion buildscripts/kokoro/unix.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,12 @@ GRADLE_FLAGS+=" -PtargetArch=$ARCH"
GRADLE_FLAGS+=" -Pcheckstyle.ignoreFailures=false"
GRADLE_FLAGS+=" -PfailOnWarnings=true"
GRADLE_FLAGS+=" -PerrorProne=true"
GRADLE_FLAGS+=" -PskipAndroid=true"
GRADLE_FLAGS+=" -Dorg.gradle.parallel=true"
if [[ -z "${ALL_ARTIFACTS:-}" ]]; then
GRADLE_FLAGS+=" -PskipAndroid=true"
else
GRADLE_FLAGS+=" -Pandroid.useAndroidX=true"
fi
export GRADLE_OPTS="-Dorg.gradle.jvmargs='-Xmx1g'"

# Make protobuf discoverable by :grpc-compiler
Expand Down