Skip to content

Commit c4dc70a

Browse files
authored
test(storage): exclude jqwik tests on Java 8 (#13846)
### Problem Jqwik version 1.9+ requires JDK 11+ at runtime. Since `google-cloud-java` runs tests on JDK 8 matrix environments, Jqwik's reflection-based class scanning fails when JSpecify 1.0.0 annotations are present, causing `UnsupportedClassVersionError` or reflection scanner crashes during JUnit test discovery on Java 8. ### Solution This PR introduces a clean profile-based exclusion to isolate Jqwik on Java 8 without impacting modern Java environments: 1. **Moved Jqwik dependency into `jqwik-tests` profile:** The `net.jqwik:jqwik` library is no longer loaded globally; it is only added to the test classpath on JDK 11+ (`[11,)`). 2. **Added `exclude-jqwik-on-java8` profile:** Active only when the JDK is exactly `1.8`. 3. **Excluded Jqwik test compilation:** Inside the Java 8 profile, we use `testExcludes` to skip compiling all Jqwik-based property tests (e.g., `*PropertyTest.java`, `jqwik` packages, etc.) to prevent compile errors when Jqwik is not on the classpath. 4. **Decoupled compilation dependencies:** Excluded `RewindableByteBufferContentTest.java` on Java 8 as well, since it has an import reference to a nested class inside `RewindableContentPropertyTest.java` and would otherwise pull it into compiler scope. ### Rationale - Decouples Jqwik testing dependencies on Java 8 matrix builds, preventing pipeline failures. - Retains 100% test coverage for these property-based tests on modern JDKs (11, 17, 21, etc.) since matrix builds continue to compile and run them normally.
1 parent 49be37a commit c4dc70a

1 file changed

Lines changed: 54 additions & 6 deletions

File tree

  • java-storage/google-cloud-storage

java-storage/google-cloud-storage/pom.xml

Lines changed: 54 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -338,12 +338,6 @@
338338
<artifactId>junit-vintage-engine</artifactId>
339339
<scope>test</scope>
340340
</dependency>
341-
<dependency>
342-
<groupId>net.jqwik</groupId>
343-
<artifactId>jqwik</artifactId>
344-
<version>1.9.3</version>
345-
<scope>test</scope>
346-
</dependency>
347341
<dependency>
348342
<groupId>io.github.classgraph</groupId>
349343
<artifactId>classgraph</artifactId>
@@ -474,6 +468,60 @@
474468
</build>
475469

476470
<profiles>
471+
<profile>
472+
<id>jqwik-tests</id>
473+
<activation>
474+
<jdk>[11,)</jdk>
475+
</activation>
476+
<dependencies>
477+
<dependency>
478+
<groupId>net.jqwik</groupId>
479+
<artifactId>jqwik</artifactId>
480+
<version>1.9.3</version>
481+
<scope>test</scope>
482+
</dependency>
483+
</dependencies>
484+
</profile>
485+
<!--
486+
Exclude Jqwik and its tests on Java 8 because Jqwik 1.9+ requires Java 11+.
487+
Jqwik's reflection-based test scanning fails on Java 8 when JSpecify annotations are present.
488+
Test coverage for these Jqwik property tests is still run and maintained on JDK 11+ matrix builds.
489+
-->
490+
<profile>
491+
<id>exclude-jqwik-on-java8</id>
492+
<activation>
493+
<jdk>1.8</jdk>
494+
</activation>
495+
<build>
496+
<plugins>
497+
<plugin>
498+
<groupId>org.apache.maven.plugins</groupId>
499+
<artifactId>maven-compiler-plugin</artifactId>
500+
<executions>
501+
<execution>
502+
<id>default-testCompile</id>
503+
<configuration>
504+
<testExcludes>
505+
<exclude>**/*PropertyTest.java</exclude>
506+
<exclude>**/JqwikTest.java</exclude>
507+
<exclude>**/jqwik/**</exclude>
508+
<exclude>**/StorageV2ProtoUtilsTest.java</exclude>
509+
<exclude>**/JsonUtilsTest.java</exclude>
510+
<exclude>**/ChunkSegmenterTest.java</exclude>
511+
<exclude>**/DefaultBufferedWritableByteChannelTest.java</exclude>
512+
<exclude>**/MinFlushBufferedWritableByteChannelTest.java</exclude>
513+
<exclude>**/DefaultBufferedReadableByteChannelTest.java</exclude>
514+
<exclude>**/Crc32cValueTest.java</exclude>
515+
<exclude>**/ITSyncingFileChannelTest.java</exclude>
516+
<exclude>**/RewindableByteBufferContentTest.java</exclude>
517+
</testExcludes>
518+
</configuration>
519+
</execution>
520+
</executions>
521+
</plugin>
522+
</plugins>
523+
</build>
524+
</profile>
477525
<profile>
478526
<id>idea-jqwik</id>
479527
<dependencies>

0 commit comments

Comments
 (0)