Description
As suggested on Reddit, the compilation performance could be improved by compiling against API JARs instead of full implementation JARs.
This can be achieved by taking the impl JARs and performing API extraction on them. Every non-anonymous class should be in it (even private ones) and every non-private members. Module-info and package-infos as well.
The private and package-private classes should be present, as there may be declarations that expose them as:
public class Main {
private static class Inner {
}
public static <T extends Inner> T f() {
return null;
}
}
In the second iteration of the issue, we may perform deep analysis of the accessability of non-public elements, however, it may be unfeasible, as the analysis may incure greater performance cost than the improvement.
Solution
This shouldn't be performed by the compiler task itself. This is the responsibility of the code that sets up the input classpath. Therefore a solution could be to introduce a new build task that performs the API extraction. Something along the lines of:
saker.java.compile(
ClassPath: task.that.extracts.api(lib/mylib.jar)
)
Another thing that could be examined is if repositories are able to directly provide compilation input JARs. If a JAR is uploaded to some common repository, it could perform the API extraction themselves, and provide it alongside of the implementation JAR. Therefore, if the client wants to compile for the given JAR, it could download the API instead of the implementation. However, if they want to use it, they can download the implementation as usual.
This issue may be moved from this repository.