Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cross build to sbt 2.0.0-M3 #1647

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ project.excludePaths = [
# WixHelper.scala:105: error: Unable to format file due to bug in scalafmt
"glob:**/src/main/scala/com/typesafe/sbt/packager/windows/WixHelper.scala"
]
project.layout = StandardConvention
7 changes: 4 additions & 3 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@ version: '{build}'
os: Windows Server 2012
install:
- cmd: choco install zulu8 -ia "INSTALLDIR=""C:\zulu"""
- cmd: SET JAVA_HOME="C:\zulu"
- cmd: SET JAVA_HOME=C:\zulu
- cmd: choco install sbt -ia "INSTALLDIR=""C:\sbt"""
- cmd: SET PATH=C:\sbt\bin;%JAVA_HOME%\bin;%PATH%
- cmd: java -version
- cmd: SET SBT_OPTS=-Xms4g -Xmx4g
- cmd: mkdir C:\temp
build_script:
- sbt clean compile
- sbt -Djava.io.tmpdir=C:\temp clean ++2.12.x compile
test_script:
- sbt validateWindows
- sbt -Djava.io.tmpdir=C:\temp ++2.12.x validateWindows
cache:
- C:\Users\appveyor\.sbt
- C:\Users\appveyor\.m2
Expand Down
47 changes: 34 additions & 13 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,22 @@ organization := "com.github.sbt"
homepage := Some(url("https://github.com/sbt/sbt-native-packager"))

Global / onChangedBuildSource := ReloadOnSourceChanges
Global / scalaVersion := "2.12.20"

// crossBuildingSettings
lazy val scala212 = "2.12.20"
lazy val scala3 = "3.6.2"
Global / scalaVersion := scala3
crossScalaVersions := Seq(scala3, scala212)
(pluginCrossBuild / sbtVersion) := {
scalaBinaryVersion.value match {
case "2.12" => "1.1.6"
case _ => "2.0.0-M2"
case "2.12" => "1.5.8"
case _ => "2.0.0-M3"
}
}
scriptedSbt := {
scalaBinaryVersion.value match {
case "2.12" => "1.10.5"
case _ => "2.0.0-M2"
case "2.12" => "1.10.7"
case _ => "2.0.0-M3"
}
}

