Skip to content
Draft
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
2 changes: 1 addition & 1 deletion .github/scripts/get-latest-cs.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
set -e

CS_VERSION="2.1.25-M26"
CS_VERSION="2.1.25"

DIR="$(cs get --archive "https://github.com/coursier/coursier/releases/download/v$CS_VERSION/cs-x86_64-pc-win32.zip")"

Expand Down
3 changes: 1 addition & 2 deletions build.mill
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
//| - com.goyeau::mill-scalafix::0.6.2
//| - ch.epfl.scala:scalafix-interfaces:0.14.9
//| - com.lumidion::sonatype-central-client-requests:0.6.0
//| - io.get-coursier:coursier-launcher_2.13:2.1.25-M26
//| - io.get-coursier:coursier-launcher_2.13:2.1.25
//| - org.eclipse.jgit:org.eclipse.jgit:7.5.0.202512021534-r
package build

Expand Down Expand Up @@ -950,7 +950,6 @@ trait Cli extends CrossSbtModule with ProtoBuildModule with CliLaunchers
override def mvnDeps: T[Seq[Dep]] = super.mvnDeps() ++ Seq(
Deps.caseApp,
Deps.coursierLauncher,
Deps.coursierProxySetup,
Deps.coursierPublish.exclude((organization, "config_2.13")).exclude((organization, "config_3")),
Deps.jimfs, // scalaJsEnvNodeJs pulls jimfs:1.1, whose class path seems borked (bin compat issue with the guava version it depends on)
Deps.jniUtils,
Expand Down
2 changes: 1 addition & 1 deletion mill
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# Adapted from

coursier_version="2.1.25-M26"
coursier_version="2.1.25"
COMMAND=$@

# necessary for Windows various shell environments
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import scala.concurrent.ExecutionContext

class ExcludeTests extends TestUtil.ScalaCliBuildSuite {
val preprocessors: Seq[Preprocessor] = Sources.defaultPreprocessors(
archiveCache = ArchiveCache().withCache(
archiveCache = ArchiveCache().copy(cache =
new Cache[Task] {
def fetch: Fetch[Task] = _ => sys.error("shouldn't be used")
def file(artifact: Artifact): EitherT[Task, ArtifactError, File] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class OfflineTests extends TestUtil.ScalaCliBuildSuite {
internal = InternalOptions(
cache = Some(FileCache()
.withLocation(directories.cacheDir.toString)
.withCachePolicies(Seq(coursier.cache.CachePolicy.LocalOnly)))
.copy(cachePolicies = Seq(coursier.cache.CachePolicy.LocalOnly)))
)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import scala.concurrent.ExecutionContext
class PreprocessingTests extends TestUtil.ScalaCliBuildSuite {
private val markdownPreprocessor: MarkdownPreprocessor =
Sources.defaultPreprocessors(
ArchiveCache().withCache(
ArchiveCache().copy(cache =
new Cache[Task] {
def fetch: Fetch[Task] = _ => sys.error("shouldn't be used")
def file(artifact: Artifact): EitherT[Task, ArtifactError, File] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class SourcesTests extends TestUtil.ScalaCliBuildSuite {
given ScalaCliInvokeData = ScalaCliInvokeData.dummy

val preprocessors: Seq[Preprocessor] = Sources.defaultPreprocessors(
ArchiveCache().withCache(
ArchiveCache().copy(cache =
new Cache[Task] {
def fetch: Fetch[Task] = _ => sys.error("shouldn't be used")
def file(artifact: Artifact): EitherT[Task, ArtifactError, File] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class MarkdownPreprocessorTests extends TestUtil.ScalaCliBuildSuite {
given ScalaCliInvokeData = ScalaCliInvokeData.dummy

private val preprocessors: Seq[Preprocessor] = Sources.defaultPreprocessors(
ArchiveCache().withCache(
ArchiveCache().copy(cache =
new Cache[Task] {
def fetch: Fetch[Task] = _ => sys.error("shouldn't be used")
def file(artifact: Artifact): EitherT[Task, ArtifactError, File] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ abstract class ScalaCommand[T <: HasGlobalOptions](implicit myParser: Parser[T],
.getOrElse(defaultScalaVersion)
val (fromIndex, completions) = cache.logger.use {
coursier.complete.Complete(cache)
.withInput(prefix)
.copy(input = prefix)
.withScalaVersion(sv)
.complete()
.unsafeRun()(using cache.ec)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ object Export extends ScalaCommand[ExportOptions] {
)
val launcherTasks = launcherArtifacts.map {
case (path, url) =>
val art = Artifact(url).withChanging(true)
val art = Artifact(url).copy(changing = true)
cache.file(art).run.flatMap {
case Left(e) => Task.fail(e)
case Right(f) => Task.delay {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ object SecretCreate extends ScalaCommand[SecretCreateOptions] {
}

val cache = options.coursier.coursierCache(logger)
val archiveCache = ArchiveCache().withCache(cache)
val archiveCache = ArchiveCache().copy(cache = cache)

LibSodiumJni.init(cache, archiveCache, logger)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -909,8 +909,10 @@ object Package extends ScalaCommand[PackageOptions] with BuildCommandHelpers {
// TODO Generate that in memory
val tmpJar = os.temp(prefix = destPath.last.stripSuffix(".jar"), suffix = ".jar")
val tmpJarParams = Parameters.Assembly()
.withExtraZipEntries(patchedByteCodeZipEntries)
.withBaseManifest(baseManifestOpt)
.copy(
extraZipEntries = patchedByteCodeZipEntries,
baseManifest = baseManifestOpt
)
.withMainClass(mainClass)
AssemblyGenerator.generate(tmpJarParams, tmpJar.toNIO)
val tmpJarContent = os.read.bytes(tmpJar)
Expand Down Expand Up @@ -948,9 +950,9 @@ object Package extends ScalaCommand[PackageOptions] with BuildCommandHelpers {
val preamble = Preamble()
.withOsKind(Properties.isWin)
.callsItself(Properties.isWin)
.withJavaOpts(builds.head.options.javaOptions.javaOpts.toSeq.map(_.value.value))
.copy(javaOpts = builds.head.options.javaOptions.javaOpts.toSeq.map(_.value.value))
val baseParams = Parameters.Bootstrap(Seq(loaderContent), mainClass)
.withDeterministic(true)
.copy(deterministic = true)
.withPreamble(preamble)

val params: Parameters.Bootstrap =
Expand All @@ -976,7 +978,7 @@ object Package extends ScalaCommand[PackageOptions] with BuildCommandHelpers {
else ClassPathEntry.Url(a.url)
}
val pythonContent = Seq(ClassLoaderContent(entries))
baseParams.addExtraContent("python", pythonContent).withPython(true)
baseParams.addExtraContent("python", pythonContent).copy(python = true)
}
else baseParams

Expand Down Expand Up @@ -1114,11 +1116,13 @@ object Package extends ScalaCommand[PackageOptions] with BuildCommandHelpers {
}
else None
val params = Parameters.Assembly()
.withExtraZipEntries(nonManifestEntries)
.withBaseManifest(baseManifestOpt)
.withFiles(jars.map(_.toIO))
.withMainClass(mainClassOpt)
.withPreambleOpt(preambleOpt)
.copy(
extraZipEntries = nonManifestEntries,
baseManifest = baseManifestOpt,
files = jars.map(_.toIO),
mainClass = mainClassOpt,
preambleOpt = preambleOpt
)
value(alreadyExistsCheck())
AssemblyGenerator.generate(params, destPath.toNIO)
val patchedDest = value(SlothPatcher.patchJarFile(destPath, options, logger))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ abstract class PgpExternalCommand extends ExternalCommand {
signingCliOptions: bo.ScalaSigningCliOptions
): Either[BuildException, Int] = either {

val archiveCache = ArchiveCache().withCache(cache)
val archiveCache = ArchiveCache().copy(cache = cache)

val binary = value(PgpExternalCommand.launcher(
cache,
Expand Down Expand Up @@ -71,7 +71,7 @@ abstract class PgpExternalCommand extends ExternalCommand {
signingCliOptions: bo.ScalaSigningCliOptions
): Either[BuildException, String] = either {

val archiveCache = ArchiveCache().withCache(cache)
val archiveCache = ArchiveCache().copy(cache = cache)

val binary = value(PgpExternalCommand.launcher(
cache,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ object PublishSetup extends ScalaCommand[PublishSetupOptions] {
s"Uploading ${missingSetSecrets.length} GitHub repository $name"
}

LibSodiumJni.init(coursierCache, ArchiveCache().withCache(coursierCache), logger)
LibSodiumJni.init(coursierCache, ArchiveCache().copy(cache = coursierCache), logger)

lazy val pubKey = SecretCreate.publicKey(
ghRepoOrg,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ final case class PgpSecretKeyCheck(
def javaCommand: Either[BuildException, () => String] = either {
() =>
value(JvmUtils.javaOptions(options.sharedJvm)).javaHome(
ArchiveCache().withCache(coursierCache),
ArchiveCache().copy(cache = coursierCache),
coursierCache,
logger.verbosity
).value.javaCommand
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,16 @@ final case class CoursierOptions(
coursierValidateChecksums.getOrElse(true)

def coursierCache(logger: Logger, cacheLogger: CacheLogger): FileCache[Task] = {
var baseCache = FileCache().withLogger(cacheLogger)
var baseCache = FileCache().copy(logger = cacheLogger)
if (!validateChecksums)
baseCache = baseCache.withChecksums(Nil)
baseCache = baseCache.copy(checksums = Nil)
val ttlOpt = ttl.map(_.trim).filter(_.nonEmpty).map(Duration(_))
for (ttl0 <- ttlOpt)
baseCache = baseCache.withTtl(ttl0)
for (loc <- cache.filter(_.trim.nonEmpty))
baseCache = baseCache.withLocation(loc)
for (isOffline <- getOffline(logger) if isOffline)
baseCache = baseCache.withCachePolicies(Seq(CachePolicy.LocalOnly))
baseCache = baseCache.copy(cachePolicies = Seq(CachePolicy.LocalOnly))

baseCache
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ object LauncherCli {
val cliSubPath = s"org/virtuslab/scala-cli/cli_$scalaBinaryVersion"
val mavenMetadataUrl =
s"${RepositoryUtils.snapshotsRepositoryUrl}/$cliSubPath/maven-metadata.xml"
val artifact = Artifact(mavenMetadataUrl).withChanging(true)
val artifact = Artifact(mavenMetadataUrl).copy(changing = true)
cache.fileWithTtl0(artifact) match {
case Left(_) =>
System.err.println(s"Unable to find nightly ${ScalaCli.fullRunnerName} version")
Expand Down
2 changes: 1 addition & 1 deletion modules/cli/src/test/scala/cli/tests/TestUtil.scala
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ object TestUtil {
}

def downloadFile(url: String): Either[ArtifactError, Array[Byte]] = {
val artifact = Artifact(url).withChanging(true)
val artifact = Artifact(url).copy(changing = true)
val cache = FileCache()

val file: Either[ArtifactError, File] = cache.logger.use {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ object CsLoggerUtil {
)
)
updatedLogger.init()
cache.withLogger(updatedLogger)
cache.copy(logger = updatedLogger)
}
else cache
case _ => cache
Expand All @@ -48,8 +48,8 @@ object CsLoggerUtil {
javaHome.cache.map(_.archiveCache.cache) match {
case Some(f: FileCache[Task]) =>
val cache0 = f.withMessage(message)
javaHome.withCache(
javaHome.cache.map(c => c.withArchiveCache(c.archiveCache.withCache(cache0)))
javaHome.copy(cache =
javaHome.cache.map(c => c.copy(archiveCache = c.archiveCache.copy(cache = cache0)))
)
case _ => javaHome
}
Expand Down
16 changes: 9 additions & 7 deletions modules/options/src/main/scala/scala/build/Artifacts.scala
Original file line number Diff line number Diff line change
Expand Up @@ -486,13 +486,15 @@ object Artifacts {
}
// this is actually fetcher.artifacts, which is a private field…
val artifacts = coursier.Artifacts()
.withCache(fetcher.cache)
.withClassifiers(fetcher.classifiers)
.withMainArtifactsOpt(fetcher.mainArtifactsOpt)
.withArtifactTypesOpt(fetcher.artifactTypesOpt)
.withExtraArtifactsSeq(fetcher.extraArtifactsSeq)
.withClasspathOrder(fetcher.classpathOrder)
.withTransformArtifacts(fetcher.transformArtifacts)
.copy(
cache = fetcher.cache,
classifiers = fetcher.classifiers,
mainArtifactsOpt = fetcher.mainArtifactsOpt,
artifactTypesOpt = fetcher.artifactTypesOpt,
extraArtifactsSeq = fetcher.extraArtifactsSeq,
classpathOrder = fetcher.classpathOrder,
transformArtifacts = fetcher.transformArtifacts
)
artifacts
.withResolution(resolution)
.runResult()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,18 @@ object TemporaryInMemoryRepository {
var conn: URLConnection = null
try {
conn = ConnectionBuilder(url.toURI.toASCIIString)
.withFollowHttpToHttpsRedirections(
cacheOpt.fold(false)(_.followHttpToHttpsRedirections)
.copy(
followHttpToHttpsRedirections = cacheOpt.fold(false)(
_.followHttpToHttpsRedirections
),
followHttpsToHttpRedirections = cacheOpt.fold(false)(
_.followHttpsToHttpRedirections
),
sslSocketFactoryOpt = cacheOpt.flatMap(_.sslSocketFactoryOpt),
hostnameVerifierOpt = cacheOpt.flatMap(_.hostnameVerifierOpt),
method = "HEAD",
maxRedirectionsOpt = cacheOpt.flatMap(_.maxRedirections)
)
.withFollowHttpsToHttpRedirections(
cacheOpt.fold(false)(_.followHttpsToHttpRedirections)
)
.withSslSocketFactoryOpt(cacheOpt.flatMap(_.sslSocketFactoryOpt))
.withHostnameVerifierOpt(cacheOpt.flatMap(_.hostnameVerifierOpt))
.withMethod("HEAD")
.withMaxRedirectionsOpt(cacheOpt.flatMap(_.maxRedirections))
.connection()
// Even though the finally clause handles this too, this has to be run here, so that we return Some(true)
// iff this doesn't throw.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ case object ActionableDependencyHandler

private def mergeCoreVersions(parts: Seq[CoreVersions]): CoreVersions =
val mergedAvailable = parts.flatMap(_.available0).distinctBy(_.asString).toList
CoreVersions.empty.withAvailable0(mergedAvailable)
CoreVersions.empty.copy(available0 = mergedAvailable)

private def findLatestVersion(
buildOptions: BuildOptions,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ object FetchExternalBinary {
makeExecutable: Boolean = true
): Either[BuildException, Option[os.Path]] = either {

val artifact = Artifact(url).withChanging(changing)
val artifact = Artifact(url).copy(changing = changing)
val res = archiveCache.cache.loggerOpt.getOrElse(CacheLogger.nop).use {
logger.log(s"Getting $url")
archiveCache.get(artifact)
Expand Down
14 changes: 8 additions & 6 deletions modules/options/src/main/scala/scala/build/internals/Util.scala
Original file line number Diff line number Diff line change
Expand Up @@ -75,21 +75,23 @@ object Util {
val mod = dep.module.toCs
var dep0 = coursier.Dependency(mod, VersionConstraint(dep.version))
if (dep.exclude.nonEmpty)
dep0 = dep0.withMinimizedExclusions {
dep0 = dep0.copy(minimizedExclusions =
MinimizedExclusions {
dep.exclude.toSet[dependency.Module].map { mod =>
(coursier.Organization(mod.organization), coursier.ModuleName(mod.name))
}
}
}
)
for (clOpt <- dep.userParams.find(_._1 == "classifier").map(_._2); cl <- clOpt)
dep0 = dep0.withPublication(dep0.publication.withClassifier(coursier.core.Classifier(cl)))
dep0 = dep0.copy(publication =
dep0.publication.copy(classifier = coursier.core.Classifier(cl))
)
for (tpeOpt <- dep.userParams.find(_._1 == "type").map(_._2); tpe <- tpeOpt)
dep0 = dep0.withPublication(dep0.publication.withType(coursier.core.Type(tpe)))
dep0 = dep0.copy(publication = dep0.publication.copy(`type` = coursier.core.Type(tpe)))
for (extOpt <- dep.userParams.find(_._1 == "ext").map(_._2); ext <- extOpt)
dep0 = dep0.withPublication(dep0.publication.withExt(coursier.core.Extension(ext)))
dep0 = dep0.copy(publication = dep0.publication.copy(ext = coursier.core.Extension(ext)))
for (_ <- dep.userParams.find(_._1 == "intransitive"))
dep0 = dep0.withTransitive(false)
dep0 = dep0.copy(transitive = false)
dep0
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ final case class BuildOptions(
coursier.complete.Complete(finalCache)
.withScalaVersion(scalaVersion)
.withScalaBinaryVersion(scalaVersion.split('.').take(2).mkString("."))
.withInput(s"org.scalameta:semanticdb-scalac_$scalaVersion:")
.copy(input = s"org.scalameta:semanticdb-scalac_$scalaVersion:")
.complete()
.future()(using finalCache.ec)
}
Expand Down Expand Up @@ -258,7 +258,7 @@ final case class BuildOptions(
lazy val finalCache: FileCache[Task] = internal.cache.getOrElse(FileCache())
// This might download a JVM if --jvm … is passed or no system JVM is installed

lazy val archiveCache: ArchiveCache[Task] = ArchiveCache().withCache(finalCache)
lazy val archiveCache: ArchiveCache[Task] = ArchiveCache().copy(cache = finalCache)

private lazy val javaCommand0: Positioned[JavaHomeInfo] =
javaHomeLocation().map(JavaHomeInfo(_))
Expand Down Expand Up @@ -710,7 +710,7 @@ object BuildOptions {
.map(_.describe)
.map(f => os.read.bytes(os.Path(f, Os.pwd)))
}
def changing(cache: FileCache[Task]): Download = apply(cache, Artifact(_).withChanging(true))
def changing(cache: FileCache[Task]): Download = apply(cache, Artifact(_).copy(changing = true))
val notSupported: Download = _ => Left("URL not supported")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,11 @@ final case class JavaOptions(
}
val jvmCache = JvmCache()
.withIndex(indexTask)
.withArchiveCache(
archiveCache.withCache(
cache.withMessage("Downloading JVM")
)
.copy(
archiveCache = archiveCache.copy(cache = cache.withMessage("Downloading JVM")),
os = finalJvmIndexOs,
architecture = jvmIndexArch.getOrElse(JvmChannel.defaultArchitecture())
)
.withOs(finalJvmIndexOs)
.withArchitecture(jvmIndexArch.getOrElse(JvmChannel.defaultArchitecture()))
JavaHome().withCache(jvmCache)
}

Expand Down
Loading
Loading