Skip to content

Commit dfd138e

Browse files
committed
Android 💚
- compile time added
1 parent 330503e commit dfd138e

17 files changed

Lines changed: 179 additions & 69 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package com.pradyotprakash.annotations
2+
3+
@Target(AnnotationTarget.PROPERTY)
4+
@Retention(AnnotationRetention.RUNTIME)
5+
annotation class JsonElement(val key: String = "")

android/CustomAnnotations/annotations/src/main/java/com/pradyotprakash/annotations/JsonElementCompiler.kt

Lines changed: 0 additions & 5 deletions
This file was deleted.
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
package com.pradyotprakash.annotations
22

33
@Target(AnnotationTarget.CLASS)
4-
@Retention(AnnotationRetention.SOURCE)
54
annotation class JsonSerializableCompiler

android/CustomAnnotations/app/src/main/java/com/pradyotprakash/customannotations/annotations/JsonSerializableRuntime.kt renamed to android/CustomAnnotations/annotations/src/main/java/com/pradyotprakash/annotations/JsonSerializableRuntime.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.pradyotprakash.customannotations.annotations
1+
package com.pradyotprakash.annotations
22

33
@Target(AnnotationTarget.CLASS)
44
@Retention(AnnotationRetention.RUNTIME)

android/CustomAnnotations/app/build.gradle.kts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ android {
4343
}
4444
}
4545

46+
kotlin {
47+
sourceSets.main {
48+
kotlin.srcDir("build/generated/ksp/main/kotlin")
49+
}
50+
}
51+
4652
dependencies {
4753
implementation(libs.androidx.core.ktx)
4854
implementation(libs.androidx.lifecycle.runtime.ktx)
@@ -54,6 +60,8 @@ dependencies {
5460
implementation(libs.androidx.material3)
5561
implementation(kotlin("reflect"))
5662
implementation(project(":annotations"))
63+
implementation(project(":processor"))
64+
ksp(project(":processor"))
5765

5866
testImplementation(libs.junit)
5967

android/CustomAnnotations/app/src/main/java/com/pradyotprakash/customannotations/MainActivity.kt

Lines changed: 44 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,13 @@ import androidx.compose.material3.Text
1111
import androidx.compose.runtime.Composable
1212
import androidx.compose.ui.Modifier
1313
import androidx.compose.ui.tooling.preview.Preview
14-
import com.pradyotprakash.customannotations.data.Car
15-
import com.pradyotprakash.customannotations.data.Person
14+
import androidx.compose.ui.unit.dp
15+
import com.pradyotprakash.customannotations.data.CarRuntime
16+
import com.pradyotprakash.customannotations.data.PersonCompileTime
17+
import com.pradyotprakash.customannotations.data.PersonRuntime
1618
import com.pradyotprakash.customannotations.ui.theme.CustomAnnotationsTheme
1719
import com.pradyotprakash.customannotations.utils.JsonUtil
20+
import com.pradyotprakash.toJson
1821

1922
class MainActivity : ComponentActivity() {
2023
override fun onCreate(savedInstanceState: Bundle?) {
@@ -23,38 +26,66 @@ class MainActivity : ComponentActivity() {
2326
setContent {
2427
CustomAnnotationsTheme {
2528
Scaffold(modifier = Modifier.fillMaxSize()) { innerPadding ->
26-
val person = Person(
27-
firstName = "Pradyot",
28-
lastName = "Prakash",
29+
val personRuntime = PersonRuntime(
30+
firstName = "Compile Time",
31+
lastName = "Last",
2932
cars = listOf(
30-
Car(
33+
CarRuntime(
3134
model = "Tesla Model 3",
3235
licenseNumber = "ABC123",
3336
),
34-
Car(
37+
CarRuntime(
3538
model = "Tesla Model Y",
3639
licenseNumber = "XYZ456",
3740
),
38-
Car(
41+
CarRuntime(
3942
model = "Tesla Model S",
4043
licenseNumber = "LMN789",
4144
),
42-
Car(
45+
CarRuntime(
4346
model = "Tesla Model X",
4447
licenseNumber = "PQR012",
4548
),
46-
Car(
49+
CarRuntime(
4750
model = "Tesla Roadster",
4851
licenseNumber = "DEF345",
4952
),
5053
)
5154
)
5255

53-
val jsonFormat = JsonUtil.toJson(person)
56+
val personCompileTime = PersonCompileTime(
57+
firstName = "Runtime",
58+
lastName = "Last",
59+
cars = listOf(
60+
CarRuntime(
61+
model = "Tesla Model 3",
62+
licenseNumber = "ABC123",
63+
),
64+
CarRuntime(
65+
model = "Tesla Model Y",
66+
licenseNumber = "XYZ456",
67+
),
68+
CarRuntime(
69+
model = "Tesla Model S",
70+
licenseNumber = "LMN789",
71+
),
72+
CarRuntime(
73+
model = "Tesla Model X",
74+
licenseNumber = "PQR012",
75+
),
76+
CarRuntime(
77+
model = "Tesla Roadster",
78+
licenseNumber = "DEF345",
79+
),
80+
)
81+
)
5482

5583
Greeting(
56-
name = jsonFormat,
57-
modifier = Modifier.padding(innerPadding)
84+
name = "Runtime Result:\n${JsonUtil.toJson(personRuntime)} \n\n" +
85+
"Compile Time Result:\n${personCompileTime.toJson()}",
86+
modifier = Modifier
87+
.padding(innerPadding)
88+
.padding(10.dp)
5889
)
5990
}
6091
}

android/CustomAnnotations/app/src/main/java/com/pradyotprakash/customannotations/annotations/JsonElementRuntime.kt

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

android/CustomAnnotations/app/src/main/java/com/pradyotprakash/customannotations/data/Car.kt

Lines changed: 0 additions & 10 deletions
This file was deleted.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package com.pradyotprakash.customannotations.data
2+
3+
import com.pradyotprakash.annotations.JsonElement
4+
import com.pradyotprakash.annotations.JsonSerializableRuntime
5+
6+
@JsonSerializableRuntime
7+
data class CarRuntime(
8+
@JsonElement("model") val model: String,
9+
@JsonElement("license_number") val licenseNumber: String,
10+
)

android/CustomAnnotations/app/src/main/java/com/pradyotprakash/customannotations/data/Person.kt

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

0 commit comments

Comments
 (0)