diff --git a/src/main/scala/sbtbuildinfo/BuildInfo.scala b/src/main/scala/sbtbuildinfo/BuildInfo.scala index 3417bb1..0005aef 100644 --- a/src/main/scala/sbtbuildinfo/BuildInfo.scala +++ b/src/main/scala/sbtbuildinfo/BuildInfo.scala @@ -37,8 +37,10 @@ object BuildInfo { // val typeExpr = TypeExpression.parse(info.manifest.toString())._1 val result = info match { - case PluginCompat.Setting(key) => extracted.getOpt(project / key).map((v) => task(ident(key) -> v)) - case PluginCompat.Task(key) => Some(task(ident(key) -> extracted.runTask(project / key, state)._2)) + case PluginCompat.Setting(key) => + extracted.getOpt(Scoped.scopedSetting(scope(key, project), key.key)).map((v) => task(ident(key) -> v)) + case PluginCompat.Task(key) => + Some(task(ident(key) -> extracted.runTask(Scoped.scopedTask(scope(key, project), key.key), state)._2)) case PluginCompat.TaskValue(task) => Some(task.map(x => ident(task) -> x)) case PluginCompat.Constant(tuple) => Some(task(tuple)) case PluginCompat.Action(name, fun) => Some(task(name -> fun.apply)) diff --git a/src/sbt-test/sbt-buildinfo/gh211/build.sbt b/src/sbt-test/sbt-buildinfo/gh211/build.sbt new file mode 100644 index 0000000..46e54d3 --- /dev/null +++ b/src/sbt-test/sbt-buildinfo/gh211/build.sbt @@ -0,0 +1,22 @@ +lazy val check = taskKey[Unit]("checks this plugin") + +lazy val a1 = project.settings(scalaVersion := "2.13.15") + +lazy val a2 = project.settings(scalaVersion := "3.3.4") + +lazy val a3 = project + .enablePlugins(BuildInfoPlugin) + .settings( + Compile / buildInfoKeys := List[BuildInfoKey]( + BuildInfoKey.map((a1 / scalaVersion): SettingKey[String])("scalaVersion_a1" -> _._2), + BuildInfoKey.map((a2 / scalaVersion): SettingKey[String])("scalaVersion_a2" -> _._2), + ), + check := { + val sv = scalaVersion.value + val _ = (Compile / compile).value + val f = (Compile / sourceManaged).value / "sbt-buildinfo" / ("BuildInfo.scala") + val lines = scala.io.Source.fromFile(f).getLines.toList + + assert(lines.contains(" val scalaVersion_a2: String = \"3.3.4\""), lines.toString) + }, + ) diff --git a/src/sbt-test/sbt-buildinfo/gh211/project/plugins.sbt b/src/sbt-test/sbt-buildinfo/gh211/project/plugins.sbt new file mode 100644 index 0000000..e392da8 --- /dev/null +++ b/src/sbt-test/sbt-buildinfo/gh211/project/plugins.sbt @@ -0,0 +1,7 @@ +{ + val pluginVersion = System.getProperty("plugin.version") + if(pluginVersion == null) + throw new RuntimeException("""|The system property 'plugin.version' is not defined. + |Specify this property using the scriptedLaunchOpts -D.""".stripMargin) + else addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % pluginVersion) +} diff --git a/src/sbt-test/sbt-buildinfo/gh211/test b/src/sbt-test/sbt-buildinfo/gh211/test new file mode 100644 index 0000000..5e9e90e --- /dev/null +++ b/src/sbt-test/sbt-buildinfo/gh211/test @@ -0,0 +1 @@ +> a3/check