[GRADLE-3443] Default Scala Compiler Doesn’t Work in Gradle 2.12 & Scala 2.11 Created: 25/Apr/16 Updated: 28/Jul/16 Resolved: 28/Jul/16 |
|
Status: | Resolved |
Project: | Gradle |
Affects Version/s: | None |
Fix Version/s: | None |
Type: | Bug | ||
Reporter: | Sterling Greene | Assignee: | Gary Hale |
Resolution: | Not A Bug | Votes: | 1 |
Description |
https://discuss.gradle.org/t/default-scala-compiler-doesnt-work-in-gradle-2-12-scala-2-11/15328 While trying to upgrade scala from 2.10 to 2.11 we are seeing compiler problems. Specifically we get: Strangely in our multi project build it would work for the first project it saw with scala, but fail for the others. If i deleted the project gradle cache, i could get one more module to compile correctly. Once i deleted my main (user) gradle cache all scala projects started failing in this same way. |
Comments |
Comment by Francesco Salbaroli [ 26/Apr/16 ] |
Confirm the same problem for me |
Comment by Gary Hale [ 10/May/16 ] |
Workaround: dependencies { zinc 'com.typesafe.zinc:zinc:0.3.9' zinc 'org.scala-lang:scala-library:2.10.5' } See the linked forum topic above for an explanation of the root issue. |
Comment by Francesco Salbaroli [ 11/May/16 ] |
The workaround does not fix it for me using scala 2.11.8 error is the same: |
Comment by Gary Hale [ 11/May/16 ] |
Can you share an example project? If not, can you provide the output from the dependencies task with --configuration zinc on the failing project? |
Comment by Brian Harrington [ 01/Jun/16 ] |
The suggested workaround works for me on 2.11.8 if I also add in scala-reflect. dependencies { zinc 'com.typesafe.zinc:zinc:0.3.9' zinc 'org.scala-lang:scala-library:2.10.5' zinc 'org.scala-lang:scala-reflect:2.10.5' } |
Comment by Gary Hale [ 28/Jul/16 ] |
So, looking into this issue deeper, we've realized that this is not a defect but a byproduct of other configuration. In the OP, the project also uses the nebula dependency-recommender plugin. The scala-library version is being set with that plugin and then recommended for all configurations, including the zinc configuration. When Gradle adds the zinc compiler library to the zinc configuration, it has a transitive dependency on scala-library, but it loses out to the recommended version during conflict resolution. But when we declare it as a first level dependency of zinc, the declared version wins out over the recommended version which is why the workaround is effective for that project. There are other ways that this problem can get introduced as well. For instance, declaring a configurations.all rule: configurations.all { resolutionStrategy.force 'org.scala-lang:scala-library:2.11.7' }This would force the version across all configurations (including zinc) and even the workaround above would not fix the issue. In this case, the rule should either not be applied to the zinc configuration (by using a conditional that checks the name of the configuration or something similar) or by applying the version in some other way that does not include the zinc configuration. If this rule is being applied somewhere outside of the users control (say in a plugin), then the only thing that can be done is to override the forced version on the zinc configuration: configurations.zinc { resolutionStrategy.force 'org.scala-lang:scala-library:2.10.5' }In any event, the behavior appears to be correct, it's just not obvious that these rules are interfering. |