juullabs / exercise Goto Github PK
View Code? Open in Web Editor NEWAnnotation processor for Android activity intent extras.
Home Page: https://juullabs.github.io/exercise/
License: Apache License 2.0
Annotation processor for Android activity intent extras.
Home Page: https://juullabs.github.io/exercise/
License: Apache License 2.0
Moshi has some here as an example of what they look like.
They seem to be backed by kotlin-compile-testing.
Attempted to add macosArm64
target to SensorTag example but am now getting the following build time failure:
* What went wrong:
Could not determine the dependencies of task ':app:compileNativeDarwinMainKotlinMetadata'.
> Could not create task ':app:kspNativeDarwinMainKotlinMetadata'.
> class org.jetbrains.kotlin.gradle.tasks.KotlinNativeCompile_Decorated cannot be cast to class org.jetbrains.kotlin.gradle.tasks.KotlinCompileCommon (org.jetbrains.kotlin.gradle.tasks.KotlinNativeCompile_Decorated and org.jetbrains.kotlin.gradle.tasks.KotlinCompileCommon are in unnamed module of loader org.gradle.internal.classloader.VisitableURLClassLoader @6db3646e)
Commenting out ksp(libs.exercise.compile)
in app/build.gradle.kts
allows the Native targets to build, but obviously breaks the Android target (because it relies on Exercise).
Danger of implementing against an alpha API
Use case here is easier integration into AndroidX Navigation (as an alternative to SafeArgs, since it's not supported when using the XML-free DSL).
@Exercise(Argument("foo", Int::class))
class DestinationFragment : Fragment() {
// ...
}
class SourceFragment : Fragment() {
fun navigateToDest() {
findNavController().navigate(R.id.action, DestinationFragmentArgs(foo = 5))
}
}
Not to assume the function name here.
The readme is far from complete, and it definitely shouldn't be the only documentation we have.
Stop assuming that a Context
's packageName
is global to the application.
When someone is using Exercise, it will generate code that uses bundleOf
(androidx.core.os.bundleOf
).
When setting up Exercise, library consumers will commonly use the following Gradle configuration:
implementation("com.juul.exercise:annotations:$version")
ksp("com.juul.exercise:compile:$version")
Unfortunately, the generated code will not compile if the core-ktx
dependency is not manually pulled in, as annotations
module does not define core-ktx
as api
(nor should it do so).
Not sure the best approach to getting core-ktx
pulled in, aside from either instructing that consumers pull in core-ktx
manually or pull in an Exercise module that has core-ktx
as api
.
A lot of our feature prioritization is done so we can eat our own dog food. Would be nice if we didn't have to issue a release for every feature, so we could make them more meaningful.
See: https://github.com/android/kotlin
Exercise only makes sense on a JVM platform, so we don't need the cross-platform side of things, but KSP processes more quickly than KAPT does so there would be less of a compile time penalty.
This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.
These updates have all been created already. Click a checkbox below to force a retry/rebase of any.
com.google.devtools.ksp:symbol-processing-api
, org.jetbrains.kotlin.jvm
, org.jetbrains.kotlin:kotlin-parcelize-runtime
)com.android.library
, com.android.application
).github/workflows/ci.yml
actions/checkout v4
actions/setup-java v4
gradle/actions v3
EnricoMi/publish-unit-test-result-action v2
codecov/codecov-action v4
ubuntu 22.04
.github/workflows/dokka.yml
actions/checkout v4
actions/setup-java v4
gradle/actions v3
JamesIves/github-pages-deploy-action v4
ubuntu 22.04
.github/workflows/publish.yml
actions/checkout v4
actions/setup-java v4
gradle/actions v3
ubuntu 22.04
.github/workflows/release-drafter.yml
release-drafter/release-drafter v6
.github/workflows/version-labels.yml
mheap/github-action-required-labels v5
gradle.properties
settings.gradle.kts
build.gradle.kts
annotations/gradle.properties
annotations/build.gradle.kts
compile/gradle.properties
compile/build.gradle.kts
gradle/jacoco.gradle.kts
gradle/libs.versions.toml
org.assertj:assertj-core 3.26.3
com.juul.khronicle:khronicle-core 0.3.0
org.jetbrains.kotlin:kotlin-parcelize-runtime 2.0.0
com.squareup:kotlinpoet 1.18.1
com.google.devtools.ksp:symbol-processing-api 2.0.0-1.0.24
com.github.tschuchortdev:kotlin-compile-testing-ksp 1.6.0
org.robolectric:robolectric 4.13
com.android.application 8.5.1
com.android.library 8.5.1
org.jetbrains.kotlinx.binary-compatibility-validator 0.16.2
org.jetbrains.dokka 1.9.20
org.jetbrains.kotlin.jvm 2.0.0
org.jmailen.kotlinter 4.4.1
com.vanniktech.maven.publish 0.29.0
runtime/gradle.properties
runtime/build.gradle.kts
stubs/gradle.properties
stubs/build.gradle.kts
gradle/wrapper/gradle-wrapper.properties
gradle 8.9
The logic for creating a launch Intent
can be exactly the same for Service
as it is for Activity
.
However, unlike an Activity
, there is no getIntent
function to power an extras
extension property. Instead, services pass the Intent
to functions as needed, such as IntentService.onHandleIntent(intent: Intent?)
.
Cleanest solution is probably something like this:
// Your Source
@Exercise(Extra("example", Int::class))
class MyService : IntentService() {
init { setIntentRedelivery(true) } // Lets us ignore null intent case to simplify sample
override fun onHandleIntent(intent: Intent) {
Log.d("MyService", "Example extra: ${extras(intent).example}")
}
}
// Generated
class MyServiceParams(
private val intent: Intent
) {
val example: Int
get() = intent.extras.get("${intent.component.packageName}.example") as Int
}
fun MyService.extras(intent: Intent): MyServiceParams
get() = MyServiceParams(intent)
We don't get the parameter as a val
extension, but this is probably the best we can do.
This would be arguments, not extras, but I don't see why the same concept can't apply.
Would be really cool if this was more robust, instead of just being an isEqualTo with syntax highlighting.
Look into using Kotlin/grammar-tools or similar to provide something more robust.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.