Skip to content
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

Component generator #65

Open
wants to merge 24 commits into
base: develop
Choose a base branch
from
Open

Conversation

RudolfHladik
Copy link
Collaborator

Add KSP Processor for generating components from ScreenInterface

@matejsemancik matejsemancik changed the base branch from main to develop June 11, 2024 06:57
# Conflicts:
#	iosApp/iosApp/Views/Screen/FirstView.swift
…generator

# Conflicts:
#	gradle/libs.versions.toml
#	gradle/wrapper/gradle-wrapper.properties
@RudolfHladik RudolfHladik requested a review from Syntey June 12, 2024 10:00
RudolfHladik and others added 3 commits June 12, 2024 13:28
Co-authored-by: Matej Semančík <matej.semancik@gmail.com>
Copy link
Member

@matejsemancik matejsemancik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs some ironing out, otherwise, this is a nice idea, wonder what other use-cases can we cover with this.

Comment on lines 15 to 18

// setup for component processor
arg("viewModel", "app.futured.kmptemplate.util.arch.ViewModelComponent")
arg("viewModelExt", "app.futured.kmptemplate.util.ext.viewModel")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this configuration actually relate to Koin, or is it just a shortcut to configure KSP for different thing?

Comment on lines 8 to 15
//internal class LoginComponent(
// componentContext: ComponentContext,
//) : ViewModelComponent<LoginViewModel>(componentContext), LoginScreen {
// override val viewModel: LoginViewModel by viewModel()
// override val viewState: StateFlow<LoginViewState> = viewModel.viewState
// override val actions: LoginScreen.Actions = viewModel
// override val suspendActions: LoginScreen.SuspendActions = viewModel
//}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can probably delete entire file, or just add a comment why this is actually commented out. Might be confusing for user.

Comment on lines +5 to +7
@Target(AnnotationTarget.CLASS)
@Retention(AnnotationRetention.SOURCE)
annotation class Component(val argType: KClass<*> = Unit::class)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we get any documentation? 🥺👉👈

Comment on lines +14 to +16
iosX64()
iosArm64()
iosSimulatorArm64()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please replace with iosTargets() like in rest of the project.

Suggested change
iosX64()
iosArm64()
iosSimulatorArm64()
iosTargets()

Comment on lines +18 to +22
sourceSets {
commonMain {
dependencies { }
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This empty configuration block can be removed

Comment on lines +3 to +5
plugins {
id(libs.plugins.kotlin.multiplatform.get().pluginId)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the processor need multiplatform plugin? I think you should be able to get it working using just jvm plugin?

@@ -0,0 +1,57 @@
package com.rudolfhladik.componentprocessor
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you update package name?


class ComponentProcessor(
private val codeGenerator: CodeGenerator,
private val logger: KSPLogger,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logger is unused, wanna keep it in? (I'm literally doing Danger's work here, which reminds me there should be ktlint and danger plugins added in component-processor and component-annotations Gradle projects)


@Target(AnnotationTarget.CLASS)
@Retention(AnnotationRetention.SOURCE)
annotation class NavigationComponent()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This annotation class is unused, pls remove

import com.squareup.kotlinpoet.ksp.toTypeName
import com.squareup.kotlinpoet.ksp.writeTo

class ComponentPoetGenerator { // TODO cant access classes from other modules
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this is WIP version of generator using Kotlin Poet?

It appears to be unused, pls

  • remove this class (we can add it later when finished)
  • remove kotlin poet dependency

# Conflicts:
#	androidApp/build.gradle.kts
#	gradle/libs.versions.toml
#	shared/feature/build.gradle.kts
#	shared/feature/src/commonMain/kotlin/app/futured/kmptemplate/feature/navigation/signedin/tab/b/TabBDestinations.kt
#	shared/feature/src/commonMain/kotlin/app/futured/kmptemplate/feature/ui/first/FirstComponent.kt
#	shared/feature/src/commonMain/kotlin/app/futured/kmptemplate/feature/ui/first/FirstViewModel.kt
#	shared/resources/build.gradle.kts
Copy link

github-actions bot commented Oct 4, 2024

9 Warnings
⚠️ Feature or fix PR title should include JIRA-ID and short description.
⚠️ Feature or fix PR branch name should include JIRA-ID and short description.
⚠️ Please start subject with capital letter.
ff39892
⚠️ Please start subject with capital letter.
359511f
⚠️ Please use more than one word.
359511f
⚠️ Please start subject with capital letter.
31b8d40
⚠️ KLIB resolver: The same 'unique_name=resources_commonMain' found in more than one library: /Users/runnerm1/actions-runner/_work/kmp-futured-template/kmp-futured-template/shared/feature/build/kotlinTransformedMetadataLibraries/commonMain/dev.icerock.moko-resources-0.24.0-commonMain-3vAcDQ.klib, /Users/runnerm1/actions-runner/_work/kmp-futured-template/kmp-futured-template/shared/resources/build/classes/kotlin/metadata/commonMain
⚠️ KLIB resolver: The same 'unique_name=runtime_commonMain' found in more than one library: /Users/runnerm1/actions-runner/_work/kmp-futured-template/kmp-futured-template/shared/feature/build/kotlinTransformedMetadataLibraries/nativeMain/app.cash.sqldelight-runtime-2.0.1-commonMain-wyRdBg.klib, /Users/runnerm1/actions-runner/_work/kmp-futured-template/kmp-futured-template/shared/feature/build/kotlinTransformedMetadataLibraries/nativeMain/org.jetbrains.compose.runtime-runtime-1.6.11-commonMain-CVJWAg.klib
⚠️ Search path '/Users/runnerm1/actions-runner/_work/kmp-futured-template/kmp-futured-template/iosApp/../shared/app/build/xcode-frameworks/Debug/iphonesimulator17.5' not found
2 Messages
📖 iosAppTests: Executed 1 test, with 0 failures (0 expected) in 0.001 (0.002) seconds
📖 iosAppUITests: Executed 1 test, with 0 failures (0 expected) in 22.678 (22.679) seconds

Generated by 🚫 Danger

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants