[ https://issues.apache.org/jira/browse/CALCITE-6851?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17929791#comment-17929791 ]
Chris Dennis edited comment on CALCITE-6851 at 2/24/25 2:43 PM: ---------------------------------------------------------------- The tests have an implicit dependency on the shaded jar but Gradle is running the tests against the unpackaged classes directory and not the jar. You can see that in the {{--dry-run}} output: {noformat} $ ./gradlew --dry-run :shaded:avatica:test > Configure project : Building Apache Calcite Avatica 1.27.0-SNAPSHOT :core:filterJava SKIPPED :metrics:compileJava SKIPPED :metrics:processResources SKIPPED :core:extractIncludeProto SKIPPED :core:extractProto SKIPPED :core:generateProto SKIPPED :core:compileJava SKIPPED :shaded:avatica:compileJava SKIPPED :shaded:avatica:processResources SKIPPED :shaded:avatica:classes SKIPPED :shaded:avatica:compileTestJava SKIPPED :shaded:avatica:processTestResources SKIPPED :shaded:avatica:testClasses SKIPPED :shaded:avatica:test SKIPPED {noformat} Simplest fix here is to make the test tasks depend on the jar task directly: {code:java} tasks { test { dependsOn jar } } {code} The most "Gradle correct" or zealot way would be something like: {code:java} sourceSets { test { val mainSourceSet = sourceSets.main.get() runtimeClasspath = files(runtimeClasspath).minus(mainSourceSet.output).plus(files(tasks.named(mainSourceSet.jarTaskName))) } } {code} Whichever way we fix it also needs to happen in {{{}standalone-server{}}}. Edit: I guess in compile safe Kotlin-land that could be: {code:java} sourceSets { test { runtimeClasspath = files(runtimeClasspath).minus(files(main.map { it.output })).plus(files(tasks.jar)) } } {code} was (Author: chrisdennis): The tests have an implicit dependency on the shaded jar but Gradle is running the tests against the unpackaged classes directory and not the jar. You can see that in the {{--dry-run}} output: {noformat} $ ./gradlew --dry-run :shaded:avatica:test > Configure project : Building Apache Calcite Avatica 1.27.0-SNAPSHOT :core:filterJava SKIPPED :metrics:compileJava SKIPPED :metrics:processResources SKIPPED :core:extractIncludeProto SKIPPED :core:extractProto SKIPPED :core:generateProto SKIPPED :core:compileJava SKIPPED :shaded:avatica:compileJava SKIPPED :shaded:avatica:processResources SKIPPED :shaded:avatica:classes SKIPPED :shaded:avatica:compileTestJava SKIPPED :shaded:avatica:processTestResources SKIPPED :shaded:avatica:testClasses SKIPPED :shaded:avatica:test SKIPPED {noformat} Simplest fix here is to make the test tasks depend on the jar task directly: {code} tasks { test { dependsOn jar } } {code} The most "Gradle correct" or zealot way would be something like: {code} sourceSets { test { val mainSourceSet = sourceSets.main.get() runtimeClasspath = files(runtimeClasspath).minus(mainSourceSet.output).plus(files(tasks.named(mainSourceSet.jarTaskName))) } } {code} Whichever way we fix it also needs to happen in {{standalone-server}}. Edit: I guess in compile safe Kotlin-land that could be: {code} sourceSets { test { runtimeClasspath = files(runtimeClasspath).minus(files(main.map { output })).plus(files(tasks.jar)) } } {code} > ShadingTest.validateShadedJar fails on first/clean build > -------------------------------------------------------- > > Key: CALCITE-6851 > URL: https://issues.apache.org/jira/browse/CALCITE-6851 > Project: Calcite > Issue Type: Bug > Components: avatica > Reporter: Stamatis Zampetakis > Assignee: Istvan Toth > Priority: Major > Labels: pull-request-available > Fix For: avatica-1.27.0 > > > The ShadingTest.validateShadedJar fails every time during the first {{build}} > and consistently if we run {{clean}} before {{build}}. > {code:bash} > ./gradlew build > {code} > {noformat} > > Task :shaded:avatica:test FAILED > FAILURE 0.0sec, org.apache.calcite.avatica.shadetest.ShadingTest > > validateShadedJar > java.lang.AssertionError: Could not find jar in > /tmp/avatica-126/calcite-avatica/shaded/core/build/libs > at org.junit.Assert.fail(Assert.java:89) > at org.junit.Assert.assertTrue(Assert.java:42) > at > org.apache.calcite.avatica.shadetest.ShadingTest.getShadedJarFile(ShadingTest.java:65) > at > org.apache.calcite.avatica.shadetest.ShadingTest.validateShadedJar(ShadingTest.java:46) > org.apache.calcite.avatica.shadetest.ShadingTest > validateShadedJar FAILED > java.lang.AssertionError: Could not find jar in > /tmp/avatica-126/calcite-avatica/shaded/core/build/libs > at org.junit.Assert.fail(Assert.java:89) > at org.junit.Assert.assertTrue(Assert.java:42) > at > org.apache.calcite.avatica.shadetest.ShadingTest.getShadedJarFile(ShadingTest.java:65) > at > org.apache.calcite.avatica.shadetest.ShadingTest.validateShadedJar(ShadingTest.java:46) > FAILURE 0.1sec, 1 completed, 1 failed, 0 skipped, > org.apache.calcite.avatica.shadetest.ShadingTest > FAILURE 1.2sec, 1 completed, 1 failed, 0 skipped, Gradle Test Run > :shaded:avatica:test > 1 test completed, 1 failed > {noformat} > The test seems to rely on some assumptions about the generation of the jar > that does not always hold leading to build failures. > The workaround is to launch the build two times (and don't clean); in the > first build the test fails but usually passes on the second. -- This message was sent by Atlassian Jira (v8.20.10#820010)