Skip to content

Android/cleanup dependency resolution workarounds #5098

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

10 changes: 2 additions & 8 deletions example/androidlib/java/1-hello-world/build.mill
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,9 @@ object app extends AndroidAppModule {
* resolution resolves conflicts between androidJvm and jvm platform types
*/
def mvnDeps = super.mvnDeps() ++ Seq(
mvn"androidx.test.ext:junit:1.2.1".exclude((
"org.jetbrains.kotlinx",
"kotlinx-coroutines-core-jvm"
)),
mvn"androidx.test.ext:junit:1.2.1",
mvn"androidx.test:runner:1.6.2",
mvn"androidx.test.espresso:espresso-core:3.5.1".exclude((
"org.jetbrains.kotlinx",
"kotlinx-coroutines-core-jvm"
)),
mvn"androidx.test.espresso:espresso-core:3.5.1",
mvn"junit:junit:4.13.2"
)
}
Expand Down
8 changes: 2 additions & 6 deletions example/androidlib/java/5-R8/build.mill
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,9 @@ object app extends AndroidAppModule { // <2>
* resolution resolves conflicts between androidJvm and jvm platform types
*/
def mvnDeps = super.mvnDeps() ++ Seq(
mvn"androidx.test.ext:junit:1.2.1".exclude(
("org.jetbrains.kotlinx", "kotlinx-coroutines-core-jvm")
),
mvn"androidx.test.ext:junit:1.2.1",
mvn"androidx.test:runner:1.6.2",
mvn"androidx.test.espresso:espresso-core:3.5.1".exclude(
("org.jetbrains.kotlinx", "kotlinx-coroutines-core-jvm")
),
mvn"androidx.test.espresso:espresso-core:3.5.1",
mvn"junit:junit:4.13.2"
)
}
Expand Down
8 changes: 2 additions & 6 deletions example/androidlib/java/6-native-libs/build.mill
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,9 @@ object app extends AndroidNativeAppModule { // <1>
* resolution resolves conflicts between androidJvm and jvm platform types
*/
def mvnDeps = super.mvnDeps() ++ Seq(
mvn"androidx.test.ext:junit:1.2.1".exclude(
("org.jetbrains.kotlinx", "kotlinx-coroutines-core-jvm")
),
mvn"androidx.test.ext:junit:1.2.1",
mvn"androidx.test:runner:1.6.2",
mvn"androidx.test.espresso:espresso-core:3.5.1".exclude(
("org.jetbrains.kotlinx", "kotlinx-coroutines-core-jvm")
),
mvn"androidx.test.espresso:espresso-core:3.5.1",
mvn"junit:junit:4.13.2"
)
}
Expand Down
10 changes: 2 additions & 8 deletions example/androidlib/kotlin/1-hello-kotlin/build.mill
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,9 @@ object app extends AndroidAppKotlinModule {
* resolution resolves conflicts between androidJvm and jvm platform types
*/
def mvnDeps = super.mvnDeps() ++ Seq(
mvn"androidx.test.ext:junit:1.2.1".exclude((
"org.jetbrains.kotlinx",
"kotlinx-coroutines-core-jvm"
)),
mvn"androidx.test.ext:junit:1.2.1",
mvn"androidx.test:runner:1.6.2",
mvn"androidx.test.espresso:espresso-core:3.5.1".exclude((
"org.jetbrains.kotlinx",
"kotlinx-coroutines-core-jvm"
)),
mvn"androidx.test.espresso:espresso-core:3.5.1",
mvn"junit:junit:4.13.2"
)
}
Expand Down
58 changes: 39 additions & 19 deletions example/androidlib/kotlin/2-compose/build.mill
Original file line number Diff line number Diff line change
Expand Up @@ -27,34 +27,30 @@ object app extends AndroidAppKotlinModule {
def androidCompileSdk = 35
def androidMinSdk = 26
def androidEnableCompose = true

def androidIsDebug = true

def androidApplicationId = "com.example.composetest"
def androidApplicationNamespace = "com.example.composetest"

def mvnDeps: T[Seq[Dep]] = Seq(
mvn"androidx.core:core-ktx:1.15.0",
mvn"androidx.activity:activity-compose:1.9.3",
mvn"androidx.compose.ui:ui:1.7.5",
mvn"androidx.compose.material3:material3:1.3.1"
mvn"androidx.appcompat:appcompat:1.7.0",
mvn"androidx.annotation:annotation:1.9.1",
mvn"androidx.activity:activity-compose:1.10.0",
mvn"androidx.compose.material3:material3:1.3.1",
mvn"androidx.compose.ui:ui:1.7.6",
mvn"androidx.emoji2:emoji2:1.3.0",
mvn"androidx.compose.ui:ui-graphics:1.7.6",
mvn"androidx.lifecycle:lifecycle-common:2.8.7",
mvn"androidx.lifecycle:lifecycle-process:2.8.7",
mvn"androidx.lifecycle:lifecycle-runtime-compose:2.8.7",
mvn"androidx.lifecycle:lifecycle-viewmodel-compose:2.8.7",
mvn"androidx.lifecycle:lifecycle-viewmodel-ktx:2.8.7",
mvn"androidx.customview:customview-poolingcontainer:1.0.0",
mvn"androidx.tracing:tracing:1.2.0"
)

// 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
}
}
}
}

