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

Escape imports from sbt files #3635

Merged
merged 1 commit into from Oct 13, 2017
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion main/src/main/scala/sbt/internal/LoadedSbtFile.scala
Expand Up @@ -61,7 +61,7 @@ private[sbt] final class DefinedSbtValues(val sbtFiles: Seq[compiler.EvalDefinit
file <- sbtFiles
m = file.enclosingModule
v <- file.valNames
} yield s"import ${m}.${v}"
} yield s"import ${m}.`${v}`"
}
def generated: Seq[File] =
sbtFiles flatMap (_.generated)
Expand Down
9 changes: 9 additions & 0 deletions notes/1.0.3/escape-imports-from-sbt-file.md
@@ -0,0 +1,9 @@
[@panaeon]: https://github.com/panaeon

[#3464]: https://github.com/sbt/sbt/issues/3464
[#3566]: https://github.com/sbt/sbt/pull/3566

### Bug fixes

- Escape imports from sbt files, so if user creates a backquoted definition then task evalution will not fail.

19 changes: 19 additions & 0 deletions sbt/src/sbt-test/project/literal-defs/build.sbt
@@ -0,0 +1,19 @@
lazy val `import` = (project in file("."))
.settings(
name := "Hello"
)

val `return` = inputKey[Unit]("Check that commands can be defined as back-ticked variables")


`return` := {
()
}


val `ї` = inputKey[Unit]("Check that we can defined unicode commands")

`ї` := {
()
}

12 changes: 12 additions & 0 deletions sbt/src/sbt-test/project/literal-defs/test
@@ -0,0 +1,12 @@
# This test verifies that top-level literal identifiers, like `return`, are loaded correctly

# Initial load should succeed

# Check that we can modify project properties
> 'set version := "1.0.0"'

# Check that we can run command defined in back-quotes
> return

# Check that we can define unicode commands
> ї