tommykw / kotlin-compiler-plugin-sample

This is a sample project using the kotlin compiler plugin.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Kotlin Compiler Plugin Sample

Summary

This is a sample project using the kotlin compiler plugin. I used the Tracer-Kotlin-Compiler-Plugin project as a reference. It consists of the following two projects. You can add @HelloWorld annotation to a function, Hello World will be printed.

  • HelloWorldPlugin
    • HelloWorldCompilerPlugin.kt
    • HelloWorldGradlePlugin.kt
    • HelloWorldTreeVisitor.kt
  • HelloWorldPluginSample
    • Main.kt

Usage

First, run the publish task of HelloWorldPlugin.

A maven-repo will be generated in the root directory.

Next, run the build task of HelloWorldPluginSample.

Finally, run the Main.kt of HelloWorldPluginSample will output Hello World.

The files generated by HelloWorldPlugin are located under HelloWorldPluginSample/build/generated/ktPlugin/. You can see that println("Hello World") has been added to foo() in the generated Main.kt.

About

This is a sample project using the kotlin compiler plugin.


Languages

Language:Kotlin 100.0%