ITADN

shadowJar fails with "Cannot expand ZIP" when dependency includes non-existent class directory

#1975Openln-e 创建于 2026-03-13
bug
L
ln-ecommented
### Expected and Results When a project dependency includes a class output directory that does not exist (e.g., build/classes/java/api from a custom source set with no Java sources), shadowJar should gracefully skip it or treat it as an empty directory, rather than failing. Actual behavior shadowJar fails with: Cannot expand ZIP '/path/to/project/build/classes/java/api' as it does not exist. ### Related environment and versions _No response_ ### Reproduction steps 1. Create a multi-module Gradle project with a custom api source set: ``` // root build.gradle.kts subprojects { sourceSets { val api by creating val main by getting { compileClasspath += api.output runtimeClasspath += api.output } } } ``` 2. In one of the submodules, apply the Shadow plugin and have Kotlin-only sources in the api source set (no Java files under src/api/java/). 3. Run ./gradlew :module:shadowJar. 4. The task fails because build/classes/java/api is included in runtimeClasspath via api.output, but the directory was never created since there are no Java sources to compile in that source set. ### Anything else? _No response_
1 条评论