Skip to content

Commit 696d649

Browse files
xuwei-keed3si9n
authored andcommitted
add sbt 2.x build setting
1 parent 3052c74 commit 696d649

File tree

10 files changed

+51
-8
lines changed

10 files changed

+51
-8
lines changed

.github/workflows/ci.yml

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,41 @@ jobs:
88
test:
99
strategy:
1010
fail-fast: false
11+
matrix:
12+
include:
13+
- java: 8
14+
distribution: zulu
15+
jobtype: 1
16+
- java: 8
17+
distribution: zulu
18+
jobtype: 2
19+
- java: 8
20+
distribution: zulu
21+
jobtype: 3
1122
runs-on: ubuntu-latest
1223
steps:
1324
- uses: actions/checkout@v4
1425
with:
1526
fetch-depth: 0
1627
- uses: actions/setup-java@v4
1728
with:
18-
distribution: temurin
19-
java-version: 8
29+
distribution: "${{ matrix.distribution }}"
30+
java-version: "${{ matrix.java }}"
2031
cache: sbt
2132
- uses: sbt/setup-sbt@v1
22-
- name: test
23-
run: sbt +test scripted mimaReportBinaryIssues
33+
- name: Build and test (sbt 1.x)
34+
if: ${{ matrix.jobtype == 1 }}
35+
shell: bash
36+
run: |
37+
sbt --client +test
38+
sbt --client "++2.12.x; scripted"
39+
- name: Build and test (sbt 2.x)
40+
if: ${{ matrix.jobtype == 2 }}
41+
shell: bash
42+
run: |
43+
sbt --client "++3.x; scripted"
44+
- name: Mima
45+
if: ${{ matrix.jobtype == 3 }}
46+
shell: bash
47+
run: |
48+
sbt --client mimaReportBinaryIssues

.github/workflows/publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
fetch-depth: 0
1919
- uses: actions/setup-java@v4
2020
with:
21-
distribution: temurin
21+
distribution: zulu
2222
java-version: 8
2323
cache: sbt
2424
- uses: sbt/setup-sbt@v1

