Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

including breaks my build due to ambiguous compile key #37

Closed
forestofrain opened this issue Jan 8, 2016 · 5 comments
Closed

including breaks my build due to ambiguous compile key #37

forestofrain opened this issue Jan 8, 2016 · 5 comments

Comments

@forestofrain
Copy link

I can't include this plugin in my build because it breaks it. Here is the error I get when adding addSbtPlugin("com.github.gseitz" % "sbt-protobuf" % "0.4.0") to plugins.sbt:

error: reference to compile is ambiguous;
it is imported twice in the same scope by
import _root_.sbtprotobuf.ProtobufPlugin._
and import Keys._
  settings(mainClass in compile := Some("whatever")

I found a similar issue from twitter scrooge. If i follow @matthandlersux workaround import Keys.{compile => sbtCompile} and change all my mainClass in compile to mainClass in sbtCompile, then adding the plugin works.

https://github.com/trueaccord/ScalaPB depends upon this plugin, and it also breaks my build.

@monzonj
Copy link
Contributor

monzonj commented Jan 11, 2016

This is not an autoplugin.

You should import:

import sbtprotobuf.{ProtobufPlugin=>PB}

instead of

import _root_.sbtprotobuf.ProtobufPlugin._

and explicitly add the settings:

settings = Defaults.defaultSettings ++ PB.protobufSettings

@forestofrain
Copy link
Author

Simply adding the plugin to plugins.sbt breaks my multi project build.

The error I pasted is output from SBT. And this happened as soon as I simply added the plugin, never including any settings in my build file. I never wrote this line of code in my build file:

import _root_.sbtprotobuf.ProtobufPlugin._

Anyhow, I have moved away from protobuf. Wanted to capture this for any others that might see the same issue. If you follow the workaround of aliasing compile import Keys.{compile => sbtCompile} in your build, then everything works as expected. If you don't use compile in your build file, then you won't see the issue. The issue that was linked from scrooge shows a probable fix.

@matthandlersux
Copy link

for convenience, here's a link to how this was fixed for scrooge: https://github.com/twitter/scrooge/pull/210/files#diff-3d1ecf501419eb7452297ced4c03b47eR13

@jroper
Copy link
Member

jroper commented Apr 8, 2016

I'm seeing this too, the import is added automatically by sbt when you use *.sbt files, but compile is private so it shouldn't be imported right? Well, no, there's a bug (or feature) in the Scala compiler that allows it to cause ambiguous import errors:

https://issues.scala-lang.org/browse/SI-2133

Even though ProtobufPlugin.compile is private, it's being imported. Since this is never going to be fixed in Scala 2.10, it should be fixed here, there are three ways to fix it, one is to rename compile, another is to move it into a different object, and finally it could be converted to an auto plugin where automatic imports to sbt files are explicitly controlled.

@xuwei-k
Copy link
Member

xuwei-k commented Apr 15, 2016

Thanks all. I just fixed and released 0.5.2

xuwei-k added a commit to xuwei-k/sbt-dependency-graph-sugar that referenced this issue Jul 6, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants