sbt-aspectj icon indicating copy to clipboard operation
sbt-aspectj copied to clipboard

Task name conflict prevents use with kamon's aspectj weaver

Open gregsilin opened this issue 7 years ago • 1 comments

Upgrading our tooling to Scala 2.12, SBT 0.13.16 and newest (0.11.0) version of this plugin as well as the newest (1.0.1) version of the kamon-io aspectj runner plugin.

Get this on SBT start:

java.lang.RuntimeException: Some keys were defined with the same name but different types: 'aspectjWeaver' (sbt.Task[scala.Option[java.io.File]], sbt.Task[java.io.File])
	at scala.sys.package$.error(package.scala:27)
	at sbt.Index$.stringToKeyMap0(EvaluateConfigurations.scala:296)
	at sbt.Index$.stringToKeyMap(EvaluateConfigurations.scala:287)
	at sbt.Load$.structureIndex(Load.scala:209)
	at sbt.Load$$anonfun$9.apply(Load.scala:165)
	at sbt.Load$$anonfun$9.apply(Load.scala:165)
	at sbt.Load$.timed(Load.scala:1025)
	at sbt.Load$.apply(Load.scala:164)
	at sbt.Load$.defaultLoad(Load.scala:39)

I tracked it down to the fact that this plugins both define aspectjWeaver keys with different types:

trait AspectjKeys {
    val aspectjWeaver = taskKey[Option[File]]("Location of AspectJ load-time weaver.")
}

kamon plugin's definition

 object Keys {
    val aspectjWeaver = TaskKey[File]("aspectj-weaver")
  }

I'm going to continue looking for a workaround but i suspect that this could be resolved easily by prefixing the keys to make them unique. It will be a breaking change for some, but at least it will play nicely with other plugins.

gregsilin avatar Sep 20 '17 18:09 gregsilin

Do you really need to use the two plugins together? I have some projects running Kamon metrics and weaved with this plugin instead of theirs... yeah, I know, it's not automatic but...

It sounds to me that the plugins in their current state are not compatible. sbt-aspectj also seems to be much general than Kamon's sbt-aspectj-runner which is targeted to just run the weaver automatically when doing a sbt run...

Probably there is here an opportunity for collaboration between the two plugins, I don't think that adding additional prefixes to the keys in either side is a good approach for this specific problem, we may end up with really awkwardly named settings.

EDIT: PS: For a solution right now, if you do not need SBT 1.0 support you could try using earlier versions of this plugin. The task name conflict should only be present in 0.11.+ since before our keys were not prefixed with aspectj (aspectjWeaver was weaver)

alonsodomin avatar Sep 21 '17 07:09 alonsodomin