Skip to content

Commit 099e7bc

Browse files
committed
[2.x] Drop the Manifest usage
Manifest doesn't seem to exist in Scala 3.8.0.
1 parent cf41711 commit 099e7bc

File tree

6 files changed

+31
-140
lines changed

6 files changed

+31
-140
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ on:
44
push:
55

66
env:
7-
SCALA212: 2.12.*
8-
SCALA213: 2.13.*
97
SCALA3: 3.*
108

119
jobs:
@@ -58,24 +56,15 @@ jobs:
5856
shell: bash
5957
run: |
6058
find **/src/main/contraband-scala -name "*.scala" -delete
61-
sbt -v -Dfile.encoding=UTF8 -Dsbt.test.fork=true ++$SCALA212 generateContrabands mimaReportBinaryIssues scalafmtCheckAll headerCheck Test/headerCheck test doc
62-
sbt -v -Dfile.encoding=UTF8 -Dsbt.test.fork=false ++$SCALA213 test ++$SCALA3 test
59+
sbt -v -Dfile.encoding=UTF8 -Dsbt.test.fork=true generateContrabands mimaReportBinaryIssues scalafmtCheckAll headerCheck Test/headerCheck test doc
6360
git diff --exit-code # check contrabands
6461
- name: Build and test (2)
6562
if: ${{ matrix.jobtype == 2 }}
6663
shell: bash
6764
run: |
68-
sbt -v -Dfile.encoding=UTF8 -Dsbt.test.fork=true ++$SCALA212 mimaReportBinaryIssues test
69-
sbt -v --client ++$SCALA213
70-
sbt -v --client test
71-
sbt -v --client ++$SCALA3
72-
sbt -v --client test
65+
sbt -v -Dfile.encoding=UTF8 -Dsbt.test.fork=true mimaReportBinaryIssues test
7366
- name: Build and test (3)
7467
if: ${{ matrix.jobtype == 3 }}
7568
shell: bash
7669
run: |
77-
sbt -v -Dfile.encoding=UTF8 -Dsbt.test.fork=true ++$SCALA212 test
78-
sbt -v --client ++$SCALA213
79-
sbt -v --client test
80-
sbt -v --client ++$SCALA3
8170
sbt -v --client test

build.sbt

Lines changed: 3 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ ThisBuild / publishTo := {
4545
}
4646

4747
def commonSettings: Seq[Setting[?]] = Seq(
48-
scalaVersion := scala212,
48+
scalaVersion := scala3,
4949
compile / javacOptions ++= Seq("-Xlint", "-Xlint:-serial"),
50-
crossScalaVersions := Seq(scala212, scala213, scala3),
50+
crossScalaVersions := Seq(scala3),
5151
headerLicense := (ThisBuild / headerLicense).value,
5252
)
5353

