Skip to content

Commit 5c57754

Browse files
authored
Distinguish if a package comes from a foreign module (#84)
* Distinguish if a package comes from a foreign module * Fix the compiler testings * Update stability * Add thrid party model example
1 parent 49443ba commit 5c57754

File tree

23 files changed

+417
-267
lines changed

23 files changed

+417
-267
lines changed

app-model/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

app-model/api/app-model.api

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
public final class com/skydoves/myapplication/model/ThirdPartyModel {
2+
public fun <init> (Ljava/lang/String;I)V
3+
public final fun component1 ()Ljava/lang/String;
4+
public final fun component2 ()I
5+
public final fun copy (Ljava/lang/String;I)Lcom/skydoves/myapplication/model/ThirdPartyModel;
6+
public static synthetic fun copy$default (Lcom/skydoves/myapplication/model/ThirdPartyModel;Ljava/lang/String;IILjava/lang/Object;)Lcom/skydoves/myapplication/model/ThirdPartyModel;
7+
public fun equals (Ljava/lang/Object;)Z
8+
public final fun getCount ()I
9+
public final fun getName ()Ljava/lang/String;
10+
public fun hashCode ()I
11+
public fun toString ()Ljava/lang/String;
12+
}
13+
14+
public final class com/skydoves/myapplication/model/ThirdPartyModelStable {
15+
public fun <init> (Ljava/lang/String;I)V
16+
public final fun component1 ()Ljava/lang/String;
17+
public final fun component2 ()I
18+
public final fun copy (Ljava/lang/String;I)Lcom/skydoves/myapplication/model/ThirdPartyModelStable;
19+
public static synthetic fun copy$default (Lcom/skydoves/myapplication/model/ThirdPartyModelStable;Ljava/lang/String;IILjava/lang/Object;)Lcom/skydoves/myapplication/model/ThirdPartyModelStable;
20+
public fun equals (Ljava/lang/Object;)Z
21+
public final fun getCount ()I
22+
public final fun getName ()Ljava/lang/String;
23+
public fun hashCode ()I
24+
public fun toString ()Ljava/lang/String;
25+
}
26+

app-model/build.gradle.kts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Designed and developed by 2025 skydoves (Jaewoong Eum)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
plugins {
17+
alias(libs.plugins.kotlin.jvm)
18+
}
19+
20+
java {
21+
sourceCompatibility = JavaVersion.VERSION_11
22+
targetCompatibility = JavaVersion.VERSION_11
23+
}
24+
25+
dependencies {
26+
compileOnly(libs.androidx.compose.runtime.annotation)
27+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
Designed and developed by 2025 skydoves (Jaewoong Eum)
4+
5+
Licensed under the Apache License, Version 2.0 (the "License");
6+
you may not use this file except in compliance with the License.
7+
You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
-->
17+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
18+
19+
</manifest>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* Designed and developed by 2025 skydoves (Jaewoong Eum)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.skydoves.myapplication.model
17+
18+
import androidx.compose.runtime.Stable
19+
20+
data class ThirdPartyModel(
21+
val name: String,
22+
val count: Int,
23+
)
24+
25+
@Stable
26+
data class ThirdPartyModelStable(
27+
val name: String,
28+
val count: Int,
29+
)

app/build.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ android {
5959
}
6060

6161
dependencies {
62+
implementation(project(":app-model"))
63+
6264
implementation(platform(libs.androidx.compose.bom))
6365
implementation(libs.androidx.activity.compose)
6466
implementation(libs.androidx.compose.ui)

app/src/main/kotlin/com/skydoves/myapplication/MainActivity.kt

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ import androidx.compose.ui.text.style.TextAlign
4747
import androidx.compose.ui.tooling.preview.Preview
4848
import androidx.compose.ui.unit.dp
4949
import androidx.lifecycle.ViewModel
50-
import com.skydoves.compose.stability.runtime.IgnoreStabilityReport
50+
import com.skydoves.myapplication.model.ThirdPartyModel
51+
import com.skydoves.myapplication.model.ThirdPartyModelStable
5152
import com.skydoves.myapplication.models.ImmutableData
5253
import com.skydoves.myapplication.models.MyClass2
5354
import com.skydoves.myapplication.models.NormalClass
@@ -56,7 +57,6 @@ import com.skydoves.myapplication.models.StableSealedClass
5657
import com.skydoves.myapplication.models.StableUser
5758
import com.skydoves.myapplication.models.UnstableUser
5859
import kotlinx.collections.immutable.ImmutableList
59-
import java.lang.StringBuilder
6060

6161
class MainActivity : ComponentActivity() {
6262
override fun onCreate(savedInstanceState: Bundle?) {
@@ -165,6 +165,20 @@ fun StableUserCard(user: StableUser) {
165165
}
166166
}
167167

168+
@Composable
169+
fun ThirdPartyCard(
170+
thirdPartyModel: ThirdPartyModel,
171+
thirdPartyModelStable: ThirdPartyModelStable,
172+
) {
173+
Card {
174+
Column(modifier = Modifier.padding(16.dp)) {
175+
Text("Stable User")
176+
Text("Name: ${thirdPartyModel.name}")
177+
Text("Age: ${thirdPartyModelStable.count}")
178+
}
179+
}
180+
}
181+
168182
@Composable
169183
fun Card(
170184
modifier: Modifier = Modifier,
@@ -366,7 +380,7 @@ fun ActionButton(
366380
* These are only used in Android Studio previews, not in production.
367381
*/
368382
@com.skydoves.compose.stability.runtime.IgnoreStabilityReport
369-
@androidx.compose.ui.tooling.preview.Preview(showBackground = true)
383+
@Preview(showBackground = true)
370384
@Composable
371385
fun StableUserCardPreview() {
372386
StableUserCard(StableUser("Preview User", 25))

app/stability/app.stability

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,14 @@ public fun com.skydoves.myapplication.Test8(items: kotlinx.collections.immutable
211211
params:
212212
- items: STABLE (known stable type)
213213

214+
@Composable
215+
public fun com.skydoves.myapplication.ThirdPartyCard(thirdPartyModel: com.skydoves.myapplication.model.ThirdPartyModel, thirdPartyModelStable: com.skydoves.myapplication.model.ThirdPartyModelStable): kotlin.Unit
216+
skippable: true
217+
restartable: true
218+
params:
219+
- thirdPartyModel: STABLE (class with no mutable properties)
220+
- thirdPartyModelStable: STABLE (marked @Stable or @Immutable)
221+
214222
@Composable
215223
public fun com.skydoves.myapplication.TrackedActionButton(text: kotlin.String, onClick: kotlin.Function0<kotlin.Unit>): kotlin.Unit
216224
skippable: true

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ plugins {
1717
}
1818

1919
apiValidation {
20-
ignoredProjects.addAll(listOf("app"))
20+
ignoredProjects.addAll(listOf("app", "app-model"))
2121
}
2222

2323
subprojects {

compiler-tests/src/test/kotlin/com/skydoves/compose/stability/compiler/tests/StabilityTestConfigurator.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,10 @@ class StabilityTestConfigurator(testServices: TestServices) :
4747

4848
// Register IR generation extension for backend transformations
4949
IrGenerationExtension.registerExtension(
50-
StabilityAnalyzerIrGenerationExtension(""),
50+
StabilityAnalyzerIrGenerationExtension(
51+
stabilityOutputDir = "",
52+
projectDependencies = "",
53+
),
5154
)
5255
}
5356
}

0 commit comments

Comments
 (0)