Gradle + Scala Plugin + Zinc 1.3.5 leaks Protobuf 3.7 to the compiler classpath

628 views Asked by At

While debugging compilation errors of the generated Protobuf code after upgrading a Scala project to Gradle 6 & Zinc 1.3.5 I found that the compiler classpath contains two versions of the protobuf jar - the one I need (3.9.x) and 3.7. The latter is a dependency of the Zinc.

What is the correct way to run Zinc Scala build in Gradle without leaking its own dependencies to the classpath?

1

There are 1 answers

0
George Hawkins On BEST ANSWER

This was resolved with sbt/zinc PR 799 that was merged and included in the 1.4.0 release of Zinc.

With this MR they started shading the protobuf dependency (see this commit).

Unfortunately, it's not currently possible to use this version of Zinc with Gradle as Gradle issue #15491 was never resolved (note the issue title mentions Zinc 1.4.3 but applies for all versions of Zinc after the 1.3.x series).

It doesn't look like there's any plans to address #15491 but it looks like the issue will get solved as a side-effect of PR 18001 which is actively being developed with the intention of adding Scala 3 support to Gradle (and also involves cleaning up various long standing issues classpath related issues).