Created by: demon-xxi
D8 desugar requires to specify additional Java bytecode that is currently not compiled into DEX bytecode but require to compile other classes into DEX bytecode. For example, if your code uses default and static interface methods, which is a Java 8 language feature, you need to use this flag to specify the path to all of your project's Java bytecode, even if you don't intend to compile all of it into DEX bytecode. That's because d8 requires this information to understand your project's code and resolve calls to the interface methods. More info: https://developer.android.com/studio/command-line/d8#j8
This change adds classpath of all the dependencies when calling D8 step. It enables desugaring only for java and android libraries with java source >= 8. It also explicitly disabled desugaring on any java 7 sources. Which may give some performance wins.
Adding classpath to D8 desugar increases number of dependencies for dex steps on java 8 libraries. While this may degrade build speeds, it does so only for java 8 dependencies. This is necessary step to make those libraries work as well as adds no impact to all the java 7 sources.
Test Plan: All the unit tests working without additional changes. May add few tests later to ensure only java 8 deps are added to dex phase.