@@ -91,79 +91,9 @@ val io = (project in file("io"))
9191
mimaPreviousArtifacts := (CrossVersion partialVersion scalaVersion.value match {
9292
case Some((2, n)) if n >= 13 => Set.empty
9393
case _ =>
94-
Set(
95-
"1.0.0",
96-
"1.0.1",
97-
"1.0.2",
98-
"1.1.0",
99-
"1.1.1",
100-
"1.1.2",
101-
"1.1.3",
102-
"1.1.4",
103-
"1.2.0",
104-
"1.3.0",
105-
"1.4.0",
106-
"1.5.0",
107-
"1.6.0",
108-
"1.7.0",
109-
"1.8.0",
110-
"1.9.0",
111-
"1.10.0",
112-
) map (version => organization.value %% moduleName.value % version)
94+
Set().map((version: String) => organization.value %% moduleName.value % version)
11395
}),
11496
mimaBinaryIssueFilters ++= Seq(
115-
exclude[FinalClassProblem]("sbt.internal.io.MacJNA$TimeBuf"),
116-
// MiMa doesn't treat effectively final members as final
117-
// WORKAROUND typesafehub/migration-manager#162
118-
exclude[FinalMethodProblem]("sbt.io.SimpleFilter.accept"),
119-
exclude[FinalMethodProblem]("sbt.io.SimpleFileFilter.accept"),
120-
// MiMa doesn't understand private inner classes?
121-
// method this(sbt.io.PollingWatchService,sbt.io.PollingWatchService#PollingThread,java.nio.file.Watchable,java.util.List)Unit in class sbt.io.PollingWatchService#PollingWatchKey does not have a correspondent in current version
122-
exclude[DirectMissingMethodProblem]("sbt.io.PollingWatchService#PollingWatchKey.this"),
123-
exclude[IncompatibleMethTypeProblem]("sbt.io.PollingWatchService#PollingWatchKey.this"),
124-
// This is a private class
125-
exclude[DirectMissingMethodProblem]("sbt.io.PollingWatchService#PollingWatchKey.events"),
126-
exclude[DirectMissingMethodProblem]("sbt.io.PollingWatchService#PollingWatchKey.offer"),
127-
// This is a private class
128-
exclude[DirectMissingMethodProblem]("sbt.io.PollingWatchService#PollingThread.events"),
129-
exclude[DirectMissingMethodProblem]("sbt.io.PollingWatchService#PollingThread.initDone"),
130-
exclude[DirectMissingMethodProblem]("sbt.io.PollingWatchService#PollingThread.initDone_="),
131-
exclude[DirectMissingMethodProblem](
132-
"sbt.io.PollingWatchService#PollingThread.keysWithEvents"
133-
),
134-
exclude[DirectMissingMethodProblem]("sbt.io.PollingWatchService#PollingThread.getFileTimes"),
135-
// moved JavaMilli to sbt.io
136-
exclude[MissingClassProblem]("sbt.internal.io.JavaMilli$"),
137-
exclude[MissingClassProblem]("sbt.internal.io.JavaMilli"),
138-
// These are private classes
139-
exclude[MissingClassProblem]("sbt.internal.io.*"),
140-
// Replaced non-standard __xstat64() with conformant stat() calls
141-
exclude[DirectMissingMethodProblem]("sbt.internal.io.Linux32.*"),
142-
exclude[ReversedMissingMethodProblem]("sbt.internal.io.Linux32.*"),
143-
exclude[DirectMissingMethodProblem]("sbt.internal.io.Linux64.*"),
144-
exclude[ReversedMissingMethodProblem]("sbt.internal.io.Linux64.*"),
145-
// protected[this]
146-
exclude[DirectMissingMethodProblem]("sbt.io.CopyOptions.copy*"),
147-
// private class
148-
exclude[MissingClassProblem]("sbt.io.Event"),
149-
exclude[MissingClassProblem]("sbt.io.Event$"),
150-
exclude[MissingClassProblem]("sbt.io.MacOSXWatchKey"),
151-
exclude[MissingClassProblem]("sbt.io.PollingWatchEvent"),
152-
exclude[MissingClassProblem]("sbt.io.PollingWatchService$PollingWatchKey"),
153-
exclude[MissingClassProblem]("sbt.io.PollingWatchService$PollingThread"),
154-
exclude[MissingClassProblem]("sbt.io.PollingWatchService$Overflow$"),
155-
// private internal classes whose functionality has been replaced
156-
exclude[MissingClassProblem]("sbt.internal.io.EventMonitor*"),
157-
exclude[DirectMissingMethodProblem]("sbt.internal.io.EventMonitor.legacy"),
158-
exclude[DirectMissingMethodProblem]("sbt.internal.io.EventMonitor.applyImpl"),
159-
// private classes that have been removed
160-
exclude[MissingClassProblem]("sbt.internal.io.Alternatives$"),
161-
exclude[MissingClassProblem]("sbt.internal.io.Alternatives"),
162-
exclude[DirectMissingMethodProblem]("sbt.io.NothingFilter.unary_-"),
163-
exclude[DirectMissingMethodProblem]("sbt.io.AllPassFilter.unary_-"),
164-
exclude[IncompatibleSignatureProblem]("sbt.io.PollingWatchService.pollEvents"),
165-
exclude[IncompatibleSignatureProblem]("sbt.io.WatchService#WatchServiceAdapter.pollEvents"),
166-
exclude[IncompatibleSignatureProblem]("sbt.io.WatchService.pollEvents"),
16797
),
16898
BuildInfoPlugin.buildInfoDefaultSettings, // avoids BuildInfo generated in Compile scope
16999
addBuildInfoToConfig(Test),