////SNIPPET:END
Expand All @@ -64,6 +60,30 @@ object app extends AndroidAppKotlinModule {
> ./mill show app.androidApk
".../out/app/androidApk.dest/app.apk"


> ./mill show app.createAndroidVirtualDevice
...Name: test, DeviceId: medium_phone...

> ./mill show app.startAndroidEmulator

> ./mill show app.androidInstall
...All files should be loaded. Notifying the device...

> ./mill show app.androidRun --activity com.example.composetest.MainActivity
[
"Starting: Intent { cmp=com.example.composetest/.MainActivity }",
"Status: ok",
"LaunchState: COLD",
"Activity: com.example.composetest/.MainActivity",
"TotalTime: ...",
"WaitTime: ...",
"Complete"
]

> ./mill show app.stopAndroidEmulator

> ./mill show app.deleteAndroidVirtualDevice

*/

// This command triggers the build process, which installs the necessary build components, compiles the Kotlin
Expand Down
21 changes: 3 additions & 18 deletions example/androidlib/kotlin/3-compose-screenshot-tests/build.mill
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import mill._, androidlib._, kotlinlib._

import coursier.core.{MinimizedExclusions, ModuleName, Organization}
import coursier.params.ResolutionParams

import coursier.core.VariantSelector.VariantMatcher
import coursier.params.ResolutionParams
// Create and configure an Android SDK module to manage Android SDK paths and tools.
object androidSdkModule0 extends AndroidSdkModule {
def buildToolsVersion = "35.0.0"
Expand All @@ -32,29 +33,13 @@ object app extends AndroidAppKotlinModule {
def androidIsDebug = true

def mvnDeps: T[Seq[Dep]] = Seq(
mvn"androidx.appcompat:appcompat:1.7.0",
mvn"androidx.core:core-ktx:1.15.0",
mvn"androidx.activity:activity-compose:1.9.3",
mvn"androidx.compose.ui:ui:1.7.5",
mvn"androidx.compose.material3:material3:1.3.1"
)

// 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
}
}
}

object screenshotTest extends AndroidAppKotlinScreenshotTests {

// TODO this exists until auto discovery of methods is implemented
Expand Down
69 changes: 33 additions & 36 deletions example/thirdparty/androidtodo/build.mill
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ object app extends AndroidAppKotlinModule with AndroidBuildConfig with AndroidHi
def kspVersion = "1.0.28"

def androidApplicationNamespace = "com.example.android.architecture.blueprints.todoapp"
def androidApplicationId = "com.example.android.architecture.blueprints.main"
// TODO change this to com.example.android.architecture.blueprints.main when mill supports build variants
def androidApplicationId = "com.example.android.architecture.blueprints.todoapp"

def androidSdkModule = mill.define.ModuleRef(androidSdkModule0)

Expand All @@ -33,7 +34,6 @@ object app extends AndroidAppKotlinModule with AndroidBuildConfig with AndroidHi
mvn"androidx.core:core-ktx:1.15.0",
mvn"androidx.appcompat:appcompat:1.7.0",
mvn"androidx.annotation:annotation:1.9.1",
mvn"org.jetbrains.kotlinx:kotlinx-coroutines-android:1.9.0",
mvn"com.jakewharton.timber:timber:5.0.1",
mvn"androidx.test.espresso:espresso-idling-resource:3.6.1",
mvn"androidx.room:room-runtime:2.6.1",
Expand All @@ -42,34 +42,30 @@ object app extends AndroidAppKotlinModule with AndroidBuildConfig with AndroidHi
mvn"androidx.activity:activity-compose:1.10.0",
mvn"androidx.compose.foundation:foundation:1.7.6",
mvn"androidx.compose.animation:animation-core:1.7.6",
mvn"androidx.compose.foundation:foundation-android:1.7.6",
mvn"androidx.compose.foundation:foundation-layout:1.7.6",
mvn"androidx.compose.animation:animation:1.7.6",
mvn"androidx.compose.material3:material3:1.3.1",
mvn"androidx.compose.material:material:1.7.6",
mvn"androidx.compose.material:material-android:1.7.6",
mvn"androidx.compose.material:material-icons-core:1.7.6",
mvn"androidx.compose.material:material-ripple-android:1.7.6",
mvn"androidx.compose.material:material-icons-extended:1.7.6",
mvn"androidx.compose.ui:ui-tooling-preview:1.7.6",
mvn"androidx.navigation:navigation-compose:2.8.5",
mvn"androidx.compose.ui:ui:1.7.6",
mvn"androidx.compose.ui:ui-android:1.7.6",
mvn"androidx.compose.ui:ui-unit:1.7.6",
mvn"androidx.compose.ui:ui-text:1.7.6",
mvn"androidx.emoji2:emoji2:1.3.0",
mvn"androidx.compose.ui:ui-graphics:1.7.6",
mvn"androidx.compose.ui:ui:1.7.6",
mvn"androidx.lifecycle:lifecycle-common:2.8.7",
mvn"androidx.lifecycle:lifecycle-process:2.8.7",
mvn"androidx.lifecycle:lifecycle-runtime-compose:2.8.7",
mvn"androidx.lifecycle:lifecycle-viewmodel-compose:2.8.7",
mvn"androidx.lifecycle:lifecycle-viewmodel-compose-android:2.8.7",
mvn"com.google.accompanist:accompanist-appcompat-theme:0.36.0"
.exclude("androix.appcompat" -> "appcompat"),
mvn"androidx.compose.material:material-icons-core-android:1.7.6",
mvn"androidx.lifecycle:lifecycle-viewmodel-ktx:2.8.7",
mvn"com.google.accompanist:accompanist-appcompat-theme:0.36.0",
mvn"com.google.dagger:hilt-android:2.56",
mvn"androidx.hilt:hilt-navigation-compose:1.2.0",
mvn"com.google.accompanist:accompanist-swiperefresh:0.36.0",
mvn"androidx.compose:compose-bom:2024.12.01",
mvn"androidx.customview:customview-poolingcontainer:1.0.0"
mvn"androidx.customview:customview-poolingcontainer:1.0.0",
mvn"androidx.tracing:tracing:1.2.0"
)