Expand Down Expand Up @@ -48,8 +51,7 @@ libraryDependencies ++= {
// scala version depended libraries
libraryDependencies ++= {
scalaBinaryVersion.value match {
case "2.10" => Nil
case _ =>
case "2.12" =>
Seq(
// Do NOT upgrade these dependencies to 2.x or newer! sbt-native-packager is a sbt-plugin
// and gets published with Scala 2.12, therefore we need to stay at the same major version
Expand All @@ -58,6 +60,8 @@ libraryDependencies ++= {
"org.scala-lang.modules" %% "scala-parser-combinators" % "1.1.2", // Do not upgrade beyond 1.x
"org.scala-lang.modules" %% "scala-xml" % "2.2.0"
)
case _ =>
Nil
}
}

Expand All @@ -79,11 +83,11 @@ mimaPreviousArtifacts := {
val m = "com.typesafe.sbt" %% moduleName.value % "1.3.15"
val sbtBinV = (pluginCrossBuild / sbtBinaryVersion).value
val scalaBinV = (update / scalaBinaryVersion).value
if (scalaBinV == "2.10") {
println(s"Skip MiMa check for SBT binary version ${sbtBinV} as scala ${scalaBinV} is not supported")
Set.empty
} else
Set(Defaults.sbtPluginExtra(m cross CrossVersion.disabled, sbtBinV, scalaBinV))
scalaBinV match {
case "2.12" =>
Set(Defaults.sbtPluginExtra(m cross CrossVersion.disabled, sbtBinV, scalaBinV))
case _ => Set.empty
}
}

// Release configuration
Expand All @@ -108,7 +112,8 @@ developers := List(
addCommandAlias("scalafmtFormatAll", "; ^scalafmtAll ; scalafmtSbt")
// ci commands
addCommandAlias("validateFormatting", "; scalafmtCheckAll ; scalafmtSbtCheck")
addCommandAlias("validate", "; clean ; update ; validateFormatting ; test ; mimaReportBinaryIssues")
// Ignore mimaReportBinaryIssues
addCommandAlias("validate", "; clean ; update ; validateFormatting ; test")

// List all scripted test separately to schedule them in different travis-ci jobs.
// Travis-CI has hard timeouts for jobs, so we run them in smaller jobs as the scripted
Expand Down Expand Up @@ -136,3 +141,19 @@ addCommandAlias("validateWindows", "; testOnly * -- -n windows ; scripted univer
addCommandAlias("validateJlink", "scripted jlink/*")

addCommandAlias("ci-release", "release with-defaults")

// So that publishLocal doesn't continuously create new versions
def versionFmt(out: sbtdynver.GitDescribeOutput): String = {
val snapshotSuffix =
if (out.isSnapshot()) "-SNAPSHOT"
else ""
out.ref.dropPrefix + snapshotSuffix
}

def fallbackVersion(d: java.util.Date): String = s"HEAD-${sbtdynver.DynVer timestamp d}"

ThisBuild / version := dynverGitDescribeOutput.value.mkVersion(versionFmt, fallbackVersion(dynverCurrentDate.value))
ThisBuild / dynver := {
val d = new java.util.Date
sbtdynver.DynVer.getGitDescribeOutput(d).mkVersion(versionFmt, fallbackVersion(d))
}
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.10.2
sbt.version=1.10.7
46 changes: 46 additions & 0 deletions src/main/scala-2.12/com/typesafe/sbt/packager/PluginCompat.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package com.typesafe.sbt.packager

import java.nio.file.{Path => NioPath}
import java.util.jar.Attributes
import sbt.*
import xsbti.FileConverter

object PluginCompat {
type FileRef = java.io.File
type ArtifactPath = java.io.File
type Out = java.io.File
type IncludeArtifact = Artifact => Boolean

val artifactStr = sbt.Keys.artifact.key
val moduleIDStr = sbt.Keys.moduleID.key
def parseModuleIDStrAttribute(m: ModuleID): ModuleID = m
def moduleIDToStr(m: ModuleID): ModuleID = m
def parseArtifactStrAttribute(a: Artifact): Artifact = a
def artifactToStr(art: Artifact): Artifact = art

def toNioPath(a: Attributed[File])(implicit conv: FileConverter): NioPath =
a.data.toPath()
def toNioPath(ref: File)(implicit conv: FileConverter): NioPath =
ref.toPath()
def toFile(a: Attributed[File])(implicit conv: FileConverter): File =
a.data
def toFile(ref: File)(implicit conv: FileConverter): File =
ref
def artifactPathToFile(ref: File)(implicit conv: FileConverter): File =
ref
def toArtifactPath(f: File)(implicit conv: FileConverter): ArtifactPath = f
def toNioPaths(cp: Seq[Attributed[File]])(implicit conv: FileConverter): Vector[NioPath] =
cp.map(_.data.toPath()).toVector
def toFiles(cp: Seq[Attributed[File]])(implicit conv: FileConverter): Vector[File] =
cp.map(_.data).toVector
def toFileRefsMapping(mappings: Seq[(File, String)])(implicit conv: FileConverter): Seq[(FileRef, String)] =
mappings
def toFileRef(x: File)(implicit conv: FileConverter): FileRef =
x
def getName(ref: File): String =
ref.getName()
def getArtifactPathName(ref: File): String =
ref.getName()
def classpathAttr = Attributes.Name.CLASS_PATH
def mainclassAttr = Attributes.Name.MAIN_CLASS
}
3 changes: 3 additions & 0 deletions src/main/scala-3/com/typesafe/sbt/packager/Compat.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package com.typesafe.sbt.packager

object Compat {}
58 changes: 58 additions & 0 deletions src/main/scala-3/com/typesafe/sbt/packager/PluginCompat.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package com.typesafe.sbt.packager

import java.io.File
import java.nio.file.{Path => NioPath}
import java.util.jar.Attributes
import sbt.*
import xsbti.{FileConverter, HashedVirtualFileRef, VirtualFile, VirtualFileRef}
import sbt.internal.RemoteCache

object PluginCompat:
type FileRef = HashedVirtualFileRef
type ArtifactPath = VirtualFileRef
type Out = VirtualFile
type IncludeArtifact = Any => Boolean

val artifactStr = Keys.artifactStr
val moduleIDStr = Keys.moduleIDStr
def parseModuleIDStrAttribute(str: String): ModuleID =
Classpaths.moduleIdJsonKeyFormat.read(str)
def moduleIDToStr(m: ModuleID): String =
Classpaths.moduleIdJsonKeyFormat.write(m)

def parseArtifactStrAttribute(str: String): Artifact =
import sbt.librarymanagement.LibraryManagementCodec.ArtifactFormat
import sjsonnew.support.scalajson.unsafe.*
Converter.fromJsonUnsafe[Artifact](Parser.parseUnsafe(str))
def artifactToStr(art: Artifact): String =
import sbt.librarymanagement.LibraryManagementCodec.ArtifactFormat
import sjsonnew.support.scalajson.unsafe.*
CompactPrinter(Converter.toJsonUnsafe(art))

def toNioPath(a: Attributed[HashedVirtualFileRef])(using conv: FileConverter): NioPath =
conv.toPath(a.data)
def toNioPath(ref: HashedVirtualFileRef)(using conv: FileConverter): NioPath =
conv.toPath(ref)
inline def toFile(a: Attributed[HashedVirtualFileRef])(using conv: FileConverter): File =
toNioPath(a).toFile()
inline def toFile(ref: HashedVirtualFileRef)(using conv: FileConverter): File =
toNioPath(ref).toFile()
def artifactPathToFile(ref: VirtualFileRef)(using conv: FileConverter): File =
conv.toPath(ref).toFile()
def toArtifactPath(f: File)(using conv: FileConverter): ArtifactPath =
conv.toVirtualFile(f.toPath())
def toNioPaths(cp: Seq[Attributed[HashedVirtualFileRef]])(using conv: FileConverter): Vector[NioPath] =
cp.map(toNioPath).toVector
inline def toFiles(cp: Seq[Attributed[HashedVirtualFileRef]])(using conv: FileConverter): Vector[File] =
toNioPaths(cp).map(_.toFile())
def toFileRefsMapping(mappings: Seq[(File, String)])(using conv: FileConverter): Seq[(FileRef, String)] =
mappings.map { case (f, name) => toFileRef(f) -> name }
def toFileRef(x: File)(using conv: FileConverter): FileRef =
conv.toVirtualFile(x.toPath())
def getName(ref: FileRef): String =
ref.name()
def getArtifactPathName(ref: ArtifactPath): String =
ref.name()
def classpathAttr: String = Attributes.Name.CLASS_PATH.toString()
def mainclassAttr: String = Attributes.Name.MAIN_CLASS.toString()
end PluginCompat
50 changes: 0 additions & 50 deletions src/main/scala-sbt-0.13/com/typesafe/sbt/packager/Compat.scala

This file was deleted.

Loading
Loading