io/src/main/scala/sbt/io/IO.scala

Lines changed: 9 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import scala.collection.JavaConverters._
3131
import scala.collection.immutable
3232
import scala.collection.immutable.TreeSet
3333
import scala.collection.mutable.{ HashMap, HashSet }
34-
import scala.reflect.{ Manifest => SManifest }
34+
import scala.reflect.ClassTag
3535
import scala.util.control.Exception._
3636
import scala.util.control.NonFatal
3737

@@ -79,8 +79,8 @@ object IO {
7979
* If the location cannot be determined, an error is generated.
8080
* Note that for JDK 11 onwards, a module will return a jrt path.
8181
*/
82-
def classLocationPath[A](implicit mf: SManifest[A]): NioPath =
83-
classLocationPath(mf.runtimeClass)
82+
def classLocationPath[A: ClassTag]: NioPath =
83+
classLocationPath(implicitly[ClassTag[A]].runtimeClass)
8484

8585
/**
8686
* Returns the directory, Java module, or the JAR containing the class file `cl`.
@@ -97,31 +97,8 @@ object IO {
9797
* If the location cannot be determined or it is not a file, an error is generated.
9898
* Note that for JDK 11 onwards, the returned module path cannot be expressed as `File`, so it will return `None`.
9999
*/
100-
def classLocationFileOption[A](implicit mf: SManifest[A]): Option[File] =
101-
classLocationFileOption(mf.runtimeClass)
102-
103-
/**
104-
* Returns the directory, Java module, or the JAR file containing the class file `cl`.
105-
* If the location cannot be determined or it is not a file, an error is generated.
106-
* Note that for JDK 11 onwards, the returned module path cannot be expressed as `File`.
107-
*/
108-
@deprecated(
109-
"classLocationFile may not work on JDK 11. Use classfileLocation, classLocationFileOption, or classLocationPath instead.",
110-
"1.3.0"
111-
)
112-
def classLocationFile(cl: Class[?]): File =
113-
classLocationFileOption(cl).getOrElse(sys.error(s"Unable to create File from $cl"))
114-
115-
/**
116-
* Returns the directory, Java module, or the JAR file containing the class file for type `T` (as determined by an implicit Manifest).
117-
* If the location cannot be determined, an error is generated.
118-
* Note that for JDK 11 onwards, the returned module path cannot be expressed as `File`.
119-
*/
120-
@deprecated(
121-
"classLocationFile may not work on JDK 11. Use classfileLocation, classLocationFileOption, or classLocationPath instead.",
122-
"1.3.0"
123-
)
124-
def classLocationFile[T](implicit mf: SManifest[T]): File = classLocationFile(mf.runtimeClass)
100+
def classLocationFileOption[A: ClassTag]: Option[File] =
101+
classLocationFileOption(implicitly[ClassTag[A]].runtimeClass)
125102

126103
/**
127104
* Returns the URL to the directory, Java module, or the JAR file containing the class file `cl`.
@@ -174,14 +151,15 @@ object IO {
174151
* If the location cannot be determined or it is not a file, an error is generated.
175152
* Note that for JDK 11 onwards, a module will return a jrt path.
176153
*/
177-
def classLocation[A](implicit mf: SManifest[A]): URL =
178-
classLocation(mf.runtimeClass)
154+
def classLocation[A: ClassTag]: URL =
155+
classLocation(implicitly[ClassTag[A]].runtimeClass)
179156

180157
/**
181158
* Returns a URL for the classfile containing the given class file for type `T` (as determined by an implicit Manifest).
182159
* If the location cannot be determined, an error is generated.
183160
*/
184-
def classfileLocation[T](implicit mf: SManifest[T]): URL = classfileLocation(mf.runtimeClass)
161+
def classfileLocation[T: ClassTag]: URL =
162+
classfileLocation(implicitly[ClassTag[T]].runtimeClass)
185163

186164
/**
187165
* Returns a URL for the classfile containing the given class

io/src/main/scala/sbt/io/Using.scala

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -32,29 +32,29 @@ import java.util.jar.{ JarFile, JarInputStream, JarOutputStream }
3232
import java.util.zip.{ GZIPInputStream, _ }
3333

3434
import sbt.internal.io.ErrorHandling.translate
35+
import scala.reflect.ClassTag
3536

36-
abstract class Using[Source, T] {
37-
protected def open(src: Source): T
38-
def apply[R](src: Source)(f: T => R): R = {
37+
abstract class Using[Source, A1] {
38+
protected def open(src: Source): A1
39+
def apply[R](src: Source)(f: A1 => R): R = {
3940
val resource = open(src)
4041
try {
4142
f(resource)
4243
} finally {
4344
close(resource)
4445
}
4546
}
46-
protected def close(out: T): Unit
47+
protected def close(out: A1): Unit
4748
}
4849

49-
import scala.reflect.{ Manifest => SManifest }
50-
private[sbt] abstract class WrapUsing[Source, T](implicit
51-
srcMf: SManifest[Source],
52-
targetMf: SManifest[T]
53-
) extends Using[Source, T] {
54-
protected def label[S](m: SManifest[S]) = m.runtimeClass.getSimpleName
50+
private[sbt] abstract class WrapUsing[Source: ClassTag, T: ClassTag] extends Using[Source, T] {
51+
protected def label[S: ClassTag]: String =
52+
implicitly[ClassTag[S]].runtimeClass.getSimpleName
5553
protected def openImpl(source: Source): T
5654
protected final def open(source: Source): T =
57-
translate("Error wrapping " + label(srcMf) + " in " + label(targetMf) + ": ")(openImpl(source))
55+
translate(s"Error wrapping ${label[Source]} in ${label[T]}: ")(
56+
openImpl(source)
57+
)
5858
}
5959
private[sbt] trait OpenFile[T] extends Using[File, T] {
6060
protected def openImpl(file: File): T
@@ -69,16 +69,10 @@ private[sbt] trait OpenFile[T] extends Using[File, T] {
6969
}
7070

7171
object Using {
72-
def wrap[Source, T <: AutoCloseable](openF: Source => T)(implicit
73-
srcMf: SManifest[Source],
74-
targetMf: SManifest[T]
75-
): Using[Source, T] =
72+
def wrap[Source: ClassTag, T <: AutoCloseable: ClassTag](openF: Source => T): Using[Source, T] =
7673
wrap(openF, closeCloseable)
7774

78-
def wrap[Source, T](openF: Source => T, closeF: T => Unit)(implicit
79-
srcMf: SManifest[Source],
80-
targetMf: SManifest[T]
81-
): Using[Source, T] =
75+
def wrap[Source: ClassTag, T: ClassTag](openF: Source => T, closeF: T => Unit): Using[Source, T] =
8276
new WrapUsing[Source, T] {
8377
def openImpl(source: Source) = openF(source)
8478
def close(t: T) = closeF(t)

io/src/test/scala/sbt/io/FileUtilitiesSpecification.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ object WriteContentSpecification extends Properties("Write content") {
3636

3737
private def largeUnzip() = {
3838
testUnzip[Product]
39-
testUnzip[scala.tools.nsc.Global]
39+
testUnzip[dotty.tools.backend.jvm.BTypes]
4040
true
4141
}
4242

project/Dependencies.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ import Keys._
44
object Dependencies {
55
val scala212 = "2.12.21"
66
val scala213 = "2.13.18"
7-
val scala3 = "3.3.7"
7+
val scala3 = "3.7.4"
88

99
val scalaCompiler = Def.setting {
10-
val v = if (scalaBinaryVersion.value == "3") scala213 else scalaVersion.value
11-
"org.scala-lang" % "scala-compiler" % v
10+
val v = scalaVersion.value
11+
"org.scala-lang" %% "scala3-compiler" % v
1212
}
1313

1414
val scalaVerify = "com.eed3si9n.verify" %% "verify" % "1.0.0"

0 commit comments

Comments
 (0)