From a395c4afe50a062dbf12ef820ab22f6f4ea72187 Mon Sep 17 00:00:00 2001 From: Tobias Roeser Date: Tue, 5 Mar 2024 18:21:41 +0100 Subject: [PATCH] Fix deprecations --- build.sc | 53 +++++++++++++++++++++++++++++------------------------ 1 file changed, 29 insertions(+), 24 deletions(-) diff --git a/build.sc b/build.sc index ae39c85e8..28b7fb370 100644 --- a/build.sc +++ b/build.sc @@ -1,3 +1,7 @@ +import $ivy.`com.lihaoyi::mill-contrib-bloop:$MILL_VERSION` +import $ivy.`io.get-coursier::coursier-launcher:2.1.0-RC1` +import $file.ci.upload + import mill._ import scalalib._ import publish._ @@ -5,13 +9,11 @@ import mill.api.Lazy import mill.contrib.bloop.Bloop import mill.scalalib.api.ZincWorkerUtil._ import coursier.mavenRepositoryString -import $file.ci.upload - -import $ivy.`com.lihaoyi::mill-contrib-bloop:$MILL_VERSION` -import $ivy.`io.get-coursier::coursier-launcher:2.1.0-RC1` import mill.define.Command import mill.testrunner.TestResult + import scala.util.chaining.scalaUtilChainingOps +import scala.util.control.NonFatal val ghOrg = "com-lihaoyi" val ghRepo = "Ammonite" @@ -29,15 +31,15 @@ val isPublishableCommit = publishBranches.exists(suffix => x.endsWith(s"/${suffix}")) ) -val latestTaggedVersion = os.proc("git", "describe", "--abbrev=0", "--tags").call().out.trim +val latestTaggedVersion = os.proc("git", "describe", "--abbrev=0", "--tags").call().out.trim() -val gitHead = os.proc("git", "rev-parse", "HEAD").call().out.trim +val gitHead = os.proc("git", "rev-parse", "HEAD").call().out.trim() val commitsSinceTaggedVersion = { os.proc("git", "rev-list", gitHead, "--not", latestTaggedVersion, "--count") .call() .out - .trim + .trim() .toInt } @@ -64,10 +66,10 @@ val (buildVersion, unstable) = scala.util.Try( os.proc("git", "describe", "--exact-match", "--tags", "--always", gitHead) .call() .out - .trim + .trim() ).toOption match { case None => - val gitHash = os.proc("git", "rev-parse", "--short", "HEAD").call().out.trim + val gitHash = os.proc("git", "rev-parse", "--short", "HEAD").call().out.trim() (s"$latestTaggedVersion-$commitsSinceTaggedVersion-$gitHash", true) case Some(tagName) => (tagName, false) } @@ -281,7 +283,7 @@ trait AmmDependenciesResourceFileModule extends JavaModule { def dependencyResourceFileName: String def dependencyFileResources = T { val deps0 = compileIvyDeps().map(bindDependency()) ++ transitiveIvyDeps() - val (_, res) = mill.modules.Jvm.resolveDependenciesMetadata( + val (_, res) = mill.util.Jvm.resolveDependenciesMetadata( repositoriesTask(), deps0.map(_.dep), // .map(resolveCoursierDependency().apply(_)), deps0.filter(_.force).map(_.dep), // .map(resolveCoursierDependency().apply(_)), @@ -402,7 +404,7 @@ object amm extends Cross[MainModule](fullCrossScalaVersions) { val outDir = T.ctx().dest val javadocDir = outDir / "javadoc" os.makeDir.all(javadocDir) - mill.api.Result.Success(mill.modules.Jvm.createJar(Agg(javadocDir))(outDir)) + mill.api.Result.Success(mill.util.Jvm.createJar(Agg(javadocDir))(outDir)) } else super.docJar def constantsSourceDir = T { @@ -506,7 +508,7 @@ object amm extends Cross[MainModule](fullCrossScalaVersions) { amm.repl.api().exposedClassPath() ++ amm.compiler().exposedClassPath() ++ Seq(compile().classes) ++ - resolveDeps(T.task { compileIvyDeps().map(bindDependency()) ++ transitiveIvyDeps() })() + resolveDeps(T.task { this.compileIvyDeps().map(bindDependency()) ++ transitiveIvyDeps() })() ) } @@ -559,7 +561,7 @@ trait MainModule extends AmmModule { externalSources() def prependShellScript = T { - mill.modules.Jvm.launcherUniversalScript( + mill.util.Jvm.launcherUniversalScript( mainClass().get, Agg("$0"), Agg("%~dpnx0"), @@ -652,7 +654,7 @@ def generateApiWhitelist(replApiCp: Seq[PathRef])(implicit ctx: mill.api.Ctx.Des val thinClasspathEntries = replApiCp.map(_.path).flatMap { cpRoot => if (os.isFile(cpRoot) && cpRoot.ext == "jar") { val zip = new java.util.zip.ZipFile(cpRoot.toIO) - import collection.JavaConverters._ + import scala.jdk.CollectionConverters._ for (e <- zip.entries().asScala) yield e.getName } else if (os.isDir(cpRoot)) { for (sub <- os.walk(cpRoot)) yield sub.relativeTo(cpRoot).toString @@ -886,7 +888,7 @@ def publishDocs() = { ) ) } catch { - case e => + case NonFatal(e) => println(e) e.printStackTrace() throw e @@ -988,11 +990,11 @@ def publishSonatype( } if (isPublishableCommit) new SonatypePublisher( - "https://oss.sonatype.org/service/local", - "https://oss.sonatype.org/content/repositories/snapshots", - sys.env("SONATYPE_DEPLOY_USER") + ":" + sys.env("SONATYPE_DEPLOY_PASSWORD"), - true, - Seq( + uri = "https://oss.sonatype.org/service/local", + snapshotUri = "https://oss.sonatype.org/content/repositories/snapshots", + credentials = sys.env("SONATYPE_DEPLOY_USER") + ":" + sys.env("SONATYPE_DEPLOY_PASSWORD"), + signed = true, + gpgArgs = Seq( "--passphrase", sys.env("SONATYPE_PGP_PASSWORD"), "--no-tty", @@ -1003,10 +1005,13 @@ def publishSonatype( "-a", "-b" ), - 600000, - 600000, - T.ctx().log, - 600000 + readTimeout = 600000, + connectTimeout = 600000, + log = T.log, + workspace = T.workspace, + env = T.env, + awaitTimeout = 600000, + stagingRelease = true ).publishAll( true, x: _*