8000 Remove CoursierModule#mapDependencies by alexarchambault · Pull Request #5070 · com-lihaoyi/mill · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Remove CoursierModule#mapDependencies #5070

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
22 changes: 8 additions & 14 deletions build.mill
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ object Deps {
val bloopConfig = mvn"ch.epfl.scala::bloop-config:1.5.5".withDottyCompat(scalaVersion)

val classgraph = mvn"io.github.classgraph:classgraph:4.8.179"
val coursierVersion = "2.1.25-M11"
val coursierVersion = "2.1.25-M12"
val coursier = mvn"io.get-coursier::coursier:$coursierVersion".withDottyCompat(scalaVersion)
val coursierInterface = mvn"io.get-coursier:interface:1.0.29-M1"
val coursierJvm =
Expand Down Expand Up @@ -456,20 +456,14 @@ trait MillJavaModule extends JavaModule {
Seq(MavenRepository("https://oss.sonatype.org/content/repositories/releases"))
}

def mapDependencies: Task[coursier.Dependency => coursier.Dependency] = Task.Anon {
super.mapDependencies().andThen { dep =>
forcedVersions.find(f =>
f.dep.module.organization.value == dep.module.organization.value &&
f.dep.module.name.value == dep.module.name.value
).map { forced =>
val newDep = dep.withVersionConstraint(VersionConstraint(forced.version))
Task.log.debug(
s"Forcing version of ${dep.module} from ${dep.versionConstraint.asString} to ${newDep.versionConstraint.asString}"
)
newDep
}.getOrElse(dep)
}
def resolutionParams: Task[coursier.params.ResolutionParams] = Task.Anon {
super.resolutionParams().addForceVersion0(
forcedVersions.map { f =>
f.dep.module -> VersionConstraint(f.version)
}*
)
}

val forcedVersions: Seq[Dep] = Deps.transitiveDeps ++ Seq(
Deps.jline,
Deps.jna
Expand Down
11 changes: 1 addition & 10 deletions core/util/src/mill/util/Jvm.scala
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,6 @@ object Jvm {
deps: IterableOnce[Dependency],
force: IterableOnce[Dependency] = Nil,
sources: Boolean = false,
mapDependencies: Option[Dependency => Dependency] = None,
customizer: Option[Resolution => Resolution] = None,
ctx: Option[mill.define.TaskCtx] = None,
coursierCacheCustomizer: Option[FileCache[Task] => FileCache[Task]] = None,
Expand All @@ -511,7 +510,6 @@ object Jvm {
repositories,
deps,
force,
mapDependencies,
customizer,
ctx,
coursierCacheCustomizer,
Expand Down Expand Up @@ -557,7 +555,6 @@ object Jvm {
deps: IterableOnce[Dependency],
force: IterableOnce[Dependency],
sources: Boolean = false,
mapDependencies: Option[Dependency => Dependency] = None,
customizer: Option[Resolution => Resolution] = None,
ctx: Option[mill.define.TaskCtx] = None,
coursierCacheCustomizer: Option[FileCache[Task] => FileCache[Task]] = None,
Expand All @@ -569,7 +566,6 @@ object Jvm {
deps,
force,
sources,
mapDependencies,
customizer,
ctx,
coursierCacheCustomizer,
Expand Down Expand Up @@ -656,20 +652,16 @@ object Jvm {
repositories: Seq[Repository],
deps: IterableOnce[Dependency],
force: IterableOnce[Dependency],
mapDependencies: Option[Dependency => Dependency] = None,
customizer: Option[Resolution => Resolution] = None,
ctx: Option[mill.define.TaskCtx] = None,
coursierCacheCustomizer: Option[FileCache[Task] => FileCache[Task]] = None,
resolutionParams: ResolutionParams = ResolutionParams(),
boms: IterableOnce[BomDependency] = Nil
): Result[Resolution] = {

val rootDeps = deps.iterator
.map(d => mapDependencies.fold(d)(_.apply(d)))
.toSeq
val rootDeps = deps.iterator.toSeq

val forceVersions = force.iterator
.map(mapDependencies.getOrElse(identity[Dependency](_)))
.map { d => d.module -> d.version }
.toMap

Expand Down Expand Up @@ -701,7 +693,6 @@ object Jvm {
.withDependencies(rootDeps)
.withRepositories(Seq(resourceTestOverridesRepo) ++ envTestOverridesRepo ++ repositories)
.withResolutionParams(resolutionParams0)
.withMapDependenciesOpt(mapDependencies)
.withBoms(boms.iterator.toSeq)

resolve.either() match {
Expand Down
25 changes: 12 additions & 13 deletions example/androidlib/kotlin/2-compose/build.mill
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,19 @@ object app extends AndroidAppKotlinModule {
)

// This is a temporary fix
def mapDependencies: Task[coursier.Dependency => coursier.Dependency] = Task.Anon {
super.mapDependencies().andThen { (d: coursier.Dependency) =>
// otherwise there are some resolution problems (version conflicts), because Coursier is using pom files only,
// but Gradle is working with .module files if available
if (d.module.organization.value == "androidx.collection") {
d.withVersion("1.4.4")
} else if (d.module.organization.value == "androidx.lifecycle") {
d.withVersion("2.8.3")
} else if (d.module.organization.value == "androidx.compose.runtime") {
d.withVersion("1.7.5")
} else {
d
}
def resolutionParams: Task[coursier.params.ResolutionParams] = Task.Anon {
// otherwise there are some resolution problems (version conflicts), because Coursier is using pom files only,
// but Gradle is working with .module files if available
def forOrg(org: String, ver: String) = {
val mod = coursier.Module(coursier.Organization(org), coursier.ModuleName("*"), Map.empty)
val constraint = coursier.version.VersionConstraint(ver)
(mod, constraint)
}
super.resolutionParams().addForceVersion0(
forOrg("androidx.collection", "1.4.4"),
forOrg("androidx.lifecycle", "2.8.3"),
forOrg("androidx.compose.runtime", "1.7.5")
)
}
}

Expand Down
41 changes: 28 additions & 13 deletions example/androidlib/kotlin/3-compose-screenshot-tests/build.mill
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,19 @@ object app extends AndroidAppKotlinModule {
)

// This is a temporary fix
def mapDependencies: Task[coursier.Dependency => coursier.Dependency] = Task.Anon {
super.mapDependencies().andThen { (d: coursier.Dependency) =>
// otherwise there are some resolution problems (version conflicts), because Coursier is using pom files only,
// but Gradle is working with .module files if available
if (d.module.organization.value == "androidx.collection") {
d.withVersion("1.4.4")
} else if (d.module.organization.value == "androidx.lifecycle") {
d.withVersion("2.8.3")
} else if (d.module.organization.value == "androidx.compose.runtime") {
d.withVersion("1.7.5")
} else {
d
}
def resolutionParams: Task[coursier.params.ResolutionParams] = Task.Anon {
// otherwise there are some resolution problems (version conflicts), because Coursier is using pom files only,
// but Gradle is working with .module files if available
def forOrg(org: String, ver: String) = {
val mod = coursier.Module(coursier.Organization(org), coursier.ModuleName("*"), Map.empty)
val constraint = coursier.version.VersionConstraint(ver)
(mod, constraint)
}
super.resolutionParams().addForceVersion0(
forOrg("androidx.collection", "1.4.4"),
forOrg("androidx.lifecycle", "2.8.3"),
forOrg("androidx.compose.runtime", "1.7.5")
)
}

object screenshotTest extends AndroidAppKotlinScreenshotTests {
Expand All @@ -61,6 +60,22 @@ object app extends AndroidAppKotlinModule {
override def androidScreenshotTestMethods: Seq[(String, Seq[String])] = Seq(
"com.example.screenshottest.ExampleMessageCardScreenshots.oMessageCardScreenshot" -> Seq.empty
)

// This is a temporary fix
def resolutionParams: Task[coursier.params.ResolutionParams] = Task.Anon {
// otherwise there are some resolution problems (version conflicts), because Coursier is using pom files only,
// but Gradle is working with .module files if available
def forOrg(org: String, ver: String) = {
val mod = coursier.Module(coursier.Organization(org), coursier.ModuleName("*"), Map.empty)
val constraint = coursier.version.VersionConstraint(ver)
(mod, constraint)
}
super.resolutionParams().addForceVersion0(
forOrg("androidx.collection", "1.4.4"),
forOrg("androidx.lifecycle", "2.8.3"),
forOrg("androidx.compose.runtime", "1.7.5")
)
}
}
}

Expand Down
38 changes: 20 additions & 18 deletions example/thirdparty/androidtodo/build.mill
Original file line number Diff line number Diff line change
Expand Up @@ -83,26 +83,28 @@ object app extends AndroidAppKotlinModule with AndroidBuildConfig with AndroidHi
)
}

private val dependencyPinning = Map(
"android.collection" -> "1.4.4",
"androidx.lifecycle" -> "2.8.7",
"androidx.compose.runtime" -> "1.7.6",
"androidx.compose.material" -> "1.7.6",
"androidx.compose.ui" -> "1.7.6",
"androidx.appcompat" -> "1.7.0",
"androidx.emoji2" -> "1.3.0",
"androidx.activity" -> "1.10.0",
"androidx.compose.foundation" -> "1.7.6",
"androidx.compose.animation" -> "1.7.6",
"androidx.collection" -> "1.4.2"
)
// This is a temporary fix
def mapDependencies: Task[coursier.Dependency => coursier.Dependency] = Task.Anon {
super.mapDependencies().andThen { (d: coursier.Dependency) =>
// otherwise there are some resolution problems (version conflicts), because Coursier is using pom files only,
// but Gradle is working with .module files if available
dependencyPinning.get(d.module.organization.value).map(d.withVersion).getOrElse(d)
def resolutionParams: Task[coursier.params.ResolutionParams] = Task.Anon {
// otherwise there are some resolution problems (version conflicts), because Coursier is using pom files only,
// but Gradle is working with .module files if available
def forOrg(org: String, ver: String) = {
val mod = coursier.Module(coursier.Organization(org), coursier.ModuleName("*"), Map.empty)
val constraint = coursier.version.VersionConstraint(ver)
(mod, constraint)
}
super.resolutionParams().addForceVersion0(
forOrg("androidx.collection", "1.4.4"),
forOrg("androidx.lifecycle", "2.8.7"),
forOrg("androidx.compose.runtime", "1.7.6"),
forOrg("androidx.compose.material", "1.7.6"),
forOrg("androidx.compose.ui", "1.7.6"),
forOrg("androidx.appcompat", "1.7.0"),
forOrg("androidx.emoji2", "1.3.0"),
forOrg("androidx.activity", "1.10.0"),
forOrg("androidx.compose.foundation", "1.7.6"),
forOrg("androidx.compose.animation", "1.7.6"),
forOrg("androidx.collection", "1.4.2")
)
}

object test extends AndroidAppKotlinTests with TestModule.Junit4 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@
<orderEntry type="sourceFolder" forTests="false"/>
<orderEntry type="library" name="scala-SDK-3.6.4" level="project"/>
<orderEntry type="library" name="aircompressor-0.27.jar" level="project"/>
<orderEntry type="library" name="cache-util-2.1.25-M11.jar" level="project"/>
<orderEntry type="library" name="cache-util-2.1.25-M12.jar" level="project"/>
<orderEntry type="library" name="commons-codec-1.17.0.jar" level="project"/>
<orderEntry type="library" name="commons-compress-1.26.2.jar" level="project"/>
<orderEntry type="library" name="commons-io-2.18.0.jar" level="project"/>
<orderEntry type="library" name="commons-lang3-3.14.0.jar" level="project"/>
<orderEntry type="library" name="concurrent-reference-hash-map-1.1.0.jar" level="project"/>
<orderEntry type="library" name="config_2.13-1.1.3.jar" level="project"/>
<orderEntry type="library" name="coursier-cache_2.13-2.1.25-M11.jar" level="project"/>
<orderEntry type="library" name="coursier-core_2.13-2.1.25-M11.jar" level="project"/>
<orderEntry type="library" name="coursier-env_2.13-2.1.25-M11.jar" level="project"/>
<orderEntry type="library" name="coursier-exec-2.1.25-M11.jar" level="project"/>
<orderEntry type="library" name="coursier-jvm_2.13-2.1.25-M11.jar" level="project"/>
<orderEntry type="library" name="coursier-proxy-setup-2.1.25-M11.jar" level="project"/>
<orderEntry type="library" name="coursier-util_2.13-2.1.25-M11.jar" level="project"/>
<orderEntry type="library" name="coursier_2.13-2.1.25-M11.jar" level="project"/>
<orderEntry type="library" name="coursier-cache_2.13-2.1.25-M12.jar" level="project"/>
<orderEntry type="library" name="coursier-core_2.13-2.1.25-M12.jar" level="project"/>
<orderEntry type="library" name="coursier-env_2.13-2.1.25-M12.jar" level="project"/>
<orderEntry type="library" name="coursier-exec-2.1.25-M12.jar" level="project"/>
<orderEntry type="library" name="coursier-jvm_2.13-2.1.25-M12.jar" level="project"/>
<orderEntry type="library" name="coursier-proxy-setup-2.1.25-M12.jar" level="project"/>
<orderEntry type="library" name="coursier-util_2.13-2.1.25-M12.jar" level="project"/>
<orderEntry type="library" name="coursier_2.13-2.1.25-M12.jar" level="project"/>
<orderEntry type="library" name="dependency_2.13-0.3.2.jar" level="project"/>
<orderEntry type="library" name="fansi_3-0.5.0.jar" level="project"/>
<orderEntry type="library" name="fastparse_3-3.1.1.jar" level="project"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,21 @@
<orderEntry type="library" name="aircompressor-0.27.jar" level="project"/>
<orderEntry type="library" name="asm-9.8.jar" level="project"/>
<orderEntry type="library" name="asm-tree-9.8.jar" level="project"/>
<orderEntry type="library" name="cache-util-2.1.25-M11.jar" level="project"/>
<orderEntry type="library" name="cache-util-2.1.25-M12.jar" level="project"/>
<orderEntry type="library" name="commons-codec-1.17.0.jar" level="project"/>
<orderEntry type="library" name="commons-compress-1.26.2.jar" level="project"/>
<orderEntry type="library" name="commons-io-2.18.0.jar" level="project"/>
<orderEntry type="library" name="commons-lang3-3.14.0.jar" level="project"/>
<orderEntry type="library" name="concurrent-reference-hash-map-1.1.0.jar" level="project"/>
<orderEntry type="library" name="config_2.13-1.1.3.jar" level="project"/>
<orderEntry type="library" name="coursier-cache_2.13-2.1.25-M11.jar" level="project"/>
<orderEntry type="library" name="coursier-core_2.13-2.1.25-M11.jar" level="project"/>
<orderEntry type="library" name="coursier-env_2.13-2.1.25-M11.jar" level="project"/>
<orderEntry type="library" name="coursier-exec-2.1.25-M11.jar" level="project"/>
<orderEntry type="library" name="coursier-jvm_2.13-2.1.25-M11.jar" level="project"/>
<orderEntry type="library" name="coursier-proxy-setup-2.1.25-M11.jar" level="project"/>
<orderEntry type="library" name="coursier-util_2.13-2.1.25-M11.jar" level="project"/>
<orderEntry type="library" name="coursier_2.13-2.1.25-M11.jar" level="project"/>
<orderEntry type="library" name="coursier-cache_2.13-2.1.25-M12.jar" level="project"/>
<orderEntry type="library" name="coursier-core_2.13-2.1.25-M12.jar" level="project"/>
<orderEntry type="library" name="coursier-env_2.13-2.1.25-M12.jar" level="project"/>
<orderEntry type="library" name="coursier-exec-2.1.25-M12.jar" level="project"/>
<orderEntry type="library" name="coursier-jvm_2.13-2.1.25-M12.jar" level="project"/>
<orderEntry type="library" name="coursier-proxy-setup-2.1.25-M12.jar" level="project"/>
<orderEntry type="library" name="coursier-util_2.13-2.1.25-M12.jar" level="project"/>
<orderEntry type="library" name="coursier_2.13-2.1.25-M12.jar" level="project"/>
<orderEntry type="library" name="dependency_2.13-0.3.2.jar" level="project"/>
<orderEntry type="library" name="fansi_3-0.5.0.jar" level="project"/>
<orderEntry type="library" name="fastparse_3-3.1.1.jar" level="project"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@
<orderEntry type="sourceFolder" forTests="false"/>
<orderEntry type="library" name="scala-SDK-3.6.4" level="project"/>
<orderEntry type="library" name="aircompressor-0.27.jar" level="project"/>
<orderEntry type="library" name="cache-util-2.1.25-M11.jar" level="project"/>
<orderEntry type="library" name="cache-util-2.1.25-M12.jar" level="project"/>
<orderEntry type="library" name="commons-codec-1.17.0.jar" level="project"/>
<orderEntry type="library" name="commons-compress-1.26.2.jar" level="project"/>
<orderEntry type="library" name="commons-io-2.18.0.jar" level="project"/>
<orderEntry type="library" name="commons-lang3-3.14.0.jar" level="project"/>
<orderEntry type="library" name="concurrent-reference-hash-map-1.1.0.jar" level="project"/>
<orderEntry type="library" name="config_2.13-1.1.3.jar" level="project"/>
<orderEntry type="library" name="coursier-cache_2.13-2.1.25-M11.jar" level="project"/>
<orderEntry type="library" name="coursier-core_2.13-2.1.25-M11.jar" level="project"/>
<orderEntry type="library" name="coursier-env_2.13-2.1.25-M11.jar" level="project"/>
<orderEntry type="library" name="coursier-exec-2.1.25-M11.jar" level="project"/>
<orderEntry type="library" name="coursier-jvm_2.13-2.1.25-M11.jar" level="project"/>
<orderEntry type="library" name="coursier-proxy-setup-2.1.25-M11.jar" level="project"/>
<orderEntry type="library" name="coursier-util_2.13-2.1.25-M11.jar" level="project"/>
<orderEntry type="library" name="coursier_2.13-2.1.25-M11.jar" level="project"/>
<orderEntry type="library" name="coursier-cache_2.13-2.1.25-M12.jar" level="project"/>
<orderEntry type="library" name="coursier-core_2.13-2.1.25-M12.jar" level="project"/>
<orderEntry type="library" name="coursier-env_2.13-2.1.25-M12.jar" level="project"/>
<orderEntry type="library" name="coursier-exec-2.1.25-M12.jar" level="project"/>
<orderEntry type="library" name="coursier-jvm_2.13-2.1.25-M12.jar" level="project"/>
<orderEntry type="library" name="coursier-proxy-setup-2.1.25-M12.jar" level="project"/>
<orderEntry type="library" name="coursier-util_2.13-2.1.25-M12.jar" level="project"/>
<orderEntry type="library" name="coursier_2.13-2.1.25-M12.jar" level="project"/>
<orderEntry type="library" name="dependency_2.13-0.3.2.jar" level="project"/>
<orderEntry type="library" name="fansi_3-0.5.0.jar" level="project"/>
<orderEntry type="library" name="fastparse_3-3.1.1.jar" level="project"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@ trait AndroidAppKotlinModule extends AndroidAppModule with AndroidKotlinModule {
/* There are no testclasses for screenshot tests, just the engine running a diff over the images */
override def discoveredTestClasses: T[Seq[String]] = Task { Seq.empty[String] }

override def mapDependencies: Task[Dependency => Dependency] =
Task.Anon(outer.mapDependencies())

override def androidApplicationId: String = outer.androidApplicationId

/**
Expand Down
Loading
Loading
0