swiftlang / swiftlang/swift-java
JavaCompilerPlugin doesn't handle outputs correctly
Nobody has claimed this yet.
- Dominant language
- Swift
- Stars
- 1.2k
- Forks
- 123
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 16
Description
The JavaCompilerPlugin has a serious flaw in that it doesn't handle outputs correctly -- it simply maps each .java file path to an equivalent .class file path, but due to a combination of use of certain language features like inner classes, and compiler implementation details which can vary across versions and implementations, there is NO guarantee that compilation of a set of Java sources will produce corresponding .class files at a 1:1 relationship.
This means the outputFiles may fail to capture class files which are generated, leading to broken products and/or broken incremental builds.
In Qbs I implemented this via a tool using compiler APIs to get the list of the .class files which will be produced: https://github.com/qbs/qbs/blob/master/share/qbs/modules/java/io/qt/qbs/tools/utils/JavaCompilerScanner.java. But this is a more involved solution and is only needed if you want to pass individual .class files to downstream build rules for further processing.
For now, can we instead produce a jar file with the set of generated classes, and list THAT as the build tool plugin command output? This simplifies the solution significantly.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the JavaCompilerPlugin and trace how outputFiles currently map each .java source to a .class path. Review the referenced Qbs JavaCompilerScanner.java for context, then determine how to package generated classes into a jar and expose that jar as the command output; done means generated outputs are captured for downstream rules and incremental builds.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100