Skip to content

Commit

Permalink
Merge pull request #212 from sbt/wip/repro211
Browse files Browse the repository at this point in the history
Reproduce 211
  • Loading branch information
eed3si9n authored Nov 9, 2024
2 parents c16dda8 + a9b2b44 commit 07337b5
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/main/scala/sbtbuildinfo/BuildInfo.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
22 changes: 22 additions & 0 deletions src/sbt-test/sbt-buildinfo/gh211/build.sbt
Original file line number Diff line number Diff line change
@@ -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)
},
)
7 changes: 7 additions & 0 deletions src/sbt-test/sbt-buildinfo/gh211/project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -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)
}
1 change: 1 addition & 0 deletions src/sbt-test/sbt-buildinfo/gh211/test
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
> a3/check

0 comments on commit 07337b5

Please sign in to comment.