SBT / Good way to override a plugin's setting

2019-09-06 02:20发布

问题:

I want to change the aspectj version used by this plugin (line 59).
Indeed, I want to use aspectj version 1.8.0 and not 1.7.3.
I sent a message to the creator but I'm stuck until he could answer since I've got a Spring-Data component that depends on 1.8.0.

The current plugin's setting is:

lazy val aspectjSettings: Seq[Setting[_]] = inConfig(Aspectj)(defaultAspectjSettings) ++ aspectjDependencySettings

  def defaultAspectjSettings = Seq(
    aspectjVersion := "1.7.3",
  .......

Mu current SBT for my own project starts as following:

val webApp = play.Project(appName, appVersion, appDependencies)
    .settings(aspectjSettings: _*)

What is a good way to "override" aspectjVersion := "1.7.3" by aspectjVersion := "1.8.0"?

I tried this, but doesn't seem to work.

.settings(Seq(aspectjVersion := "1.8.0") ++ aspectjSettings.filterNot(_.key.key.label == "aspectjVersion"): _*)

I still have this error:

warning bad version number found in /Developpements/play-2.2.3/repository/cache/org.aspectj/aspectjrt/jars/aspectjrt-1.8.0.jar expected 1.7.3 found 1.8.0

回答1:

If you look at line 56 the settings are defined with

 inConfig(Aspectj)(defaultAspectjSettings) ...

which means that each key will be defined for the AspectJ config, so I think you need to override them in that config rather than without any config:

.settings(aspectjVersion in Aspectj := "1.8.0")