Skip to content

Commit

Permalink
Annotation processor upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
UnknownJoe796 committed Aug 5, 2024
1 parent ae80715 commit ee577dd
Show file tree
Hide file tree
Showing 71 changed files with 293 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ local.properties
.terraform
/gradle-plugin/gradle/wrapper/gradle-wrapper.jar
/gradle-plugin/gradle/wrapper/gradle-wrapper.properties
.kotlin
78 changes: 78 additions & 0 deletions buildSrc/src/main/kotlin/RockPlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class KiteUiPlugin : Plugin<Project> {
val resourceFolder = project.file("src/commonMain/resources")
inputs.files(resourceFolder)
afterEvaluate {
tasks.findByName("compileCommonMainKotlinMetadata")?.dependsOn(this)

val out = project.file("src/commonMain/kotlin/${ext.packageName.replace(".", "/")}/ResourcesExpect.kt")
outputs.file(out)
Expand Down Expand Up @@ -73,6 +74,7 @@ expect object Resources {
from("src/commonMain/resources")
into("src/jsMain/resources/common")
afterEvaluate {
tasks.findByName("compileKotlinJs")?.dependsOn(this)

val out = project.file("src/jsMain/kotlin/${ext.packageName.replace(".", "/")}/ResourcesActual.kt")
val gitIgnore = project.file("src/jsMain/resources/common/.gitignore")
Expand Down Expand Up @@ -129,6 +131,75 @@ package ${ext.packageName}
$imports
actual object Resources {
$lines
}
""".trimIndent()
)
}
}
}

tasks.create("kiteuiResourcesJvm", Task::class.java).apply {
dependsOn("kiteuiResourcesCommon")
group = "build"
afterEvaluate {
tasks.findByName("compileKotlinJvm")?.dependsOn(this)
val out = project.file("src/jvmMain/kotlin/${ext.packageName.replace(".", "/")}/ResourcesActual.kt")
val gitIgnore = project.file("src/jvmMain/resources/common/.gitignore")
outputs.file(out)
outputs.file(gitIgnore)
val resourceFolder = project.file("src/commonMain/resources")
inputs.files(resourceFolder)
doLast {
var usesBlob = false
gitIgnore.writeText("*\n")
val lines = resourceFolder.resources()
.entries
.sortedBy { it.key }
.joinToString("\n ") {
when (val r = it.value) {
is Resource.Font -> {
val normal = r.normal.entries.joinToString { "${it.key} to \"common/${it.value.relativeFile.toString().replace(File.separatorChar, '/')}\"" }
val italics = r.italics.entries.joinToString { "${it.key} to \"common/${it.value.relativeFile.toString().replace(File.separatorChar, '/')}\"" }
"actual val ${r.name}: Font = Font(cssFontFamilyName = \"${r.name}\", direct = FontDirect(normal = mapOf($normal), italics = mapOf($italics)))"
}

is Resource.Image -> "actual val ${r.name}: ImageResource = ImageResource(\"common/${
r.relativeFile.toString().replace(File.separatorChar, '/')
}\")"

is Resource.Video -> "actual val ${r.name}: VideoResource = VideoResource(\"common/${
r.relativeFile.toString().replace(File.separatorChar, '/')
}\")"

is Resource.Audio -> "actual val ${r.name}: AudioResource = AudioResource(\"common/${
r.relativeFile.toString().replace(File.separatorChar, '/')
}\")"

is Resource.Binary -> { usesBlob = true; "actual suspend fun ${r.name}(): Blob = fetch(\"common/${
r.relativeFile.toString().replace(File.separatorChar, '/')
}\").blob()" }

else -> ""
}
}

val imports = mutableListOf("import com.lightningkite.kiteui.models.*")
.also {
if (usesBlob) {
it.add("import com.lightningkite.kiteui.Blob")
it.add("import com.lightningkite.kiteui.fetch")
}
}
.joinToString("\n")

out.writeText(
"""
package ${ext.packageName}
$imports
actual object Resources {
$lines
}
Expand All @@ -143,6 +214,9 @@ actual object Resources {
group = "build"

afterEvaluate {
tasks.findByName("compileKotlinIosSimulatorArm64")?.dependsOn(this)
tasks.findByName("compileKotlinIosArm64")?.dependsOn(this)
tasks.findByName("compileKotlinIosX64")?.dependsOn(this)
val outKt = project.file("src/iosMain/kotlin/${ext.packageName.replace(".", "/")}/ResourcesActual.kt")
outputs.file(outKt)

Expand Down Expand Up @@ -300,9 +374,12 @@ actual object Resources {
val androidResFolder = project.file("src/androidMain/res")

afterEvaluate {
tasks.findByName("compileReleaseKotlinAndroid")?.dependsOn(this)
tasks.findByName("compileDebugKotlinAndroid")?.dependsOn(this)
val outKt =
project.file("src/androidMain/kotlin/${ext.packageName.replace(".", "/")}/ResourcesActual.kt")
outputs.file(outKt)
// TODO: Manifest for tracking which files are under our control; git-ignore
doLast {
val resources = resourceFolder.resources()
.entries
Expand Down Expand Up @@ -403,6 +480,7 @@ actual object Resources {
dependsOn("kiteuiResourcesJs")
dependsOn("kiteuiResourcesIos")
dependsOn("kiteuiResourcesAndroid")
dependsOn("kiteuiResourcesJvm")
}

tasks.create("kiteuiLocalize").apply {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"data" : [
{
"filename" : "taunt.mp3",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
11 changes: 11 additions & 0 deletions example-app/src/androidMain/res/font/fonts_goldman.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<font-family xmlns:android="http://schemas.android.com/apk/res/android">
<font
android:fontStyle="normal"
android:fontWeight="400"
android:font="@font/fonts_goldman_400_normal" />
<font
android:fontStyle="normal"
android:fontWeight="700"
android:font="@font/fonts_goldman_700_normal" />
</font-family>
Binary file not shown.
Binary file not shown.
Binary file not shown.
19 changes: 19 additions & 0 deletions example-app/src/androidMain/res/font/fonts_montserrat.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<font-family xmlns:android="http://schemas.android.com/apk/res/android">
<font
android:fontStyle="normal"
android:fontWeight="400"
android:font="@font/fonts_montserrat_400_normal" />
<font
android:fontStyle="normal"
android:fontWeight="700"
android:font="@font/fonts_montserrat_700_normal" />
<font
android:fontStyle="italic"
android:fontWeight="400"
android:font="@font/fonts_montserrat_400_italic" />
<font
android:fontStyle="italic"
android:fontWeight="700"
android:font="@font/fonts_montserrat_700_italic" />
</font-family>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
51 changes: 51 additions & 0 deletions example-app/src/androidMain/res/font/fonts_opensans.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="utf-8"?>
<font-family xmlns:android="http://schemas.android.com/apk/res/android">
<font
android:fontStyle="normal"
android:fontWeight="600"
android:font="@font/fonts_opensans_600_normal" />
<font
android:fontStyle="normal"
android:fontWeight="300"
android:font="@font/fonts_opensans_300_normal" />
<font
android:fontStyle="normal"
android:fontWeight="800"
android:font="@font/fonts_opensans_800_normal" />
<font
android:fontStyle="normal"
android:fontWeight="700"
android:font="@font/fonts_opensans_700_normal" />
<font
android:fontStyle="normal"
android:fontWeight="500"
android:font="@font/fonts_opensans_500_normal" />
<font
android:fontStyle="normal"
android:fontWeight="400"
android:font="@font/fonts_opensans_400_normal" />
<font
android:fontStyle="italic"
android:fontWeight="400"
android:font="@font/fonts_opensans_400_italic" />
<font
android:fontStyle="italic"
android:fontWeight="500"
android:font="@font/fonts_opensans_500_italic" />
<font
android:fontStyle="italic"
android:fontWeight="300"
android:font="@font/fonts_opensans_300_italic" />
<font
android:fontStyle="italic"
android:fontWeight="600"
android:font="@font/fonts_opensans_600_italic" />
<font
android:fontStyle="italic"
android:fontWeight="800"
android:font="@font/fonts_opensans_800_italic" />
<font
android:fontStyle="italic"
android:fontWeight="700"
android:font="@font/fonts_opensans_700_italic" />
</font-family>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
27 changes: 27 additions & 0 deletions example-app/src/androidMain/res/font/fonts_roboto.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<font-family xmlns:android="http://schemas.android.com/apk/res/android">
<font
android:fontStyle="normal"
android:fontWeight="300"
android:font="@font/fonts_roboto_300_normal" />
<font
android:fontStyle="normal"
android:fontWeight="400"
android:font="@font/fonts_roboto_400_normal" />
<font
android:fontStyle="normal"
android:fontWeight="700"
android:font="@font/fonts_roboto_700_normal" />
<font
android:fontStyle="italic"
android:fontWeight="400"
android:font="@font/fonts_roboto_400_italic" />
<font
android:fontStyle="italic"
android:fontWeight="300"
android:font="@font/fonts_roboto_300_italic" />
<font
android:fontStyle="italic"
android:fontWeight="700"
android:font="@font/fonts_roboto_700_italic" />
</font-family>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
7 changes: 0 additions & 7 deletions example-app/src/commonTest/kotlin/Sample.kt

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.lightningkite.mppexampleapp

import com.lightningkite.kiteui.models.*

actual object Resources {
actual val audioTaunt: AudioResource = AudioResource("common/audio/taunt.mp3")
actual val fontsGoldman: Font = Font(cssFontFamilyName = "fontsGoldman", direct = FontDirect(normal = "common/fonts/goldman/normal.ttf", bold = "common/fonts/goldman/bold.ttf", italic = null, boldItalic = null))
actual val fontsMontserrat: Font = Font(cssFontFamilyName = "fontsMontserrat", direct = FontDirect(normal = "common/fonts/montserrat/normal.ttf", bold = "common/fonts/montserrat/bold.ttf", italic = "common/fonts/montserrat/italic.ttf", boldItalic = "common/fonts/montserrat/bold-italic.ttf"))
actual val fontsRoboto: Font = Font(cssFontFamilyName = "fontsRoboto", direct = FontDirect(normal = "common/fonts/roboto/normal.ttf", bold = "common/fonts/roboto/bold.ttf", italic = "common/fonts/roboto/italic.ttf", boldItalic = "common/fonts/roboto/bold-italic.ttf"))
actual val fontsRobotoLight: Font = Font(cssFontFamilyName = "fontsRobotoLight", direct = FontDirect(normal = "common/fonts/roboto/light.ttf", bold = null, italic = null, boldItalic = null))
actual val fontsRobotoLightItalic: Font = Font(cssFontFamilyName = "fontsRobotoLightItalic", direct = FontDirect(normal = "common/fonts/roboto/light-Italic.ttf", bold = null, italic = null, boldItalic = null))
actual val imagesMammoth: ImageResource = ImageResource("common/images/Mammoth.png")
actual val imagesSolera: ImageResource = ImageResource("common/images/solera.jpg")
actual val videoBack: VideoResource = VideoResource("common/video/back.mp4")
}
Loading

0 comments on commit ee577dd

Please sign in to comment.