Skip to content

Commit

Permalink
Update scala-library to 2.13.16 & downgrade JLine to 3.25.0 (#64)
Browse files Browse the repository at this point in the history
  • Loading branch information
scala-steward authored Jan 21, 2025
1 parent 5db0506 commit bbef547
Showing 1 changed file with 52 additions and 16 deletions.
68 changes: 52 additions & 16 deletions build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,39 @@ import io.github.alexarchambault.millnativeimage.upload.Upload
import mill._
import mill.scalalib._

def scalafmtVersion = "3.8.3"
object Versions {
def scalafmtVersion = "3.8.3"

trait ScalafmtNativeImage extends ScalaModule with NativeImage {
def scalaVersion = "2.13.13"
def scalaVersion = "2.13.16"

def nativeImageClassPath = T{
def jline = "3.25.0"

def coursier = "2.1.0-M5-18-gfebf9838c"
}

trait ScalafmtNativeImageModule extends ScalaModule {
override def scalaVersion = Versions.scalaVersion

override def transitiveIvyDeps = T {
super.transitiveIvyDeps()
.map(_.exclude("org.jline" -> "jline-native"))
.map(_.exclude("org.jline" -> "jline-reader"))
.map(_.exclude("org.jline" -> "jline-terminal"))
.map(_.exclude("org.jline" -> "jline-terminal-jna"))
}

def jlineDeps = Agg(
ivy"org.jline:jline-native:${Versions.jline}",
ivy"org.jline:jline-reader:${Versions.jline}",
ivy"org.jline:jline-terminal:${Versions.jline}",
ivy"org.jline:jline-terminal-jna:${Versions.jline}"
)

override def ivyDeps = super.ivyDeps() ++ jlineDeps
}

trait ScalafmtNativeImage extends ScalafmtNativeImageModule with NativeImage {
def nativeImageClassPath = T {
val origCp = runClasspath()
val tmpDir = T.dest / "jars"
os.makeDir.all(tmpDir)
Expand All @@ -35,7 +62,7 @@ trait ScalafmtNativeImage extends ScalaModule with NativeImage {
zf = new ZipFile(path.toIO)
fos = new FileOutputStream(dest.toIO)
zos = new ZipOutputStream(fos)
val buf = Array.ofDim[Byte](64*1024)
val buf = Array.ofDim[Byte](64 * 1024)
for (ent <- zf.entries.asScala) {
val postProcess = ent.getName == "META-INF/native-image/org.scalafmt/scalafmt-cli/native-image.properties"

Expand All @@ -48,7 +75,7 @@ trait ScalafmtNativeImage extends ScalaModule with NativeImage {
zos.putNextEntry(ent0)
val baos = new ByteArrayOutputStream
var read = -1
while ({
while ( {
read = is.read(buf)
read >= 0
}) {
Expand All @@ -62,7 +89,7 @@ trait ScalafmtNativeImage extends ScalaModule with NativeImage {
else {
zos.putNextEntry(ent)
var read = -1
while ({
while ( {
read = is.read(buf)
read >= 0
}) {
Expand All @@ -88,20 +115,27 @@ trait ScalafmtNativeImage extends ScalaModule with NativeImage {
p
}
}
def nativeImageOptions = T{

def nativeImageOptions = T {
super.nativeImageOptions() ++ Seq(
"--no-fallback"
)
}

def nativeImagePersist = System.getenv("CI") != null

def nativeImageGraalVmJvmId = "graalvm-java17:22.2.0"

def nativeImageName = "scalafmt"
def ivyDeps = super.ivyDeps() ++ Seq(
ivy"org.scalameta::scalafmt-cli:$scalafmtVersion"

def ivyDeps = super.ivyDeps() ++ jlineDeps ++ Seq(
ivy"org.scalameta::scalafmt-cli:${Versions.scalafmtVersion}".excludeOrg("org.jline")
)

def nativeImageMainClass = "org.scalafmt.cli.Cli"

def nameSuffix = ""

def copyToArtifacts(directory: String = "artifacts/") = T.command {
val _ = Upload.copyLauncher(
nativeImage().path,
Expand All @@ -115,24 +149,25 @@ trait ScalafmtNativeImage extends ScalaModule with NativeImage {

object native extends ScalafmtNativeImage

def csDockerVersion = "2.1.0-M5-18-gfebf9838c"

object `native-static` extends ScalafmtNativeImage {
def nameSuffix = "-static"

def buildHelperImage = T {
os.proc("docker", "build", "-t", "scala-cli-base-musl:latest", ".")
.call(cwd = os.pwd / "musl-image", stdout = os.Inherit)
()
}
def nativeImageDockerParams = T{

def nativeImageDockerParams = T {
buildHelperImage()
Some(
NativeImage.linuxStaticParams(
"scala-cli-base-musl:latest",
s"https://github.com/coursier/coursier/releases/download/v$csDockerVersion/cs-x86_64-pc-linux.gz"
s"https://github.com/coursier/coursier/releases/download/v${Versions.coursier}/cs-x86_64-pc-linux.gz"
)
)
}

def writeNativeImageScript(scriptDest: String, imageDest: String = "") = T.command {
buildHelperImage()
super.writeNativeImageScript(scriptDest, imageDest)()
Expand All @@ -141,16 +176,17 @@ object `native-static` extends ScalafmtNativeImage {

object `native-mostly-static` extends ScalafmtNativeImage {
def nameSuffix = "-mostly-static"

def nativeImageDockerParams = Some(
NativeImage.linuxMostlyStaticParams(
"ubuntu:18.04", // TODO Pin that?
s"https://github.com/coursier/coursier/releases/download/v$csDockerVersion/cs-x86_64-pc-linux.gz"
s"https://github.com/coursier/coursier/releases/download/v${Versions.coursier}/cs-x86_64-pc-linux.gz"
)
)
}


def publishVersion = T{
def publishVersion = T {
val state = VcsVersion.vcsState()
if (state.commitsSinceLastTag > 0) {
val versionOrEmpty = state.lastTag
Expand Down

0 comments on commit bbef547

Please sign in to comment.