Skip to content

JavaCompilerPlugin doesn't handle outputs correctly #114

Open
@jakepetroules

Description

@jakepetroules

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions