Skip to content

Commit 916a4c8

Browse files
authored
Merge pull request #3912 from Gedochao/maintenance/scala-2-cleanup-sequel
Drop Scala 2 in `config` and `specification-level` modules & bump `jsoniter-scala` to 2.38.2 (was 2.13.5.2)
2 parents bfc19a4 + 3640719 commit 916a4c8

File tree

16 files changed

+62
-147
lines changed

16 files changed

+62
-147
lines changed

.scala-steward.conf

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
updates.ignore = [
2-
{ groupId = "com.github.plokhotnyuk.jsoniter-scala", artifactId="jsoniter-scala-macros", version="2.13.5.2" },
3-
{ groupId = "com.github.plokhotnyuk.jsoniter-scala", artifactId="jsoniter-scala-core", version="2.13.5.2" }
4-
]
51
postUpdateHooks = [{
62
command = ["./mill", "-i", "generate-reference-doc[].run"],
73
commitMessage = "Generate the reference doc"

.scalafix.legacy.conf

Lines changed: 0 additions & 25 deletions
This file was deleted.

build.mill.scala

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import settings.{
1717
LocalRepo,
1818
PublishLocalNoFluff,
1919
ScalaCliCrossSbtModule,
20-
ScalaCliScalafixLegacyModule,
2120
ScalaCliScalafixModule,
2221
jvmPropertiesFileName,
2322
localRepoResourcePath,
@@ -94,11 +93,11 @@ object cliBootstrapped extends ScalaCliPublishModule {
9493
}
9594
}
9695

97-
object `specification-level` extends Cross[SpecificationLevel](Scala.all)
96+
object `specification-level` extends Cross[SpecificationLevel](Scala.scala3MainVersions)
9897
with CrossScalaDefaultToInternal
9998
object `build-macros` extends Cross[BuildMacros](Scala.scala3MainVersions)
10099
with CrossScalaDefaultToInternal
101-
object config extends Cross[Config](Scala.all) with CrossScalaDefaultToInternal
100+
object config extends Cross[Config](Scala.scala3MainVersions) with CrossScalaDefaultToInternal
102101
object options extends Cross[Options](Scala.scala3MainVersions) with CrossScalaDefaultToInternal
103102
object directives extends Cross[Directives](Scala.scala3MainVersions)
104103
with CrossScalaDefaultToInternal
@@ -648,27 +647,9 @@ trait Config extends ScalaCliCrossSbtModule
648647
override def crossScalaVersion: String = crossValue
649648
override def moduleDeps: Seq[SonatypeCentralPublishModule] =
650649
Seq(`specification-level`(crossScalaVersion))
651-
override def ivyDeps: T[Agg[Dep]] = {
652-
val maybeCollectionCompat =
653-
if (crossScalaVersion.startsWith("2.12.")) Seq(Deps.collectionCompat)
654-
else Nil
655-
super.ivyDeps() ++ maybeCollectionCompat ++ Agg(
656-
Deps.jsoniterCoreJava8
657-
)
658-
}
659-
override def compileIvyDeps: T[Agg[Dep]] = super.compileIvyDeps() ++ Agg(
660-
Deps.jsoniterMacrosJava8
661-
)
662-
override def scalacOptions: T[Seq[String]] = Task {
663-
super.scalacOptions() ++ Seq("-release", "8")
664-
}
665-
666-
// Disabling Scalafix in 2.13 and 3, so that it doesn't remove
667-
// some compatibility-related imports, that are actually only used
668-
// in Scala 2.12.
669-
override def fix(args: String*): Command[Unit] =
670-
if (crossScalaVersion.startsWith("2.12.")) super.fix(args: _*)
671-
else Task.Command(())
650+
override def ivyDeps: T[Agg[Dep]] = super.ivyDeps() ++ Agg(Deps.jsoniterCore)
651+
override def compileIvyDeps: T[Agg[Dep]] = super.compileIvyDeps() ++ Agg(Deps.jsoniterMacros)
652+
override def scalacOptions: T[Seq[String]] = super.scalacOptions() ++ Seq("-deprecation")
672653
}
673654

674655
trait Options extends ScalaCliCrossSbtModule with ScalaCliPublishModule with HasTests

modules/config/src/main/scala-2.12/scala/cli/config/Util.scala

Lines changed: 0 additions & 14 deletions
This file was deleted.

modules/config/src/main/scala-2.13/scala/cli/config/Util.scala

Lines changed: 0 additions & 3 deletions
This file was deleted.

modules/config/src/main/scala-3/scala/cli/config/Util.scala

Lines changed: 0 additions & 3 deletions
This file was deleted.

modules/config/src/main/scala/scala/cli/config/ConfigDb.scala

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
package scala.cli.config
22

3-
import com.github.plokhotnyuk.jsoniter_scala.core.{Key => _, _}
4-
import com.github.plokhotnyuk.jsoniter_scala.macros._
3+
import com.github.plokhotnyuk.jsoniter_scala.core.{Key as _, *}
4+
import com.github.plokhotnyuk.jsoniter_scala.macros.*
55

66
import java.nio.charset.StandardCharsets
77
import java.nio.file.attribute.{PosixFilePermission, PosixFilePermissions}
88
import java.nio.file.{Files, Path}
99

1010
import scala.collection.immutable.ListMap
11-
import scala.jdk.CollectionConverters._
11+
import scala.jdk.CollectionConverters.*
1212
import scala.util.Properties
1313

1414
/** In-memory representation of a configuration DB content.
@@ -50,7 +50,7 @@ final class ConfigDb private (
5050
}
5151

5252
/** Removes an entry from memory */
53-
def remove(key: Key[_]): this.type = {
53+
def remove(key: Key[?]): this.type = {
5454
rawEntries -= key.fullName
5555
this
5656
}
@@ -90,7 +90,9 @@ final class ConfigDb private (
9090
}
9191
val sortedMap: Map[String, RawJson] = ListMap.empty ++ keyValues
9292
val b =
93-
writeToArray(sortedMap, WriterConfig.withIndentionStep((level + 1) * 2))(ConfigDb.codec)
93+
writeToArray(sortedMap, WriterConfig.withIndentionStep((level + 1) * 2))(using
94+
ConfigDb.codec
95+
)
9496
if (b.nonEmpty && b.last == '}'.toByte)
9597
// FIXME We're copying / moving arrays around quite a bit here
9698
b.init ++ (" " * level).getBytes(StandardCharsets.US_ASCII) ++ Array('}'.toByte)
@@ -114,7 +116,7 @@ final class ConfigDb private (
114116
Array('\n': Byte)
115117
}
116118

117-
def saveUnsafe(path: Path): Either[ConfigDb.ConfigDbPermissionsError, Unit] = {
119+
private def saveUnsafe(path: Path): Either[ConfigDb.ConfigDbPermissionsError, Unit] = {
118120
val dir = path.getParent
119121

120122
if (Properties.isWin) {
@@ -164,7 +166,6 @@ final class ConfigDb private (
164166
}
165167

166168
object ConfigDb {
167-
168169
final class ConfigDbFormatError(
169170
message: String,
170171
causeOpt: Option[Throwable] = None
@@ -183,7 +184,7 @@ object ConfigDb {
183184
res += (if (perms.contains(PosixFilePermission.OTHERS_EXECUTE)) 'x' else '-')
184185
res.result()
185186
}
186-
final class ConfigDbPermissionsError(path: Path, perms: Set[PosixFilePermission])
187+
private final class ConfigDbPermissionsError(path: Path, perms: Set[PosixFilePermission])
187188
extends Exception(
188189
s"$path has wrong permissions ${permsString(perms)} (expected at most rwx------)"
189190
)
@@ -208,7 +209,7 @@ object ConfigDb {
208209
map.flatMap {
209210
case (k, v) =>
210211
try {
211-
val subMap = flatten(readFromArray(v.value)(codec))
212+
val subMap = flatten(readFromArray(v.value)(using codec))
212213
subMap.toSeq.map {
213214
case (k0, v0) =>
214215
(k + "." + k0, v0)
@@ -221,7 +222,7 @@ object ConfigDb {
221222
}
222223

223224
val maybeRawEntries =
224-
try Right(flatten(readFromArray(dbContent)(codec)))
225+
try Right(flatten(readFromArray(dbContent)(using codec)))
225226
catch {
226227
case e: JsonReaderException =>
227228
Left(new ConfigDbFormatError(
@@ -241,11 +242,9 @@ object ConfigDb {
241242
* either an error on failure, or a ConfigDb instance on success
242243
*/
243244
def open(path: Path): Either[Exception, ConfigDb] =
244-
if (Files.exists(path))
245-
apply(Files.readAllBytes(path), Some(path.toString))
246-
else
247-
Right(empty)
245+
if Files.exists(path)
246+
then apply(Files.readAllBytes(path), Some(path.toString))
247+
else Right(empty)
248248

249-
def empty: ConfigDb =
250-
new ConfigDb(Map())
249+
def empty: ConfigDb = new ConfigDb(Map())
251250
}

modules/config/src/main/scala/scala/cli/config/ErrorMessages.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,4 @@ package scala.cli.config
33
object ErrorMessages {
44
val inlineCredentialsError =
55
"Inline credentials not accepted, please edit the config file manually."
6-
76
}

modules/config/src/main/scala/scala/cli/config/Key.scala

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
package scala.cli.config
22

3-
import com.github.plokhotnyuk.jsoniter_scala.core._
4-
import com.github.plokhotnyuk.jsoniter_scala.macros._
3+
import com.github.plokhotnyuk.jsoniter_scala.core.*
4+
import com.github.plokhotnyuk.jsoniter_scala.macros.*
55

66
import scala.cli.commands.SpecificationLevel
7-
import scala.cli.config.PublishCredentialsAsJson._
8-
import scala.cli.config.RepositoryCredentialsAsJson._
9-
import scala.cli.config.Util._ // only used in 2.12, unused import in 2.13
7+
import scala.cli.config.PublishCredentialsAsJson.*
8+
import scala.cli.config.RepositoryCredentialsAsJson.*
109

1110
/** A configuration key
1211
*/
@@ -73,7 +72,7 @@ object Key {
7372
extends EntryError("Error parsing config JSON", Some(cause))
7473

7574
final class MalformedValue(
76-
entry: Key[_],
75+
entry: Key[?],
7776
input: Seq[String],
7877
messageOrExpectedShape: Either[String, String],
7978
cause: Option[Throwable] = None
@@ -89,7 +88,7 @@ object Key {
8988
)
9089

9190
private final class MalformedEntry(
92-
entry: Key[_],
91+
entry: Key[?],
9392
messages: ::[String]
9493
) extends EntryError(
9594
s"Malformed entry ${entry.fullName}, " +
@@ -153,7 +152,7 @@ object Key {
153152
) extends Key[PasswordOption] {
154153
def parse(json: Array[Byte]): Either[EntryError, PasswordOption] =
155154
try {
156-
val str = readFromArray(json)(stringJsonCodec)
155+
val str = readFromArray(json)(using stringJsonCodec)
157156
PasswordOption.parse(str).left.map { e =>
158157
new MalformedValue(this, Seq(str), Right(e))
159158
}
@@ -163,7 +162,7 @@ object Key {
163162
Left(new JsonReaderError(e))
164163
}
165164
def write(value: PasswordOption): Array[Byte] =
166-
writeToArray(value.asString.value)(stringJsonCodec)
165+
writeToArray(value.asString.value)(using stringJsonCodec)
167166
def asString(value: PasswordOption): Seq[String] = Seq(value.asString.value)
168167
def fromString(values: Seq[String]): Either[MalformedValue, PasswordOption] =
169168
values match {

modules/config/src/main/scala/scala/cli/config/Keys.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package scala.cli.config
22

3-
import com.github.plokhotnyuk.jsoniter_scala.core.{Key => _}
3+
import com.github.plokhotnyuk.jsoniter_scala.core.Key as _
44

55
import scala.cli.commands.SpecificationLevel
66

@@ -142,7 +142,7 @@ object Keys {
142142
)
143143

144144
// Kept for binary compatibility
145-
val repositoriesMirrors = repositoryMirrors
145+
val repositoriesMirrors: Key.StringListEntry = repositoryMirrors
146146

147147
// setting indicating if the global interactive mode was suggested
148148
val globalInteractiveWasSuggested = new Key.BooleanEntry(
@@ -169,7 +169,7 @@ object Keys {
169169
"Publishing credentials, syntax: repositoryAddress value:user value:password [realm]"
170170
)
171171

172-
def all: Seq[Key[_]] = Seq[Key[_]](
172+
def all: Seq[Key[?]] = Seq[Key[?]](
173173
actions,
174174
defaultRepositories,
175175
ghToken,
@@ -194,5 +194,5 @@ object Keys {
194194
userName,
195195
userUrl
196196
)
197-
lazy val map: Map[String, Key[_]] = all.map(e => e.fullName -> e).toMap
197+
lazy val map: Map[String, Key[?]] = all.map(e => e.fullName -> e).toMap
198198
}

0 commit comments

Comments
 (0)