Skip to content

Commit

Permalink
Check that env var KAITAI_STRUCT_VERSION matches build.sbt VERSION
Browse files Browse the repository at this point in the history
See 5340ff3#commitcomment-99529992
- asserting that the versions match seems to be the easiest way to avoid
that problem.

Throwing `MessageOnlyException` to indicate the error is inspired by
https://github.com/sbt/sbt-dynver/tree/125101ba#sanity-checking-the-version.
  • Loading branch information
generalmimon committed Feb 12, 2023
1 parent 53d5cd3 commit 829a14f
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,21 @@ lazy val compiler = crossProject.in(file(".")).
enablePlugins(JavaAppPackaging).
settings(
organization := "io.kaitai",
version := sys.env.getOrElse("KAITAI_STRUCT_VERSION", VERSION),
version := {
sys.env.get("KAITAI_STRUCT_VERSION") match {
case Some(ver) =>
if (VERSION.endsWith("-SNAPSHOT")) {
if (!ver.startsWith(VERSION))
throw new MessageOnlyException(s"Environment variable KAITAI_STRUCT_VERSION '$ver' doesn't start with build.sbt VERSION '$VERSION'")
} else {
if (ver != VERSION)
throw new MessageOnlyException(s"Environment variable KAITAI_STRUCT_VERSION '$ver' is not equal to build.sbt VERSION '$VERSION'")
}
ver
case None =>
VERSION
}
},
licenses := Seq(("GPL-3.0", url("https://opensource.org/licenses/GPL-3.0"))),
scalaVersion := "2.12.12",

Expand Down

0 comments on commit 829a14f

Please sign in to comment.