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

Reproduce 211 #212

Merged
merged 1 commit into from
Nov 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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