|
14 | 14 | * limitations under the License.
|
15 | 15 | */
|
16 | 16 |
|
17 |
| -import androidx.build.AndroidXComposePlugin |
18 | 17 | import androidx.build.LibraryType
|
19 | 18 | import androidx.build.Publish
|
20 |
| -import org.jetbrains.kotlin.gradle.tasks.KotlinCompile |
21 | 19 |
|
22 | 20 | plugins {
|
23 | 21 | id("AndroidXPlugin")
|
24 | 22 | id("com.android.library")
|
25 | 23 | id("AndroidXComposePlugin")
|
26 | 24 | }
|
27 | 25 |
|
28 |
| -AndroidXComposePlugin.applyAndConfigureKotlinPlugin(project) |
29 |
| - |
30 |
| -dependencies { |
31 |
| - |
32 |
| - if(!AndroidXComposePlugin.isMultiplatformEnabled(project)) { |
33 |
| - /* |
34 |
| - * When updating dependencies, make sure to make the an an analogous update in the |
35 |
| - * corresponding block below |
36 |
| - */ |
37 |
| - |
38 |
| - api("androidx.activity:activity:1.2.0") |
39 |
| - api(projectOrArtifact(":compose:ui:ui-test-junit4")) |
40 |
| - api(project(":test:screenshot:screenshot")) |
41 |
| - |
42 |
| - implementation(libs.kotlinStdlibCommon) |
43 |
| - implementation(projectOrArtifact(":compose:runtime:runtime")) |
44 |
| - implementation(projectOrArtifact(":compose:ui:ui-unit")) |
45 |
| - implementation(projectOrArtifact(":compose:ui:ui-graphics")) |
46 |
| - implementation("androidx.activity:activity-compose:1.3.1") |
47 |
| - // old version of common-java8 conflicts with newer version, because both have |
48 |
| - // DefaultLifecycleEventObserver. |
49 |
| - // Outside of androidx this is resolved via constraint added to lifecycle-common, |
50 |
| - // but it doesn't work in androidx. |
51 |
| - // See aosp/1804059 |
52 |
| - implementation("androidx.lifecycle:lifecycle-common-java8:2.5.1") |
53 |
| - implementation(libs.testCore) |
54 |
| - implementation(libs.testRules) |
55 |
| - |
56 |
| - // This has stub APIs for access to legacy Android APIs, so we don't want |
57 |
| - // any dependency on this module. |
58 |
| - compileOnly(projectOrArtifact(":compose:ui:ui-android-stubs")) |
59 |
| - |
60 |
| - testImplementation(libs.truth) |
61 |
| - |
62 |
| - androidTestImplementation(libs.truth) |
63 |
| - androidTestImplementation(projectOrArtifact(":compose:material:material")) |
64 |
| - } |
65 |
| -} |
| 26 | +def desktopEnabled = false // b/276387374 TODO: KmpPlatformsKt.enableDesktop(project) |
66 | 27 |
|
67 |
| -if (AndroidXComposePlugin.isMultiplatformEnabled(project)) { |
68 |
| - androidXComposeMultiplatform { |
69 |
| - android() |
70 |
| - } |
| 28 | +androidXMultiplatform { |
| 29 | + android() |
| 30 | + if (desktopEnabled) desktop() |
71 | 31 |
|
72 |
| - kotlin { |
73 |
| - /* |
74 |
| - * When updating dependencies, make sure to make the an an analogous update in the |
75 |
| - * corresponding block above |
76 |
| - */ |
77 |
| - sourceSets { |
78 |
| - commonMain.dependencies { |
| 32 | + sourceSets { |
| 33 | + commonMain { |
| 34 | + dependencies { |
79 | 35 | implementation(libs.kotlinStdlibCommon)
|
80 | 36 | implementation(projectOrArtifact(":compose:runtime:runtime"))
|
81 | 37 | implementation(projectOrArtifact(":compose:ui:ui-unit"))
|
82 | 38 | implementation(projectOrArtifact(":compose:ui:ui-graphics"))
|
83 | 39 | implementation(projectOrArtifact(":compose:ui:ui-test-junit4"))
|
84 | 40 | }
|
| 41 | + } |
| 42 | + androidMain.dependencies { |
| 43 | + api("androidx.activity:activity:1.2.0") |
| 44 | + implementation "androidx.activity:activity-compose:1.3.1" |
| 45 | + api(projectOrArtifact(":compose:ui:ui-test-junit4")) |
| 46 | + api(project(":test:screenshot:screenshot")) |
| 47 | + // This has stub APIs for access to legacy Android APIs, so we don't want |
| 48 | + // any dependency on this module. |
| 49 | + compileOnly(projectOrArtifact(":compose:ui:ui-android-stubs")) |
| 50 | + implementation(libs.testCore) |
| 51 | + implementation(libs.testRules) |
| 52 | + } |
85 | 53 |
|
86 |
| - androidMain.dependencies { |
87 |
| - api("androidx.activity:activity:1.2.0") |
88 |
| - implementation "androidx.activity:activity-compose:1.3.1" |
89 |
| - api(projectOrArtifact(":compose:ui:ui-test-junit4")) |
90 |
| - api(project(":test:screenshot:screenshot")) |
91 |
| - // This has stub APIs for access to legacy Android APIs, so we don't want |
92 |
| - // any dependency on this module. |
93 |
| - compileOnly(projectOrArtifact(":compose:ui:ui-android-stubs")) |
94 |
| - implementation(libs.testCore) |
95 |
| - implementation(libs.testRules) |
| 54 | + commonTest { |
| 55 | + dependencies { |
96 | 56 | }
|
| 57 | + } |
97 | 58 |
|
98 |
| - // TODO(b/214407011): These dependencies leak into instrumented tests as well. If you |
99 |
| - // need to add Robolectric (which must be kept out of androidAndroidTest), use a top |
100 |
| - // level dependencies block instead: |
101 |
| - // `dependencies { testImplementation(libs.robolectric) }` |
102 |
| - androidTest.dependencies { |
103 |
| - implementation(libs.truth) |
| 59 | + jvmMain { |
| 60 | + dependsOn(commonMain) |
| 61 | + dependencies { |
104 | 62 | }
|
| 63 | + } |
| 64 | + |
| 65 | + |
| 66 | + androidMain { |
| 67 | + dependsOn(jvmMain) |
| 68 | + dependencies { |
| 69 | + } |
| 70 | + } |
105 | 71 |
|
106 |
| - androidAndroidTest.dependencies { |
| 72 | + if (desktopEnabled) { |
| 73 | + desktopMain { |
| 74 | + dependsOn(jvmMain) |
| 75 | + dependencies { |
| 76 | + } |
| 77 | + } |
| 78 | + } |
| 79 | + |
| 80 | + jvmTest { |
| 81 | + dependsOn(commonTest) |
| 82 | + dependencies { |
| 83 | + } |
| 84 | + } |
| 85 | + |
| 86 | + androidAndroidTest { |
| 87 | + dependsOn(jvmTest) |
| 88 | + dependencies { |
107 | 89 | implementation(libs.truth)
|
108 | 90 | implementation(projectOrArtifact(":compose:material:material"))
|
109 | 91 | }
|
110 | 92 | }
|
| 93 | + |
| 94 | + // TODO(b/214407011): These dependencies leak into instrumented tests as well. If you |
| 95 | + // need to add Robolectric (which must be kept out of androidAndroidTest), use a top |
| 96 | + // level dependencies block instead: |
| 97 | + // `dependencies { testImplementation(libs.robolectric) }` |
| 98 | + androidTest { |
| 99 | + dependsOn(jvmTest) |
| 100 | + dependencies { |
| 101 | + implementation(libs.truth) |
| 102 | + } |
| 103 | + } |
| 104 | + |
| 105 | + if (desktopEnabled) { |
| 106 | + desktopTest { |
| 107 | + dependsOn(jvmTest) |
| 108 | + dependsOn(desktopMain) |
| 109 | + dependencies { |
| 110 | + } |
| 111 | + } |
| 112 | + } |
111 | 113 | }
|
112 | 114 | }
|
113 | 115 |
|
|
0 commit comments