mirror of
https://github.com/msfjarvis/TraceLog.git
synced 2024-06-03 04:18:59 +05:30
feat: add a JVM CLI sample
This commit is contained in:
parent
fb9d02958a
commit
cd936e1e91
26
sample-jvm/build.gradle.kts
Normal file
26
sample-jvm/build.gradle.kts
Normal file
|
@ -0,0 +1,26 @@
|
|||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||
|
||||
plugins {
|
||||
embeddedKotlin("jvm")
|
||||
application
|
||||
}
|
||||
|
||||
group = "dev.msfjarvis.tracelog"
|
||||
version = "1.0.0-SNAPSHOT"
|
||||
|
||||
application {
|
||||
mainClass = "dev.msfjarvis.tracelog.sample.MainKt"
|
||||
}
|
||||
|
||||
tasks.withType<KotlinCompile>().configureEach {
|
||||
compilerOptions.freeCompilerArgs.addAll(
|
||||
"-P",
|
||||
"plugin:dev.msfjarvis.tracelog:loggerFunction=dev.msfjarvis.tracelog.sample.recordMessage",
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
dependencies {
|
||||
kotlinCompilerPluginClasspath(projects.compilerPlugin)
|
||||
implementation(projects.annotations)
|
||||
}
|
21
sample-jvm/src/main/kotlin/Main.kt
Normal file
21
sample-jvm/src/main/kotlin/Main.kt
Normal file
|
@ -0,0 +1,21 @@
|
|||
package dev.msfjarvis.tracelog.sample
|
||||
|
||||
import dev.msfjarvis.tracelog.annotations.DebugLog
|
||||
|
||||
private val messages = arrayListOf<String>()
|
||||
|
||||
fun main() {
|
||||
debuggableFunction("First parameter")
|
||||
println("Captured messages:")
|
||||
println(messages.joinToString("\n"))
|
||||
}
|
||||
|
||||
@Suppress("Unused") // Used by the generated bytecode
|
||||
fun recordMessage(message: Any?) {
|
||||
messages += message.toString()
|
||||
}
|
||||
|
||||
@DebugLog
|
||||
fun debuggableFunction(p0: String): String {
|
||||
return "Debugging is cool!"
|
||||
}
|
|
@ -14,9 +14,10 @@ plugins { id("org.gradle.toolchains.foojay-resolver-convention") version "0.7.0"
|
|||
rootProject.name = "tracelog"
|
||||
|
||||
include(
|
||||
"annotations",
|
||||
"compiler-plugin",
|
||||
"gradle-plugin",
|
||||
"annotations",
|
||||
"compiler-plugin",
|
||||
"gradle-plugin",
|
||||
"sample-jvm",
|
||||
)
|
||||
|
||||
enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")
|
||||
|
|
Loading…
Reference in New Issue
Block a user