diff --git a/build.mill b/build.mill index 4015fa3a..15734069 100644 --- a/build.mill +++ b/build.mill @@ -14,7 +14,7 @@ val communityBuildDottyVersion = sys.props.get("dottyVersion").toList val scala213Version = "2.13.14" val scalaVersions = Seq( - "3.3.1", + "3.7.0-RC1", "2.12.17", scala213Version ) ++ communityBuildDottyVersion @@ -39,7 +39,8 @@ trait AcyclicModule extends ScalaModule { } def compileIvyDeps = acyclicDep def scalacPluginIvyDeps = acyclicDep - def scalacOptions = super.scalacOptions() ++ acyclicOptions() + def scalacOptions = super.scalacOptions() ++ acyclicOptions() ++ + Agg.when(scalaVersion().startsWith("3"))("-experimental") } trait SafeDeps extends ScalaModule { @@ -85,6 +86,8 @@ trait OsLibModule with SafeDeps with PlatformScalaModule { outer => + def scalacPluginIvyDeps = super.scalacPluginIvyDeps() ++ Agg.when(scalaVersion().startsWith("2"))(ivy"com.lihaoyi::unroll-plugin:0.1.12") + def ivyDeps = super.ivyDeps() ++ Agg.when(scalaVersion().startsWith("2"))(ivy"com.lihaoyi::unroll-annotation:0.1.12") def publishVersion = VcsVersion.vcsState().format() def pomSettings = PomSettings( description = artifactName(), @@ -101,18 +104,20 @@ trait OsLibModule ) trait OsLibTestModule extends ScalaModule with TestModule.Utest with SafeDeps { - def ivyDeps = Agg(Deps.utest, Deps.sourcecode) + def ivyDeps = super.ivyDeps() ++ Agg(Deps.utest, Deps.sourcecode) // we check the textual output of system commands and expect it in english def forkEnv = super.forkEnv() ++ Map( "LC_ALL" -> "C", "TEST_SUBPROCESS_ENV" -> "value", "OS_TEST_RESOURCE_FOLDER" -> os.jvm(crossValue).test.resources().head.path.toString ) + def scalacOptions = super.scalacOptions() ++ + Agg.when(scalaVersion().startsWith("3"))("-experimental") } } trait OsModule extends OsLibModule { outer => - def ivyDeps = Agg(Deps.geny) + def ivyDeps = super.ivyDeps() ++ Agg(Deps.geny) override def compileIvyDeps = T { val scalaReflectOpt = Option.when(!ZincWorkerUtil.isDottyOrScala3(scalaVersion()))( Deps.scalaReflect(scalaVersion()) @@ -187,6 +192,8 @@ object os extends Module { object testSpawnExitHook extends ScalaModule{ def scalaVersion = OsJvmModule.this.scalaVersion() def moduleDeps = Seq(OsJvmModule.this) + def scalacOptions = super.scalacOptions() ++ + Agg.when(scalaVersion().startsWith("3"))("-experimental") } object testSpawnExitHook2 extends JavaModule } diff --git a/os/src/FileOps.scala b/os/src/FileOps.scala index ad1c2230..676687f2 100644 --- a/os/src/FileOps.scala +++ b/os/src/FileOps.scala @@ -11,6 +11,7 @@ import java.nio.file.{Path => _, _} import java.nio.file.attribute.{FileAttribute, PosixFilePermission, PosixFilePermissions} import scala.util.Try +import scala.annotation.unroll /** * Create a single directory at the specified path. Optionally takes in a @@ -40,8 +41,7 @@ object makeDir extends Function1[Path, Unit] { * destination path already containts a directory */ object all extends Function1[Path, Unit] { - def apply(path: Path): Unit = apply(path, null, true) - def apply(path: Path, perms: PermSet = null, acceptLinkedDirectory: Boolean = true): Unit = { + def apply(path: Path, @unroll perms: PermSet = null, @unroll acceptLinkedDirectory: Boolean = true): Unit = { checker.value.onWrite(path) // We special case calling makeDir.all on a symlink to a directory; // normally createDirectories blows up noisily, when really what most @@ -181,7 +181,7 @@ object copy { replaceExisting: Boolean = false, copyAttributes: Boolean = false, createFolders: Boolean = false, - mergeFolders: Boolean = false + @unroll mergeFolders: Boolean = false ): Unit = { checker.value.onRead(from) checker.value.onWrite(to) @@ -213,29 +213,6 @@ object copy { if (stat(from, followLinks = followLinks).isDir) for (p <- walk(from)) copyOne(p) } - /** This overload is only to keep binary compatibility with older os-lib versions. */ - @deprecated( - "Use os.copy(from, to, followLinks, replaceExisting, copyAttributes, " + - "createFolders, mergeFolders) instead", - "os-lib 0.7.5" - ) - def apply( - from: Path, - to: Path, - followLinks: Boolean, - replaceExisting: Boolean, - copyAttributes: Boolean, - createFolders: Boolean - ): Unit = apply( - from = from, - to = to, - followLinks = followLinks, - replaceExisting = replaceExisting, - copyAttributes = copyAttributes, - createFolders = createFolders, - mergeFolders = false - ) - /** * Copy a file into a particular folder, rather * than into a particular path @@ -248,7 +225,7 @@ object copy { replaceExisting: Boolean = false, copyAttributes: Boolean = false, createFolders: Boolean = false, - mergeFolders: Boolean = false + @unroll mergeFolders: Boolean = false ): Unit = { os.copy( from, @@ -260,29 +237,6 @@ object copy { mergeFolders ) } - - /** This overload is only to keep binary compatibility with older os-lib versions. */ - @deprecated( - "Use os.copy.into(from, to, followLinks, replaceExisting, copyAttributes, " + - "createFolders, mergeFolders) instead", - "os-lib 0.7.5" - ) - def apply( - from: Path, - to: Path, - followLinks: Boolean, - replaceExisting: Boolean, - copyAttributes: Boolean, - createFolders: Boolean - ): Unit = apply( - from = from, - to = to, - followLinks = followLinks, - replaceExisting = replaceExisting, - copyAttributes = copyAttributes, - createFolders = createFolders, - mergeFolders = false - ) } /** @@ -317,8 +271,7 @@ object copy { * does nothing if there aren't any */ object remove extends Function1[Path, Boolean] { - def apply(target: Path): Boolean = apply(target, false) - def apply(target: Path, checkExists: Boolean = false): Boolean = { + def apply(target: Path, @unroll checkExists: Boolean = false): Boolean = { checker.value.onWrite(target) if (checkExists) { Files.delete(target.wrapped) @@ -329,8 +282,7 @@ object remove extends Function1[Path, Boolean] { } object all extends Function1[Path, Unit] { - def apply(target: Path): Unit = apply(target, ignoreErrors = false) - def apply(target: Path, ignoreErrors: Boolean = false): Unit = { + def apply(target: Path, @unroll ignoreErrors: Boolean = false): Unit = { require(target.segmentCount != 0, s"Cannot remove a root directory: $target") checker.value.onWrite(target) @@ -353,8 +305,7 @@ object remove extends Function1[Path, Boolean] { * Checks if a file or folder exists at the given path. */ object exists extends Function1[Path, Boolean] { - def apply(p: Path): Boolean = Files.exists(p.wrapped) - def apply(p: Path, followLinks: Boolean = true): Boolean = { + def apply(p: Path, @unroll followLinks: Boolean = true): Boolean = { val opts = if (followLinks) Array[LinkOption]() else Array(LinkOption.NOFOLLOW_LINKS) Files.exists(p.wrapped, opts: _*) } diff --git a/os/src/Path.scala b/os/src/Path.scala index c4e3fad9..a7e559d5 100644 --- a/os/src/Path.scala +++ b/os/src/Path.scala @@ -477,8 +477,8 @@ object Path extends PathMacros { val f = implicitly[PathConvertible[T]].apply(f0) if (f.subpath(0, 1).toString != "~") if (base == null) Path(f0) else Path(f0, base) else { - Path(System.getProperty("user.home"))(PathConvertible.StringConvertible) / - RelPath(f.subpath(0, 1).relativize(f))(PathConvertible.NioPathConvertible) + Path(System.getProperty("user.home"))(using PathConvertible.StringConvertible) / + RelPath(f.subpath(0, 1).relativize(f))(using PathConvertible.NioPathConvertible) } } diff --git a/os/src/ProcessOps.scala b/os/src/ProcessOps.scala index e4a30629..0bf3613f 100644 --- a/os/src/ProcessOps.scala +++ b/os/src/ProcessOps.scala @@ -6,7 +6,7 @@ import os.SubProcess.InputStream import java.io.IOException import java.util.concurrent.LinkedBlockingQueue import ProcessOps._ - +import scala.annotation.unroll object call { /** @@ -26,7 +26,7 @@ object call { check: Boolean = true, propagateEnv: Boolean = true, shutdownGracePeriod: Long = 100, - destroyOnExit: Boolean = true + @unroll destroyOnExit: Boolean = true ): CommandResult = { os.proc(cmd).call( cwd = cwd, @@ -43,37 +43,6 @@ object call { ) } - // Bincompat Forwarder - def apply( - cmd: Shellable, - env: Map[String, String], - // Make sure `cwd` only comes after `env`, so `os.call("foo", path)` is a compile error - // since the correct syntax is `os.call(("foo", path))` - cwd: Path, - stdin: ProcessInput, - stdout: ProcessOutput, - stderr: ProcessOutput, - mergeErrIntoOut: Boolean, - timeout: Long, - check: Boolean, - propagateEnv: Boolean, - timeoutGracePeriod: Long - ): CommandResult = { - call( - cmd = cmd, - cwd = cwd, - env = env, - stdin = stdin, - stdout = stdout, - stderr = stderr, - mergeErrIntoOut = mergeErrIntoOut, - timeout = timeout, - check = check, - propagateEnv = propagateEnv, - shutdownGracePeriod = timeoutGracePeriod, - destroyOnExit = true - ) - } } object spawn { @@ -91,8 +60,8 @@ object spawn { stderr: ProcessOutput = os.Inherit, mergeErrIntoOut: Boolean = false, propagateEnv: Boolean = true, - shutdownGracePeriod: Long = 100, - destroyOnExit: Boolean = true + @unroll shutdownGracePeriod: Long = 100, + @unroll destroyOnExit: Boolean = true ): SubProcess = { os.proc(cmd).spawn( cwd = cwd, @@ -106,33 +75,6 @@ object spawn { destroyOnExit = destroyOnExit ) } - - // Bincompat Forwarder - def apply( - cmd: Shellable, - // Make sure `cwd` only comes after `env`, so `os.spawn("foo", path)` is a compile error - // since the correct syntax is `os.spawn(("foo", path))` - env: Map[String, String], - cwd: Path, - stdin: ProcessInput, - stdout: ProcessOutput, - stderr: ProcessOutput, - mergeErrIntoOut: Boolean, - propagateEnv: Boolean - ): SubProcess = { - spawn( - cmd = cmd, - cwd = cwd, - env = env, - stdin = stdin, - stdout = stdout, - stderr = stderr, - mergeErrIntoOut = mergeErrIntoOut, - propagateEnv = propagateEnv, - shutdownGracePeriod = 100, - destroyOnExit = true - ) - } } /**