Cannot exclude generated source in a multi-module gradle build
- Dominant language
- Java
- Stars
- 5.6k
- Forks
- 559
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 34
Description
Spotless error! All target files must be within the project dir.
project dir: /Users/niels/repo/sx/helium/helium-main/helium-data-model
target: /Users/niels/repo/sx/helium/helium-main/build/helium-data-model/generated/sources/xjc/java/com/soundexchange/helium/distribution/iso20022/NameAndAddress3.java'
I stepped through the build in a debugger and found that the problem lies in SpotlessTaskImpl.getOutputFile(). The call to FormatExtension.relativize returns null, which causes the exception to be thrown. relativize returns null because the targetExclude (${project.rootDir}/build/generated...) specified is not a child of the subproject directory in a multi-module build. So targetExclude can't be used to exclude generated sources from a multi-module build, because the build output is at the root directory, not the subproject directory.
_Originally posted by @niels1voo in https://github.com/diffplug/spotless/issues/399#issuecomment-1090845702_
Contributor guide
Assessment
This issue has not been assessed yet.