Skip to content

tommykw/kotlin-compiler-plugin-sample

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages