Skip to content

Commit 4d6d8d7

Browse files
authored
add sbt 2 cross build (#56)
1 parent ddd3542 commit 4d6d8d7

6 files changed

Lines changed: 74 additions & 5 deletions

File tree

.github/workflows/build-test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ jobs:
3131
}
3232
cmd: >-
3333
sbt "
34+
+ Test/compile;
3435
set scriptedSbt := \"$MATRIX_SBT\";
3536
set scriptedLaunchOpts += \"-Dscala.version=$MATRIX_SCALA\";
3637
show scriptedSbt;

.scalafmt.conf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,5 @@ rewrite {
5757
}
5858
trailingCommas.style = keep # https://scalameta.org/scalafmt/docs/configuration.html#trailing-commas
5959
}
60+
61+
project.layout = StandardConvention

build.sbt

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,32 @@ Global / onLoad := (Global / onLoad).value.andThen { s =>
5050
s
5151
}
5252

53+
crossScalaVersions += "3.7.3"
54+
55+
scalacOptions --= {
56+
scalaBinaryVersion.value match {
57+
case "3" =>
58+
Seq("-Xfatal-warnings")
59+
case _ =>
60+
Nil
61+
}
62+
}
63+
64+
pluginCrossBuild / sbtVersion := {
65+
scalaBinaryVersion.value match {
66+
case "2.12" =>
67+
sbtVersion.value
68+
case _ =>
69+
"2.0.0-RC5"
70+
}
71+
}
72+
5373
addCommandAlias(
5474
"validateCode",
5575
List(
5676
"scalafmtSbtCheck",
57-
"scalafmtCheckAll",
58-
"javafmtCheckAll",
59-
"headerCheck"
77+
"+ scalafmtCheckAll",
78+
"+ javafmtCheckAll",
79+
"+ headerCheckAll"
6080
).mkString(";")
6181
)
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* Copyright (C) from 2023 The sbt contributors <https://github.com/sbt>
3+
*/
4+
5+
package com.github.sbt.maven
6+
7+
import java.io.File
8+
9+
import sbt.Classpaths
10+
import sbt.Configuration
11+
import sbt.Keys.Classpath
12+
import sbt.UpdateReport
13+
14+
private[maven] object SbtMavenPluginCompat {
15+
def managedJars(
16+
config: Configuration,
17+
jarTypes: Set[String],
18+
up: UpdateReport
19+
): Seq[File] =
20+
Classpaths.managedJars(config, jarTypes, up).map(_.data)
21+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* Copyright (C) from 2023 The sbt contributors <https://github.com/sbt>
3+
*/
4+
5+
package com.github.sbt.maven
6+
7+
import java.io.File
8+
9+
import sbt.Classpaths
10+
import sbt.Configuration
11+
import sbt.Keys.fileConverter
12+
import sbt.Keys.Classpath
13+
import sbt.UpdateReport
14+
15+
private[maven] object SbtMavenPluginCompat {
16+
inline def managedJars(
17+
config: Configuration,
18+
jarTypes: Set[String],
19+
up: UpdateReport
20+
): Seq[File] = {
21+
val converter = fileConverter.value
22+
Classpaths.managedJars(config, jarTypes, up, converter).map(x => converter.toPath(x.data).toFile)
23+
}
24+
}

src/main/scala/com/github/sbt/maven/SbtMavenPlugin.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ object SbtMavenPlugin extends AutoPlugin {
4040
val mavenVersion = settingKey[String]("Maven version")
4141
val mavenPluginToolsVersion = settingKey[String]("Maven Plugin Tools version")
4242

43-
val MavenConf = Configurations.config("scripted-maven").hide
43+
val MavenConf = Configurations.config("scripted-maven").hide
44+
@transient
4445
val mavenClasspath = taskKey[PathFinder]("")
4546
val mavenLaunchOpts =
4647
settingKey[Seq[String]]("options to pass to jvm launching Maven tasks")
@@ -66,7 +67,7 @@ object SbtMavenPlugin extends AutoPlugin {
6667
private def scriptedMavenSettings: Seq[Setting[?]] = Seq(
6768
ivyConfigurations += MavenConf,
6869
mavenClasspath := Def.task {
69-
PathFinder(Classpaths.managedJars(MavenConf, classpathTypes.value, Keys.update.value).map(_.data))
70+
PathFinder(SbtMavenPluginCompat.managedJars(MavenConf, classpathTypes.value, Keys.update.value))
7071
}.value,
7172
scripted / sourceDirectory := sourceDirectory.value / "maven-test",
7273
scripted := scriptedTask.evaluated,

0 commit comments

Comments
 (0)