/KotlinCompilerPluginExample

This is an example project that shows how to create a Kotlin Compiler Plugin.The plugin will print "Hello from" and the name of the file that is being compiled, as a compiler warning to the terminal log.

Primary LanguageKotlinApache License 2.0Apache-2.0

JK_KotlinCompilerPluginHelloWorld

jCenter PRs Welcome jCenter

jCenter

Introduction 🙋‍♂️

This is an example project that shows how to create a Kotlin Compiler Plugin. At compile time a gradle plugin will trigger the compiler plugin. The plugin will print "Hello from" and the name of the file that is being compiled, as a compiler warning to the terminal log.

Show some ❤️ and star the repo to support the project

GitHub stars GitHub forks GitHub watchers Twitter Follow

Usage

ℹ️ Please be aware that the Kotlin Compiler still doesn’t have any stable API and there is no backwards compatibility guaranteed. Kotlin versions above 1.3.72 can have all totally different API.

  • Inside the project folder run ./gradlew clean build

The plugin is only active when the build cache is changed. This is why you need to run "clean" before building, when you want to see the log output again.

👷 Project Structure

src

  • app - A Kotlin Multiplatform project which applies a gradle plugin(compiler.plugin.helloworld) whichs triggers the compiler plugin.

buildSrc/compiler-plugin

  • kotlin-compiler-native-plugin - This module contains the Kotlin Compiler Plugin for native targets
  • kotlin-compiler-plugin - This module contains the Kotlin Compiler Plugin for JVM/JS targets
  • gradle-plugin - This module contains the gradle plugin which trigger the two compiler plugins

✍️ Feedback

Feel free to send feedback on Twitter or file an issue. Feature requests are always welcome.

Find this project useful ? ❤️

  • Support it by clicking the ⭐ button on the upper right of this page. ✌️

📜 License


This project is licensed under Apache License, Version 2.0

Copyright 2019 Jens Klingenberg

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Acknowledgments

Projects that helped me understand how to setup the project: