Skip to content

Commit

Permalink
Skip setting release flag when user pass directly -release or -java-o…
Browse files Browse the repository at this point in the history
…utput-version (#2321)
  • Loading branch information
lwronski committed Jul 31, 2023
1 parent b0f3c53 commit 2d86cca
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
5 changes: 3 additions & 2 deletions modules/build/src/main/scala/scala/build/Build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -766,8 +766,9 @@ object Build {
else if (compilerJvmVersionOpt.exists(_.value == 8))
None
else if (
options.scalaOptions.scalacOptions.values.exists(
_.headOption.exists(_.value.value == "-release")
options.scalaOptions.scalacOptions.values.exists(opt =>
opt.headOption.exists(_.value.value.startsWith("-release")) ||
opt.headOption.exists(_.value.value.startsWith("-java-output-version"))
)
)
None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -368,4 +368,27 @@ class BuildOptionsTests extends munit.FunSuite {
expect(semanticDbVersion == "4.8.4")
}

test("skip setting release option when -release or -java-output-version is set by user") {
val javaOutputVersionOpt = "-java-output-version:16"
val inputs = TestInputs(
os.rel / "Hello.scala" ->
s"""//> using option $javaOutputVersionOpt
|""".stripMargin
)

inputs.withBuild(BuildOptions(), buildThreads, bloopConfigOpt, buildTests = false) {
(_, _, maybeBuild) =>
expect(maybeBuild.exists(_.success))
val build = maybeBuild
.toOption
.flatMap(_.successfulOpt)
.getOrElse(sys.error("cannot happen"))

val scalacOpts = build.project.scalaCompiler.toSeq.flatMap(_.scalacOptions)

expect(scalacOpts.contains(javaOutputVersionOpt))
expect(!scalacOpts.exists(_.startsWith("-release")))
}
}

}

0 comments on commit 2d86cca

Please sign in to comment.