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

Update scala3 to 3.2.0 #1314

Merged
merged 6 commits into from
Sep 6, 2022
Merged
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
23 changes: 18 additions & 5 deletions build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -595,11 +595,8 @@ trait CliOptions extends SbtModule with ScalaCliPublishModule with ScalaCliCompi
Deps.jsoniterMacros
)
private def scalaVer = Scala.scala213
def compileModuleDeps = Seq(
options
)
def scalaVersion = scalaVer
def repositories = super.repositories ++ customRepositories
def scalaVersion = scalaVer
def repositories = super.repositories ++ customRepositories
}

trait Cli extends SbtModule with ProtoBuildModule with CliLaunchers
Expand Down Expand Up @@ -1037,7 +1034,23 @@ class TastyLib(val crossScalaVersion: String) extends ScalaCliCrossSbtModule
else Nil
}
)
def constantsFile = T.persistent {
val dir = T.dest / "constants"
val dest = dir / "Constants.scala"
val code =
s"""package scala.build.tastylib.internal
|
|/** Build-time constants. Generated by mill. */
|object Constants {
| def latestSupportedScala = "${Scala.defaultInternal}"
|}
|""".stripMargin
if (!os.isFile(dest) || os.read(dest) != code)
os.write.over(dest, code, createFolders = true)
PathRef(dir)
}

def generatedSources = super.generatedSources() ++ Seq(constantsFile())
}

