Skip to content

Instantly share code, notes, and snippets.

View Morfly's full-sized avatar

Pavlo Stavytskyi Morfly

View GitHub Profile
View AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.morfly.helloworld">
<application android:label="Bazel Android Hello World">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
View MainActivity.java
package com.morfly.helloworld;
import android.app.Activity;
import android.os.Bundle;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@Morfly
Morfly / BUILD
Last active March 22, 2021 08:37
View BUILD
android_binary(
name = "app",
custom_package = "com.morfly.helloworld",
manifest = "AndroidManifest.xml",
srcs = ["java/com/morfly/helloworld/MainActivity.java"],
resource_files = glob(["res/**"]),
)
View activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
View WORKSPACE
android_sdk_repository(
name = "androidsdk"
)
View WORKSPACE
android_sdk_repository(
name = "androidsdk",
path = "/path/to/Android/sdk",
)
@Morfly
Morfly / FunctionProcessor.kt
Created July 15, 2021 17:59
OutputStream write utility function
View FunctionProcessor.kt
class FunctionProcessor(...) : SymbolProcessor {
operator fun OutputStream.plusAssign(str: String) {
this.write(str.toByteArray())
}
override fun process(resolver: Resolver): List<KSAnnotated> { ... }
}
@Morfly
Morfly / build.gradle.kts
Last active July 15, 2021 18:29
KSP sample annotations build
View build.gradle.kts
// annotations/build.gradle.kts
plugins {
kotlin("jvm")
}
@Morfly
Morfly / build.gradle.kts
Created July 15, 2021 18:31
KSP sample main-project build
View build.gradle.kts
// main-project/build.gradle.kts
plugins {
kotlin("jvm")
id("com.google.devtools.ksp")
}
dependencies {
implementation(project(":annotations"))
ksp(project(":processor"))
@Morfly
Morfly / FunctionProcessor.kt
Last active July 15, 2021 18:53
KSP function processor, process function, visitor
View FunctionProcessor.kt
class FunctionProcessor(...) : SymbolProcessor {
override fun process(resolver: Resolver): List<KSAnnotated> {
...
symbols.forEach { it.accept(Visitor(file), Unit) }
file.close()
val unableToProcess = symbols.filterNot { it.validate() }.toList()
return unableToProcess