-
Notifications
You must be signed in to change notification settings - Fork 202
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't fail in builds of single sbt plugins
I knew about the possibility of failing in builds of single sbt plugins, but however didn't protect us about them because I hoped sbt would expose an entrypoint to know for real if a project is a meta build or not. As this hasn't been the case, I've implemented a simple heuristic to know whether a build is a meta-project or not: check if the CWD is the same as the root of the build.
- Loading branch information
Showing
5 changed files
with
36 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
integrations/sbt-bloop/src/sbt-test/sbt-bloop/sbt-plugin-build/build.sbt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
name := "sbt-plugin-foobar" | ||
sbtPlugin := true | ||
|
||
import java.nio.file.Files | ||
|
||
val checkMetaBuildInfo = taskKey[Unit]("Check sbt meta build info is not generated") | ||
checkMetaBuildInfo in ThisBuild := { | ||
def readBareFile(p: java.nio.file.Path): String = | ||
new String(Files.readAllBytes(p)).replaceAll("\\s", "") | ||
|
||
def check(f: File): Unit = { | ||
val metaContents = readBareFile(f.toPath) | ||
assert(metaContents.contains("\"autoImports\":[\""), "Missing auto imports.") | ||
assert(metaContents.contains("\"sbtVersion\":\""), "Missing sbt version.") | ||
} | ||
|
||
val bloopMetaDir = Keys.baseDirectory.value./("project")./(".bloop") | ||
val metaBuildConfig = bloopMetaDir./("sbt-plugin-build.json") | ||
check(metaBuildConfig) | ||
} |
2 changes: 2 additions & 0 deletions
2
integrations/sbt-bloop/src/sbt-test/sbt-bloop/sbt-plugin-build/project/plugins.sbt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
addSbtPlugin("ch.epfl.scala" % "sbt-bloop" % sys.props.apply("plugin.version")) | ||
|
2 changes: 2 additions & 0 deletions
2
integrations/sbt-bloop/src/sbt-test/sbt-bloop/sbt-plugin-build/project/project/plugins.sbt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
addSbtPlugin("ch.epfl.scala" % "sbt-bloop" % sys.props.apply("plugin.version")) | ||
|
1 change: 1 addition & 0 deletions
1
integrations/sbt-bloop/src/sbt-test/sbt-bloop/sbt-plugin-build/test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
> bloopInstall |