object `local-repo` extends LocalRepo {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package scala.build.options.publish
package scala.cli.commands.publish

import scala.cli.signing.shared.PasswordOption

Expand All @@ -7,11 +7,7 @@ sealed abstract class MaybeConfigPasswordOption extends Product with Serializabl

object MaybeConfigPasswordOption {
final case class ActualOption(option: PasswordOption) extends MaybeConfigPasswordOption
final case class ConfigOption(fullName: String) extends MaybeConfigPasswordOption {
private lazy val split = fullName.split('.')
def prefix: Seq[String] = split.dropRight(1).toSeq
def name: String = split.last
}
final case class ConfigOption(fullName: String) extends MaybeConfigPasswordOption

def parse(input: String): Either[String, MaybeConfigPasswordOption] =
if (input.startsWith("config:"))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package scala.cli.commands.publish

import caseapp._

import scala.build.options.publish.MaybeConfigPasswordOption
import scala.cli.signing.shared.PasswordOption
import scala.cli.signing.util.ArgParsers._
import scala.cli.util.ArgParsers._
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ package scala.cli.util

import caseapp.core.argparser.ArgParser
import caseapp.core.argparser.SimpleArgParser

import scala.build.options.publish.MaybeConfigPasswordOption
import scala.cli.commands.publish.MaybeConfigPasswordOption
import scala.cli.signing.shared.PasswordOption

abstract class LowPriorityArgParsers {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import scala.cli.commands.util.CommonOps.SharedDirectoriesOptionsOps
import scala.cli.commands.util.MainClassOptionsUtil._
import scala.cli.commands.util.ScalaCliSttpBackend
import scala.cli.commands.util.SharedOptionsUtil._
import scala.cli.commands.util.PublishUtils._
import scala.cli.commands.{
MainClassOptions,
Package => PackageCmd,
Expand All @@ -54,7 +55,7 @@ import scala.cli.errors.{
}
import scala.cli.packaging.Library
import scala.cli.publish.BouncycastleSignerMaker
import scala.cli.util.MaybeConfigPasswordOptionHelpers._
import scala.cli.util.ConfigPasswordOptionHelpers._

object Publish extends ScalaCommand[PublishOptions] {

Expand All @@ -79,8 +80,8 @@ object Publish extends ScalaCommand[PublishOptions] {
docJar = sharedPublish.doc,
gpgSignatureId = sharedPublish.gpgKey.map(_.trim).filter(_.nonEmpty),
gpgOptions = sharedPublish.gpgOption,
secretKey = publishParams.secretKey,
secretKeyPassword = publishParams.secretKeyPassword,
secretKey = publishParams.secretKey.map(_.configPasswordOptions()),
secretKeyPassword = publishParams.secretKeyPassword.map(_.configPasswordOptions()),
repoUser = publishRepo.user,
repoPassword = publishRepo.password,
repoRealm = publishRepo.realm,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ import scala.cli.commands.util.JvmUtils
import scala.cli.config.{ConfigDb, Keys}
import scala.cli.errors.MissingPublishOptionError
import scala.cli.signing.shared.PasswordOption
import scala.cli.util.MaybeConfigPasswordOptionHelpers._
import scala.cli.util.ConfigPasswordOptionHelpers._
import scala.cli.commands.util.PublishUtils._

final case class PgpSecretKeyCheck(
options: PublishSetupOptions,
Expand Down Expand Up @@ -64,7 +65,10 @@ final case class PgpSecretKeyCheck(
case Some(secretKey) =>
val pubKeyOpt = options.publicKey.map(_.get())
val passwordOpt =
value(options.publishParams.secretKeyPassword.map(_.get(configDb())).sequence)
value(options.publishParams.secretKeyPassword
.map(_.configPasswordOptions())
.map(_.get(configDb()))
.sequence)
(pubKeyOpt, Left(secretKey), passwordOpt)
case None =>
value(configDb().get(Keys.pgpSecretKey)) match {
Expand All @@ -83,6 +87,7 @@ final case class PgpSecretKeyCheck(
val res = value {
options.publishParams
.secretKeyPassword
.map(_.configPasswordOptions())
.map(_.get(configDb()))
.sequence
}
Expand Down Expand Up @@ -221,7 +226,8 @@ final case class PgpSecretKeyCheck(
Seq(SetSecret(
"PUBLISH_SECRET_KEY",
secretKey match {
case Left(p) => value(p.get(configDb())).getBytes().map(maybeEncodeBase64)
case Left(p) =>
value(p.configPasswordOptions().get(configDb())).getBytes().map(maybeEncodeBase64)
case Right(p) => p.getBytes().map(maybeEncodeBase64)
},
force = true
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package scala.cli.commands.util

import scala.build.options.publish.ConfigPasswordOption
import scala.cli.commands.publish.MaybeConfigPasswordOption

object PublishUtils {

implicit class ConfigPasswordOptionsOps(v: MaybeConfigPasswordOption) {
def configPasswordOptions() =
v match {
case MaybeConfigPasswordOption.ActualOption(option) =>
ConfigPasswordOption.ActualOption(option)
case MaybeConfigPasswordOption.ConfigOption(fullName) =>
ConfigPasswordOption.ConfigOption(fullName)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
package scala.cli.util

import scala.build.errors.BuildException
import scala.build.options.publish.MaybeConfigPasswordOption
import scala.cli.commands.publish.MaybeConfigPasswordOption
import scala.build.options.publish.ConfigPasswordOption
import scala.cli.config.{ConfigDb, Key}
import scala.cli.errors.MissingConfigEntryError
import scala.cli.signing.shared.PasswordOption

object MaybeConfigPasswordOptionHelpers {
object ConfigPasswordOptionHelpers {

implicit class MaybeConfigPasswordOptionOps(private val opt: MaybeConfigPasswordOption)
implicit class ConfigPasswordOptionOps(private val opt: ConfigPasswordOption)
extends AnyVal {
def get(configDb: => ConfigDb): Either[BuildException, PasswordOption] =
opt match {
case a: MaybeConfigPasswordOption.ActualOption =>
case a: ConfigPasswordOption.ActualOption =>
Right(a.option)
case c: MaybeConfigPasswordOption.ConfigOption =>
case c: ConfigPasswordOption.ConfigOption =>
val key = new Key.PasswordEntry(c.prefix, c.name)
configDb.get(key).flatMap {
case None => Left(new MissingConfigEntryError(c.fullName))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ package scala.build.preprocessing.directives
import scala.build.EitherCps.{either, value}
import scala.build.Logger
import scala.build.errors.{BuildException, MalformedInputError, UnexpectedDirectiveError}
import scala.build.options.publish.{ComputeVersion, MaybeConfigPasswordOption}
import scala.build.options.publish.ComputeVersion
import scala.build.options.publish.ConfigPasswordOption
import scala.build.options.{
BuildOptions,
PostBuildOptions,
Expand Down Expand Up @@ -101,13 +102,13 @@ case object UsingPublishContextualDirectiveHandler extends UsingDirectiveHandler
case "secretKey" =>
PublishContextualOptions(secretKey =
Some(
MaybeConfigPasswordOption.ActualOption(value(parsePasswordOption(singleValue.value)))
ConfigPasswordOption.ActualOption(value(parsePasswordOption(singleValue.value)))
)
)
case "secretKeyPassword" =>
PublishContextualOptions(
secretKeyPassword = Some(
MaybeConfigPasswordOption.ActualOption(value(parsePasswordOption(singleValue.value)))
ConfigPasswordOption.ActualOption(value(parsePasswordOption(singleValue.value)))
)
)
case "user" =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ object ActionablePreprocessor {
.map(handler => handler.createActionableDiagnostics(options))
.sequence
.left.map(CompositeBuildException(_))
.map(_.flatten)
.map((v: Seq[Seq[Any]]) => v.flatten)
.asInstanceOf[Either[BuildException, Seq[ActionableDiagnostic]]]

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package scala.build.options

import scala.build.options.publish.{ComputeVersion, MaybeConfigPasswordOption, Signer}
import scala.build.options.publish.{ComputeVersion, Signer, ConfigPasswordOption}
import scala.cli.signing.shared.PasswordOption

/** Publishing-related options, that can have different values locally and on CIs */
Expand All @@ -12,8 +12,8 @@ final case class PublishContextualOptions(
gpgSignatureId: Option[String] = None,
gpgOptions: List[String] = Nil,
signer: Option[Signer] = None,
secretKey: Option[MaybeConfigPasswordOption] = None,
secretKeyPassword: Option[MaybeConfigPasswordOption] = None,
secretKey: Option[ConfigPasswordOption] = None,
secretKeyPassword: Option[ConfigPasswordOption] = None,
repoUser: Option[PasswordOption] = None,
repoPassword: Option[PasswordOption] = None,
repoRealm: Option[String] = None,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package scala.build.options.publish

import scala.cli.signing.shared.PasswordOption

/** Can be either a [[PasswordOption]], or something like "config:…" pointing at a config entry */
sealed abstract class ConfigPasswordOption extends Product with Serializable

object ConfigPasswordOption {
final case class ActualOption(option: PasswordOption) extends ConfigPasswordOption
final case class ConfigOption(fullName: String) extends ConfigPasswordOption {
private lazy val split = fullName.split('.')
def prefix: Seq[String] = split.dropRight(1).toSeq
def name: String = split.last
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
package scala.build.tastylib

import scala.build.tastylib.internal.Constants

object TastyVersions {

// Every time tasty version is updated, please update LatestSupportedScala as well!
final val MajorVersion: Int = 28
final val MinorVersion: Int = 1
final val ExperimentalVersion: Int = 0

object LatestSupportedScala {
final val MajorVersion: Int = 3
Gedochao marked this conversation as resolved.
Show resolved Hide resolved
final val MinorVersion: Int = 1
final val MinorVersion: Int = Constants.latestSupportedScala.split('.')(1).toInt
Gedochao marked this conversation as resolved.
Show resolved Hide resolved
}

def shouldRunPreprocessor(
Expand Down
4 changes: 2 additions & 2 deletions project/deps.sc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import scala.util.Properties
object Scala {
def scala212 = "2.12.16"
def scala213 = "2.13.8"
def scala3 = "3.1.3"
def scala3 = "3.2.0"
val allScala2 = Seq(scala213, scala212)
val all = allScala2 ++ Seq(scala3)
val mainVersions = Seq(scala3, scala213)
Expand Down Expand Up @@ -64,7 +64,7 @@ object Deps {
def scalaPackager = "0.1.27"
def signingCli = "0.1.9"
}
def ammonite = ivy"com.lihaoyi:::ammonite:2.5.4-19-cd76521f"
def ammonite = ivy"com.lihaoyi:ammonite_3.1.3:2.5.4-19-cd76521f"
def asm = ivy"org.ow2.asm:asm:9.3"
// Force using of 2.13 - is there a better way?
def bloopConfig = ivy"io.github.alexarchambault.bleep:bloop-config_2.13:1.5.3-sc-1"
Expand Down
15 changes: 8 additions & 7 deletions website/docs/reference/scala-versions.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ sidebar_position: 7
Currently, Scala CLI supports Scala 3, 2.13 and 2.12. The table below lists the last supported version of Scala in Scala CLI. If you want to use a newer Scala version,
it is recommended to update scala-cli.

| Scala CLI versions | Scala 3 | Scala 2.13 | Scala 2.12 |
|---------------------|:-----------------:|------------:|-----------:|
| 0.0.9 | 3.0.2 | 2.13.7 | 2.12.7 |
| 0.1.0 - 0.1.3 | 3.1.1 | 2.13.8 | 2.12.15 |
| 0.1.4 - 0.1.7 | 3.1.2 | 2.13.8 | 2.12.15 |
| 0.1.8 | 3.1.2 | 2.13.8 | 2.12.16 |
| 0.1.9 - current | 3.1.3 | 2.13.8 | 2.12.16 |
| Scala CLI versions | Scala 3 | Scala 2.13 | Scala 2.12 |
|--------------------|:-------:|------------:|-----------:|
| 0.0.9 | 3.0.2 | 2.13.7 | 2.12.7 |
| 0.1.0 - 0.1.3 | 3.1.1 | 2.13.8 | 2.12.15 |
| 0.1.4 - 0.1.7 | 3.1.2 | 2.13.8 | 2.12.15 |
| 0.1.8 | 3.1.2 | 2.13.8 | 2.12.16 |
| 0.1.9 - 0.1.12 | 3.1.3 | 2.13.8 | 2.12.16 |
| 0.1.13 - current | 3.2.0 | 2.13.8 | 2.12.16 |