def kotlinSymbolProcessors: T[Seq[Dep]] = Seq(
Expand All @@ -83,28 +79,6 @@ 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)
}
}

object test extends AndroidAppKotlinTests with TestModule.Junit4 {
def mvnDeps = super.mvnDeps() ++ Seq(
mvn"junit:junit:4.13.2"
Expand All @@ -119,6 +93,29 @@ object app extends AndroidAppKotlinModule with AndroidBuildConfig with AndroidHi

/** Usage

> ./mill app.androidDex
> ./mill app.androidApk

> ./mill show app.createAndroidVirtualDevice
...Name: test, DeviceId: medium_phone...

> ./mill show app.startAndroidEmulator

> ./mill show app.androidInstall
...All files should be loaded. Notifying the device...

> ./mill show app.androidRun --activity com.example.android.architecture.blueprints.todoapp.TodoActivity
[
"Starting: Intent { cmp=com.example.android.architecture.blueprints.todoapp/.TodoActivity }",
"Status: ok",
"LaunchState: COLD",
"Activity: com.example.android.architecture.blueprints.todoapp/.TodoActivity",
"TotalTime: ...",
"WaitTime: ...",
"Complete"
]

> ./mill show app.stopAndroidEmulator

> ./mill show app.deleteAndroidVirtualDevice

*/
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.7.0" 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-M13.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-M13.jar" level="project"/>
<orderEntry type="library" name="coursier-core_2.13-2.1.25-M13.jar" level="project"/>
<orderEntry type="library" name="coursier-env_2.13-2.1.25-M13.jar" level="project"/>
<orderEntry type="library" name="coursier-exec-2.1.25-M13.jar" level="project"/>
<orderEntry type="library" name="coursier-jvm_2.13-2.1.25-M13.jar" level="project"/>
<orderEntry type="library" name="coursier-proxy-setup-2.1.25-M13.jar" level="project"/>
<orderEntry type="library" name="coursier-util_2.13-2.1.25-M13.jar" level="project"/>
<orderEntry type="library" name="coursier_2.13-2.1.25-M13.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 Expand Up @@ -116,6 +116,6 @@
<orderEntry type="library" name="windows-jni-utils-0.3.3.jar" level="project"/>
<orderEntry type="library" name="xbean-reflect-3.7.jar" level="project"/>
<orderEntry type="library" scope="RUNTIME" name="xz-1.9.jar" level="project"/>
<orderEntry type="library" name="zstd-jni-1.5.7-2.jar" level="project"/>
<orderEntry type="library" name="zstd-jni-1.5.7-3.jar" level="project"/>
</component>
</module>
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-M13.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-M13.jar" level="project"/>
<orderEntry type="library" name="coursier-core_2.13-2.1.25-M13.jar" level="project"/>
<orderEntry type="library" name="coursier-env_2.13-2.1.25-M13.jar" level="project"/>
<orderEntry type="library" name="coursier-exec-2.1.25-M13.jar" level="project"/>
<orderEntry type="library" name="coursier-jvm_2.13-2.1.25-M13.jar" level="project"/>
<orderEntry type="library" name="coursier-proxy-setup-2.1.25-M13.jar" level="project"/>
<orderEntry type="library" name="coursier-util_2.13-2.1.25-M13.jar" level="project"/>
<orderEntry type="library" name="coursier_2.13-2.1.25-M13.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 Expand Up @@ -118,6 +118,6 @@
<orderEntry type="library" name="windows-jni-utils-0.3.3.jar" level="project"/>
<orderEntry type="library" name="xbean-reflect-3.7.jar" level="project"/>
<orderEntry type="library" scope="RUNTIME" name="xz-1.9.jar" level="project"/>
<orderEntry type="library" name="zstd-jni-1.5.7-2.jar" level="project"/>
<orderEntry type="library" name="zstd-jni-1.5.7-3.jar" level="project"/>
</component>
</module>
Loading