Skip to content

Commit 3683a86

Browse files
authored
Use the latest releases of protoc and protobuf-java for ProtobufFuzzer (#13635)
Use the latest releases of protoc and protobuf-java for ProtobufFuzzer instead of from protobuf github main branch, which is not gauranteed to build or work at any time.
1 parent dbc0042 commit 3683a86

File tree

2 files changed

+13
-16
lines changed

2 files changed

+13
-16
lines changed

projects/protobuf-java/Dockerfile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ ENV MVN $SRC/maven/apache-maven-3.6.3/bin/mvn
2626

2727
RUN curl -L -O https://raw.githubusercontent.com/protobuf-c/protobuf-c/39cd58f5ff06048574ed5ce17ee602dc84006162/t/test-full.proto
2828

29-
RUN git clone --depth 1 --recursive https://github.com/protocolbuffers/protobuf.git
30-
3129
COPY build.sh $SRC
3230
COPY ProtobufFuzzer.java $SRC
3331

projects/protobuf-java/build.sh

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,21 @@
1515
#
1616
################################################################################
1717

18-
# Build protoc with default options.
18+
# Get the latest protoc binary release
1919
unset CFLAGS CXXFLAGS
20-
cd $SRC/protobuf/
21-
bazel build :protoc
22-
cp $SRC/protobuf/bazel-bin/protoc $SRC/protobuf/protoc
23-
export PROTOC="$SRC/protobuf/bazel-bin/protoc"
20+
mkdir -p $SRC/protobuf
21+
VERSION=$(curl --silent --fail "https://api.github.com/repos/protocolbuffers/protobuf/releases/latest" | jq -r '.tag_name' | sed 's/v//')
22+
PROTOC_ZIP="protoc-$VERSION-linux-x86_64.zip"
23+
curl --silent --fail -L -o "$SRC/$PROTOC_ZIP" "https://github.com/protocolbuffers/protobuf/releases/download/v$VERSION/$PROTOC_ZIP"
24+
unzip -o $PROTOC_ZIP -d $SRC/protobuf
25+
export PROTOC=$SRC/protobuf/bin/protoc
2426

25-
26-
# Build protobuf-java (requires protoc in source tree).
27-
cd $SRC/protobuf/java/
28-
cp $PROTOC $SRC/protobuf/src/
29-
MAVEN_ARGS="-Dmaven.test.skip=true -Djavac.src.version=15 -Djavac.target.version=15"
30-
$MVN package $MAVEN_ARGS
31-
CURRENT_VERSION=$($MVN org.apache.maven.plugins:maven-help-plugin:3.2.0:evaluate \
32-
-Dexpression=project.version -q -DforceStdout)
33-
cp "core/target/protobuf-java-$CURRENT_VERSION.jar" $OUT/protobuf-java.jar
27+
# Get the latest protobuf-java release
28+
JAVA_VERSION=$(curl -s "https://search.maven.org/solrsearch/select?q=g:com.google.protobuf+AND+a:protobuf-java&rows=1&wt=json" \
29+
| jq -r '.response.docs[0].latestVersion')
30+
JAR_FILE="protobuf-java-$JAVA_VERSION.jar"
31+
curl --silent -L -o "$SRC/$JAR_FILE" "https://repo1.maven.org/maven2/com/google/protobuf/protobuf-java/$JAVA_VERSION/$JAR_FILE"
32+
cp $JAR_FILE $OUT/protobuf-java.jar
3433

3534
# Compile test protos with protoc.
3635
cd $SRC/

0 commit comments

Comments
 (0)