build.sbt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ val dynver = project.settings(
4646
libraryDependencies += "org.eclipse.jgit" % "org.eclipse.jgit" % "5.13.3.202401111512-r" % Test,
4747
libraryDependencies += "org.scalacheck" %% "scalacheck" % "1.18.1" % Test,
4848
publishSettings,
49-
crossScalaVersions ++= Seq(scala2_13, scala3),
49+
crossScalaVersions := Seq(scala2_12, scala2_13, scala3),
50+
scripted := (()),
5051
scalacOptions := {
5152
scalaBinaryVersion.value match {
5253
case "3" | "2.13" => scalacOptions.value.filterNot(scalacOptions212.contains(_))
@@ -61,9 +62,11 @@ val sbtdynver = project.dependsOn(dynverLib).enablePlugins(SbtPlugin).settings(
6162
scriptedDependencies := Seq(dynver / publishLocal, publishLocal).dependOn.value,
6263
scriptedLaunchOpts += s"-Dplugin.version=${version.value}",
6364
scriptedLaunchOpts += s"-Dsbt.boot.directory=${file(sys.props("user.home")) / ".sbt" / "boot"}",
65+
crossScalaVersions := Seq(scala2_12, scala3),
6466
(pluginCrossBuild / sbtVersion) := {
6567
scalaBinaryVersion.value match {
6668
case "2.12" => "1.3.0"
69+
case _ => "2.0.0-M2"
6770
}
6871
},
6972
publishSettings,
@@ -73,6 +76,7 @@ lazy val publishSettings = Def.settings(
7376
MimaSettings.mimaSettings,
7477
)
7578

79+
crossScalaVersions := Nil
7680
mimaPreviousArtifacts := Set.empty
7781
publish / skip := true
7882
Global / cancelable := true
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# In sbt 2.x, this fails to load
2+
# [error] java.lang.RuntimeException: Failed to derive version from git tags. Maybe run `git fetch --unshallow`? Version: HEAD+20241012-0028
3+
# [error] at sbtdynver.GitDescribeOutput$OptGitDescribeOutputOps$.assertTagVersion$extension(DynVer.scala:130)
4+
# [error] at sbtdynver.DynVerPlugin$.assertTagVersion$lzyINIT1$$anonfun$1(DynVerPlugin.scala:65)
5+
6+
-> check

sbtdynver/src/sbt-test/dynver/assert-tag-version/test

Lines changed: 0 additions & 1 deletion
This file was deleted.

sbtdynver/src/sbt-test/dynver/custom-version-string-0/build.sbt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ TaskKey[Unit]("checkOnTagAndCommitDirty") := check(version.value, s"1.0.0-1-${he
2222

2323
TaskKey[Unit]("gitInitSetup") := {
2424
implicit def log2log(log: Logger): scala.sys.process.ProcessLogger = sbtLoggerToScalaSysProcessLogger(log)
25+
IO.writeLines(baseDirectory.value / ".gitignore", List("target", ".bsp"))
26+
"git config --global init.defaultBranch main".!!(streams.value.log)
2527
"git init".!!(streams.value.log)
2628
"git config user.email [email protected]".!!(streams.value.log)
2729
"git config user.name dynver".!!(streams.value.log)

sbtdynver/src/sbt-test/dynver/custom-version-string/build.sbt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ TaskKey[Unit]("checkOnTagAndCommitDirty") := check(version.value, s"1.0.0-1-${he
3535

3636
TaskKey[Unit]("gitInitSetup") := {
3737
implicit def log2log(log: Logger): scala.sys.process.ProcessLogger = sbtLoggerToScalaSysProcessLogger(log)
38+
IO.writeLines(baseDirectory.value / ".gitignore", List("target", ".bsp"))
39+
"git config --global init.defaultBranch main".!!(streams.value.log)
3840
"git init".!!(streams.value.log)
3941
"git config user.email [email protected]".!!(streams.value.log)
4042
"git config user.name dynver".!!(streams.value.log)

sbtdynver/src/sbt-test/dynver/distance-separator/build.sbt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ TaskKey[Unit]("checkOnTagAndCommitDirty") := check(version.value, s"1.0.0-1-${he
2121

2222
TaskKey[Unit]("gitInitSetup") := {
2323
implicit def log2log(log: Logger): scala.sys.process.ProcessLogger = sbtLoggerToScalaSysProcessLogger(log)
24+
IO.writeLines(baseDirectory.value / ".gitignore", List("target", ".bsp"))
25+
"git config --global init.defaultBranch main".!!(streams.value.log)
2426
"git init".!!(streams.value.log)
2527
"git config user.email [email protected]".!!(streams.value.log)
2628
"git config user.name dynver".!!(streams.value.log)

sbtdynver/src/sbt-test/dynver/multi-build/build.sbt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
dependsOn(RootProject(file("bar")))
1+
lazy val root = (project in file("."))
2+
.dependsOn(RootProject(file("bar")))
23

34
def check(a: String, e: String) = assert(a == e, s"Version mismatch: Expected $e, Incoming $a")
45

sbtdynver/src/sbt-test/dynver/versions/build.sbt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ TaskKey[Unit]("checkOnTagAndCommitDirty") := check(version.value, s"1.0.0+1-${he
1919

2020
TaskKey[Unit]("gitInitSetup") := {
2121
implicit def log2log(log: Logger): scala.sys.process.ProcessLogger = sbtLoggerToScalaSysProcessLogger(log)
22+
IO.writeLines(baseDirectory.value / ".gitignore", List("target", ".bsp"))
23+
"git config --global init.defaultBranch main".!!(streams.value.log)
2224
"git init".!!(streams.value.log)
2325
"git config user.email [email protected]".!!(streams.value.log)
2426
"git config user.name dynver".!!(streams.value.log)

0 commit comments

Comments
 (0)