Skip to content

Commit ced66d8

Browse files
committed
checkstyle: fix broken build
The Maven build configuration of the Checkstyle project requires Java 21 or a higher version. However, the default OSS-Fuzz base image provides Java 17, resulting in a mismatch error regarding the Java version.
1 parent 583430e commit ced66d8

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

projects/checkstyle/Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ RUN curl -L https://archive.apache.org/dist/maven/maven-3/3.6.3/binaries/apache-
1919
unzip maven.zip -d $SRC/maven && \
2020
rm maven.zip
2121
ENV MVN $SRC/maven/apache-maven-3.6.3/bin/mvn
22+
RUN apt-get update && apt-get install -y openjdk-21-jdk rsync
23+
ENV JAVA_HOME /usr/lib/jvm/java-21-openjdk-amd64
24+
ENV PATH "$JAVA_HOME/bin:$PATH"
2225
RUN git clone --depth 1 https://github.com/checkstyle/checkstyle checkstyle
2326
COPY *.sh *Fuzzer.java $SRC/
2427
WORKDIR $SRC/checkstyle

projects/checkstyle/build.sh

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,26 @@
1414
# limitations under the License.
1515
#
1616
##########################################################################
17+
export JAVA_HOME=/usr/lib/jvm/java-21-openjdk-amd64
18+
export PATH="$JAVA_HOME/bin:$PATH"
1719
export TARGET_PACKAGE_PREFIX="com.puppycrawl.tools.checkstyle."
1820

19-
MAVEN_ARGS="-Dmaven.test.skip=true -Djavac.src.version=15 -Djavac.target.version=15 --update-snapshots"
21+
MAVEN_ARGS="-Dmaven.test.skip=true -Djavac.src.version=21 -Djavac.target.version=21 --update-snapshots"
2022
$MVN clean package $MAVEN_ARGS
2123

2224
BUILD_CLASSPATH=
2325
RUNTIME_CLASSPATH=
2426

25-
for JARFILE in $(find ./ -name *.jar)
27+
for JARFILE in $(find ./ -name "*.jar")
2628
do
2729
cp $JARFILE $OUT/
2830
BUILD_CLASSPATH=$BUILD_CLASSPATH$OUT/$(basename $JARFILE):
2931
RUNTIME_CLASSPATH=$RUNTIME_CLASSPATH\$this_dir/$(basename $JARFILE):
3032
done
3133

34+
mkdir -p $OUT/jdk-21
35+
rsync -aL --exclude=*.zip "$JAVA_HOME/" "$OUT/jdk-21/"
36+
3237
# Build corpus with valid java files
3338
mkdir $SRC/tmp-corpus
3439
find $SRC -name "*.java" -exec cp {} $SRC/tmp-corpus/ \;
@@ -61,7 +66,9 @@ do
6166
mem_settings='-Xmx2048m:-Xss1024k'
6267
fi
6368
64-
LD_LIBRARY_PATH=\"$JVM_LD_LIBRARY_PATH\":\$this_dir \
69+
export JAVA_HOME=\$this_dir/jdk-21
70+
export PATH=\$JAVA_HOME/bin:\$PATH
71+
LD_LIBRARY_PATH=\"\$JAVA_HOME/lib/server\":\$this_dir \
6572
\$this_dir/jazzer_driver --agent_path=\$this_dir/jazzer_agent_deploy.jar \
6673
--cp=$RUNTIME_CLASSPATH \
6774
--target_class=$fuzzer_basename \

0 commit comments

Comments
 (0)