Skip to content

Commit

Permalink
Merge pull request #314 from eed3si9n/wip/cross
Browse files Browse the repository at this point in the history
sbt 2.x build setting, take 3
  • Loading branch information
eed3si9n authored Oct 12, 2024
2 parents 3052c74 + 696d649 commit fda1e02
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 8 deletions.
33 changes: 29 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,41 @@ jobs:
test:
strategy:
fail-fast: false
matrix:
include:
- java: 8
distribution: zulu
jobtype: 1
- java: 8
distribution: zulu
jobtype: 2
- java: 8
distribution: zulu
jobtype: 3
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 8
distribution: "${{ matrix.distribution }}"
java-version: "${{ matrix.java }}"
cache: sbt
- uses: sbt/setup-sbt@v1
- name: test
run: sbt +test scripted mimaReportBinaryIssues
- name: Build and test (sbt 1.x)
if: ${{ matrix.jobtype == 1 }}
shell: bash
run: |
sbt --client +test
sbt --client "++2.12.x; scripted"
- name: Build and test (sbt 2.x)
if: ${{ matrix.jobtype == 2 }}
shell: bash
run: |
sbt --client "++3.x; scripted"
- name: Mima
if: ${{ matrix.jobtype == 3 }}
shell: bash
run: |
sbt --client mimaReportBinaryIssues
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
fetch-depth: 0
- uses: actions/setup-java@v4
with:
distribution: temurin
distribution: zulu
java-version: 8
cache: sbt
- uses: sbt/setup-sbt@v1
Expand Down
6 changes: 5 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ val dynver = project.settings(
libraryDependencies += "org.eclipse.jgit" % "org.eclipse.jgit" % "5.13.3.202401111512-r" % Test,
libraryDependencies += "org.scalacheck" %% "scalacheck" % "1.18.1" % Test,
publishSettings,
crossScalaVersions ++= Seq(scala2_13, scala3),
crossScalaVersions := Seq(scala2_12, scala2_13, scala3),
scripted := (()),
scalacOptions := {
scalaBinaryVersion.value match {
case "3" | "2.13" => scalacOptions.value.filterNot(scalacOptions212.contains(_))
Expand All @@ -61,9 +62,11 @@ val sbtdynver = project.dependsOn(dynverLib).enablePlugins(SbtPlugin).settings(
scriptedDependencies := Seq(dynver / publishLocal, publishLocal).dependOn.value,
scriptedLaunchOpts += s"-Dplugin.version=${version.value}",
scriptedLaunchOpts += s"-Dsbt.boot.directory=${file(sys.props("user.home")) / ".sbt" / "boot"}",
crossScalaVersions := Seq(scala2_12, scala3),
(pluginCrossBuild / sbtVersion) := {
scalaBinaryVersion.value match {
case "2.12" => "1.3.0"
case _ => "2.0.0-M2"
}
},
publishSettings,
Expand All @@ -73,6 +76,7 @@ lazy val publishSettings = Def.settings(
MimaSettings.mimaSettings,
)

crossScalaVersions := Nil
mimaPreviousArtifacts := Set.empty
publish / skip := true
Global / cancelable := true
6 changes: 6 additions & 0 deletions sbtdynver/src/sbt-test/dynver/assert-tag-version/disabled
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# In sbt 2.x, this fails to load
# [error] java.lang.RuntimeException: Failed to derive version from git tags. Maybe run `git fetch --unshallow`? Version: HEAD+20241012-0028
# [error] at sbtdynver.GitDescribeOutput$OptGitDescribeOutputOps$.assertTagVersion$extension(DynVer.scala:130)
# [error] at sbtdynver.DynVerPlugin$.assertTagVersion$lzyINIT1$$anonfun$1(DynVerPlugin.scala:65)

-> check
1 change: 0 additions & 1 deletion sbtdynver/src/sbt-test/dynver/assert-tag-version/test

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ TaskKey[Unit]("checkOnTagAndCommitDirty") := check(version.value, s"1.0.0-1-${he

TaskKey[Unit]("gitInitSetup") := {
implicit def log2log(log: Logger): scala.sys.process.ProcessLogger = sbtLoggerToScalaSysProcessLogger(log)
IO.writeLines(baseDirectory.value / ".gitignore", List("target", ".bsp"))
"git config --global init.defaultBranch main".!!(streams.value.log)
"git init".!!(streams.value.log)
"git config user.email [email protected]".!!(streams.value.log)
"git config user.name dynver".!!(streams.value.log)
Expand Down
2 changes: 2 additions & 0 deletions sbtdynver/src/sbt-test/dynver/custom-version-string/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ TaskKey[Unit]("checkOnTagAndCommitDirty") := check(version.value, s"1.0.0-1-${he

TaskKey[Unit]("gitInitSetup") := {
implicit def log2log(log: Logger): scala.sys.process.ProcessLogger = sbtLoggerToScalaSysProcessLogger(log)
IO.writeLines(baseDirectory.value / ".gitignore", List("target", ".bsp"))
"git config --global init.defaultBranch main".!!(streams.value.log)
"git init".!!(streams.value.log)
"git config user.email [email protected]".!!(streams.value.log)
"git config user.name dynver".!!(streams.value.log)
Expand Down
2 changes: 2 additions & 0 deletions sbtdynver/src/sbt-test/dynver/distance-separator/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ TaskKey[Unit]("checkOnTagAndCommitDirty") := check(version.value, s"1.0.0-1-${he

TaskKey[Unit]("gitInitSetup") := {
implicit def log2log(log: Logger): scala.sys.process.ProcessLogger = sbtLoggerToScalaSysProcessLogger(log)
IO.writeLines(baseDirectory.value / ".gitignore", List("target", ".bsp"))
"git config --global init.defaultBranch main".!!(streams.value.log)
"git init".!!(streams.value.log)
"git config user.email [email protected]".!!(streams.value.log)
"git config user.name dynver".!!(streams.value.log)
Expand Down
3 changes: 2 additions & 1 deletion sbtdynver/src/sbt-test/dynver/multi-build/build.sbt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
dependsOn(RootProject(file("bar")))
lazy val root = (project in file("."))
.dependsOn(RootProject(file("bar")))

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

Expand Down
2 changes: 2 additions & 0 deletions sbtdynver/src/sbt-test/dynver/versions/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ TaskKey[Unit]("checkOnTagAndCommitDirty") := check(version.value, s"1.0.0+1-${he

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

0 comments on commit fda1e02

Please sign in to comment.