Skip to content

Commit eac0614

Browse files
authored
Revert "Read coursier env vars via Task.Input (#5350)" (#5404)
This reverts commit d03fd45. Fixes #5398
1 parent e57c725 commit eac0614

File tree

24 files changed

+153
-445
lines changed

24 files changed

+153
-445
lines changed

core/util/src/mill/util/CoursierConfig.scala

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

core/util/src/mill/util/Jvm.scala

Lines changed: 20 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -445,13 +445,9 @@ object Jvm {
445445

446446
private def coursierCache(
447447
ctx: Option[mill.define.TaskCtx],
448-
coursierCacheCustomizer: Option[FileCache[Task] => FileCache[Task]],
449-
config: CoursierConfig
448+
coursierCacheCustomizer: Option[FileCache[Task] => FileCache[Task]]
450449
) =
451-
FileCache[Task](os.Path(config.cacheLocation).toIO)
452-
.withCredentials(config.credentials)
453-
.withTtl(config.ttl)
454-
.withCachePolicies(config.cachePolicies)
450+
FileCache[Task]()
455451
.pipe { cache =>
456452
coursierCacheCustomizer.fold(cache)(c => c.apply(cache))
457453
}
@@ -477,8 +473,7 @@ object Jvm {
477473
coursierCacheCustomizer: Option[FileCache[Task] => FileCache[Task]] = None,
478474
artifactTypes: Option[Set[Type]] = None,
479475
resolutionParams: ResolutionParams = ResolutionParams(),
480-
checkGradleModules: Boolean = false,
481-
config: CoursierConfig
476+
checkGradleModules: Boolean = false
482477
): Result[coursier.Artifacts.Result] = {
483478
val resolutionRes = resolveDependenciesMetadataSafe(
484479
repositories,
@@ -489,12 +484,11 @@ object Jvm {
489484
ctx,
490485
coursierCacheCustomizer,
491486
resolutionParams,
492-
checkGradleModules = checkGradleModules,
493-
config = config
487+
checkGradleModules = checkGradleModules
494488
)
495489

496490
resolutionRes.flatMap { resolution =>
497-
val coursierCache0 = coursierCache(ctx, coursierCacheCustomizer, config)
491+
val coursierCache0 = coursierCache(ctx, coursierCacheCustomizer)
498492

499493
val artifactsResultOrError = Artifacts(coursierCache0)
500494
.withResolution(resolution)
@@ -542,8 +536,7 @@ object Jvm {
542536
coursierCacheCustomizer: Option[FileCache[Task] => FileCache[Task]] = None,
543537
artifactTypes: Option[Set[Type]] = None,
544538
resolutionParams: ResolutionParams = ResolutionParams(),
545-
checkGradleModules: Boolean = false,
546-
config: CoursierConfig
539+
checkGradleModules: Boolean = false
547540
): Result[Seq[PathRef]] =
548541
getArtifacts(
549542
repositories,
@@ -556,8 +549,7 @@ object Jvm {
556549
coursierCacheCustomizer,
557550
artifactTypes,
558551
resolutionParams,
559-
checkGradleModules = checkGradleModules,
560-
config = config
552+
checkGradleModules = checkGradleModules
561553
).map { res =>
562554
BuildCtx.withFilesystemCheckerDisabled {
563555
res.files
@@ -568,24 +560,22 @@ object Jvm {
568560

569561
def jvmIndex(
570562
ctx: Option[mill.define.TaskCtx] = None,
571-
coursierCacheCustomizer: Option[FileCache[Task] => FileCache[Task]] = None,
572-
config: CoursierConfig
563+
coursierCacheCustomizer: Option[FileCache[Task] => FileCache[Task]] = None
573564
): JvmIndex = {
574-
val coursierCache0 = coursierCache(ctx, coursierCacheCustomizer, config)
575-
coursierCache0.logger.use(jvmIndex0(ctx, coursierCacheCustomizer, config = config))
565+
val coursierCache0 = coursierCache(ctx, coursierCacheCustomizer)
566+
coursierCache0.logger.use(jvmIndex0(ctx, coursierCacheCustomizer))
576567
.unsafeRun()(using coursierCache0.ec)
577568
}
578569

579570
def jvmIndex0(
580571
ctx: Option[mill.define.TaskCtx] = None,
581572
coursierCacheCustomizer: Option[FileCache[Task] => FileCache[Task]] = None,
582-
jvmIndexVersion: String = "latest.release",
583-
config: CoursierConfig
573+
jvmIndexVersion: String = "latest.release"
584574
): Task[JvmIndex] = {
585-
val coursierCache0 = coursierCache(ctx, coursierCacheCustomizer, config)
575+
val coursierCache0 = coursierCache(ctx, coursierCacheCustomizer)
586576
JvmIndex.load(
587577
cache = coursierCache0, // the coursier.cache.Cache instance to use
588-
repositories = config.repositories, // repositories to use
578+
repositories = Resolve().repositories, // repositories to use
589579
indexChannel = JvmChannel.module(
590580
JvmChannel.centralModule(),
591581
version = jvmIndexVersion
@@ -603,10 +593,9 @@ object Jvm {
603593
ctx: Option[mill.define.TaskCtx] = None,
604594
coursierCacheCustomizer: Option[FileCache[Task] => FileCache[Task]] = None,
605595
jvmIndexVersion: String = mill.api.BuildInfo.coursierJvmIndexVersion,
606-
useShortPaths: Boolean = false,
607-
config: CoursierConfig
596+
useShortPaths: Boolean = false
608597
): Result[os.Path] = {
609-
val coursierCache0 = coursierCache(ctx, coursierCacheCustomizer, config)
598+
val coursierCache0 = coursierCache(ctx, coursierCacheCustomizer)
610599
val shortPathDirOpt = Option.when(useShortPaths) {
611600
if (isWin)
612601
// On Windows, prefer to use System.getenv over sys.env (or ctx.env for
@@ -625,16 +614,10 @@ object Jvm {
625614
val jvmCache = JvmCache()
626615
.withArchiveCache(
627616
ArchiveCache()
628-
.withLocation(os.Path(config.archiveCacheLocation).toIO)
629617
.withCache(coursierCache0)
630618
.withShortPathDirectory(shortPathDirOpt.map(_.toIO))
631619
)
632-
.withIndex(jvmIndex0(
633-
ctx,
634-
coursierCacheCustomizer,
635-
jvmIndexVersion,
636-
config = config
637-
))
620+
.withIndex(jvmIndex0(ctx, coursierCacheCustomizer, jvmIndexVersion))
638621
val javaHome = JavaHome()
639622
.withCache(jvmCache)
640623
// when given a version like "17", always pick highest version in the index
@@ -656,8 +639,7 @@ object Jvm {
656639
coursierCacheCustomizer: Option[FileCache[Task] => FileCache[Task]] = None,
657640
resolutionParams: ResolutionParams = ResolutionParams(),
658641
boms: IterableOnce[BomDependency] = Nil,
659-
checkGradleModules: Boolean = false,
660-
config: CoursierConfig
642+
checkGradleModules: Boolean = false
661643
): Result[Resolution] = {
662644

663645
val rootDeps = deps.iterator
@@ -670,7 +652,7 @@ object Jvm {
670652
.toMap
671653

672654
val offlineMode = ctx.fold(false)(_.offline)
673-
val coursierCache0 = coursierCache(ctx, coursierCacheCustomizer, config)
655+
val coursierCache0 = coursierCache(ctx, coursierCacheCustomizer)
674656

675657
val resolutionParams0 = resolutionParams.addForceVersion(forceVersions.toSeq*)
676658

@@ -691,8 +673,6 @@ object Jvm {
691673
.withResolutionParams(resolutionParams0)
692674
.withMapDependenciesOpt(mapDependencies)
693675
.withBoms(boms.iterator.toSeq)
694-
.withConfFiles(config.confFiles.map(_.toNIO))
695-
.withMirrors(config.mirrors)
696676

697677
resolve.either() match {
698678
case Left(error) =>
@@ -743,11 +723,8 @@ object Jvm {
743723
}
744724

745725
// Parse a list of repositories from their string representation
746-
private[mill] def reposFromStrings(
747-
repoList: Seq[String],
748-
defaultRepos: Seq[Repository]
749-
): Result[Seq[Repository]] = {
750-
RepositoryParser.repositories(repoList, defaultRepos).either match {
726+
private[mill] def reposFromStrings(repoList: Seq[String]): Result[Seq[Repository]] = {
727+
RepositoryParser.repositories(repoList).either match {
751728
case Left(errs) =>
752729
val msg =
753730
s"Invalid repository string:" + System.lineSeparator() +

core/util/src/mill/util/MillModuleUtil.scala

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,40 @@
11
package mill.util
22

3+
import coursier.Repository
4+
import mill.api.{BuildInfo, Result}
5+
import mill.define.PathRef
6+
37
import java.nio.file.{Files, Paths}
48

59
private[mill] object MillModuleUtil {
610

11+
/**
12+
* Deprecated helper method, intended to allow runtime resolution and in-development-tree testings of mill plugins possible.
13+
* This design has issues and will probably be replaced.
14+
*/
15+
@deprecated("Use Dep.millProjectModule instead", "Mill 0.13.0-M1")
16+
private[mill] def millProjectModule(
17+
artifact: String,
18+
repositories: Seq[Repository],
19+
// this should correspond to the mill runtime Scala version
20+
artifactSuffix: String = "_3"
21+
): Result[Seq[PathRef]] = {
22+
23+
mill.util.Jvm.resolveDependencies(
24+
repositories = repositories,
25+
deps = Seq(
26+
coursier.Dependency(
27+
coursier.Module(
28+
coursier.Organization("com.lihaoyi"),
29+
coursier.ModuleName(artifact + artifactSuffix)
30+
),
31+
coursier.VersionConstraint(BuildInfo.millVersion)
32+
)
33+
),
34+
force = Nil
35+
).map(_.map(_.withRevalidateOnce))
36+
}
37+
738
private val LongMillProps = new java.util.Properties()
839

940
{

integration/bootstrap/no-java-bootstrap/src/NoJavaBootstrapTests.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ object NoJavaBootstrapTests extends UtestIntegrationTestSuite {
1919
val cache = FileCache()
2020
val index = JvmIndex.load(
2121
cache = cache,
22-
repositories = Resolve.defaultRepositories,
22+
repositories = Resolve().repositories,
2323
indexChannel = JvmChannel.module(
2424
JvmChannel.centralModule(),
2525
version = mill.api.BuildInfo.coursierJvmIndexVersion

integration/feature/cs-env-vars/resources/build.mill

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

integration/feature/cs-env-vars/src/CsEnvVarsTests.scala

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

integration/ide/gen-idea/resources/extended/idea/mill_modules/mill-build.iml

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,22 @@
1212
<orderEntry type="sourceFolder" forTests="false"/>
1313
<orderEntry type="library" name="scala-SDK-3.7.1" level="project"/>
1414
<orderEntry type="library" scope="RUNTIME" name="aircompressor-0.27.jar" level="project"/>
15-
<orderEntry type="library" scope="RUNTIME" name="cache-util-2.1.25-M14.jar" level="project"/>
15+
<orderEntry type="library" scope="RUNTIME" name="cache-util-2.1.25-M13.jar" level="project"/>
1616
<orderEntry type="library" name="common_2.13-4.13.4.jar" level="project"/>
1717
<orderEntry type="library" scope="RUNTIME" name="commons-codec-1.17.0.jar" level="project"/>
1818
<orderEntry type="library" scope="RUNTIME" name="commons-compress-1.26.2.jar" level="project"/>
1919
<orderEntry type="library" scope="RUNTIME" name="commons-io-2.18.0.jar" level="project"/>
2020
<orderEntry type="library" scope="RUNTIME" name="commons-lang3-3.14.0.jar" level="project"/>
2121
<orderEntry type="library" scope="RUNTIME" name="concurrent-reference-hash-map-1.1.0.jar" level="project"/>
22-
<orderEntry type="library" scope="RUNTIME" name="config_3-1.8.0.jar" level="project"/>
23-
<orderEntry type="library" name="coursier-cache_2.13-2.1.25-M14.jar" level="project"/>
24-
<orderEntry type="library" name="coursier-core_2.13-2.1.25-M14.jar" level="project"/>
25-
<orderEntry type="library" scope="RUNTIME" name="coursier-env_2.13-2.1.25-M14.jar" level="project"/>
26-
<orderEntry type="library" scope="RUNTIME" name="coursier-exec-2.1.25-M14.jar" level="project"/>
27-
<orderEntry type="library" name="coursier-jvm_2.13-2.1.25-M14.jar" level="project"/>
28-
<orderEntry type="library" scope="RUNTIME" name="coursier-proxy-setup-2.1.25-M14.jar" level="project"/>
29-
<orderEntry type="library" name="coursier-util_2.13-2.1.25-M14.jar" level="project"/>
30-
<orderEntry type="library" name="coursier_2.13-2.1.25-M14.jar" level="project"/>
22+
<orderEntry type="library" scope="RUNTIME" name="config_2.13-1.1.3.jar" level="project"/>
23+
<orderEntry type="library" name="coursier-cache_2.13-2.1.25-M13.jar" level="project"/>
24+
<orderEntry type="library" name="coursier-core_2.13-2.1.25-M13.jar" level="project"/>
25+
<orderEntry type="library" scope="RUNTIME" name="coursier-env_2.13-2.1.25-M13.jar" level="project"/>
26+
<orderEntry type="library" scope="RUNTIME" name="coursier-exec-2.1.25-M13.jar" level="project"/>
27+
<orderEntry type="library" name="coursier-jvm_2.13-2.1.25-M13.jar" level="project"/>
28+
<orderEntry type="library" scope="RUNTIME" name="coursier-proxy-setup-2.1.25-M13.jar" level="project"/>
29+
<orderEntry type="library" name="coursier-util_2.13-2.1.25-M13.jar" level="project"/>
30+
<orderEntry type="library" name="coursier_2.13-2.1.25-M13.jar" level="project"/>
3131
<orderEntry type="library" scope="RUNTIME" name="dependency_2.13-0.3.2.jar" level="project"/>
3232
<orderEntry type="library" name="fansi_3-0.5.0.jar" level="project"/>
3333
<orderEntry type="library" name="fastparse_3-3.1.1.jar" level="project"/>
@@ -48,7 +48,6 @@
4848
<orderEntry type="library" name="jna-5.13.0.jar" level="project"/>
4949
<orderEntry type="library" scope="RUNTIME" name="jna-5.17.0.jar" level="project"/>
5050
<orderEntry type="library" scope="RUNTIME" name="jsoniter-scala-core_2.13-2.13.39.jar" level="project"/>
51-
<orderEntry type="library" scope="RUNTIME" name="jsoniter-scala-core_3-2.13.5.2.jar" level="project"/>
5251
<orderEntry type="library" scope="RUNTIME" name="jsr305-3.0.2.jar" level="project"/>
5352
<orderEntry type="library" scope="RUNTIME" name="jul-to-slf4j-1.7.30.jar" level="project"/>
5453
<orderEntry type="library" name="junit-4.13.2.jar" level="project"/>
@@ -105,8 +104,8 @@
105104
<orderEntry type="library" scope="PROVIDED" name="scala-library-2.13.12.jar" level="project"/>
106105
<orderEntry type="library" name="scala-library-2.13.16.jar" level="project"/>
107106
<orderEntry type="library" name="scala-reflect-2.13.15.jar" level="project"/>
108-
<orderEntry type="library" scope="RUNTIME" name="scala-xml_2.13-2.4.0.jar" level="project"/>
109-
<orderEntry type="library" name="scala-xml_3-2.4.0.jar" level="project"/>
107+
<orderEntry type="library" scope="RUNTIME" name="scala-xml_2.13-2.3.0.jar" level="project"/>
108+
<orderEntry type="library" name="scala-xml_3-2.3.0.jar" level="project"/>
110109
<orderEntry type="library" scope="PROVIDED" name="scala3-library_3-3.3.3.jar" level="project"/>
111110
<orderEntry type="library" name="scala3-library_3-3.7.1.jar" level="project"/>
112111
<orderEntry type="library" name="scalameta_2.13-4.13.4.jar" level="project"/>
@@ -120,7 +119,7 @@
120119
<orderEntry type="library" scope="RUNTIME" name="sonatype-central-client-upickle_3-0.3.0.jar" level="project"/>
121120
<orderEntry type="library" name="sourcecode_2.13-0.4.2.jar" level="project"/>
122121
<orderEntry type="library" name="sourcecode_3-0.4.3-M5.jar" level="project"/>
123-
<orderEntry type="library" scope="RUNTIME" name="specification-level_3-1.8.0.jar" level="project"/>
122+
<orderEntry type="library" scope="RUNTIME" name="specification-level_2.13-1.1.3.jar" level="project"/>
124123
<orderEntry type="library" name="test-interface-1.0.jar" level="project"/>
125124
<orderEntry type="library" scope="RUNTIME" name="tika-core-3.1.0.jar" level="project"/>
126125
<orderEntry type="library" name="trees_2.13-4.13.4.jar" level="project"/>

0 commit comments

Comments
 (0)