Hallo Friends cellphone prices and specifications, In the article that you are reading this time with the title Accelerated Kotlin build times with Kotlin Symbol Processing 1.0, we have prepared this article well for you to read and take the information in it. hopefully the contents of the post Article Android Developers Blog, Article IFTTT, what we write you can understand. all right, have a nice reading..
Posted by Ting-Yuan Huang, Software Engineer and Jiaxiang Chen, Software Engineer
Kotlin Symbol Processing (KSP), our new tool for building lightweight compiler plugins in Kotlin, is now stable! KSP offers similar functionality to the Kotlin Annotation Processing Tool (KAPT), however it’s up to 2x faster, offers direct access to Kotlin language constructs, and offers support for multiplatform targets.
Over the past few months, KSP has gone through 32 releases with over 162 bugs reported from the community and fixed by our team. If you were waiting to adopt it, now is the time to check it out.
Why we built KSP
On the Android team, we regularly ask developers: what are your biggest frustrations with writing apps today? One of the top issues that comes up repeatedly is build speed. Over the years we’ve been making steady improvements to the Android build toolchain, and today we’re excited to add to those improvements with KSP. KSP is the next generation of annotation processing in Kotlin: it will dramatically improve build speed for Kotlin developers, and unlike KAPT, it offers support for Kotlin/Native and Kotlin/JS.
Why is KSP faster?
The Kotlin Annotation Processing Tool (KAPT) works with Java’s annotation processing infrastructure to make most Java language annotation processors work in Kotlin out of the box. To do this, KAPT compiles Kotlin code into Java stubs that retain information that Java annotation processors care about. Creating these stubs is costly though, and means the compiler must resolve all the symbols in your program multiple times (once to generate stubs, and then again to do the actual compilation).
KSP moves away from the stub generation model by working as a Kotlin compiler plugin — it allows annotation processors to read and analyze source programs and resources directly in Kotlin instead of requiring you to depend on the Java annotation processing infrastructure. This both dramatically improves build speed (up to 2x faster for Room's Kotlin test app) and means that KSP can be used for non-Android and non-JVM environments like Kotlin/Native and Kotlin/JS.
How to get started
To start using KSP, download the KSP playground project from GitHub, which shows how to use KSP both as an annotation processor and as a consuming app/library:
- Annotation processor: A toy
test-processor
library that implements the builder pattern as a KSP processor - Consuming library: A
workload
directory that shows how to use the builder processor in a real-world Kotlin project
If you’re an app developer, check out the list of supported libraries and the quickstart guide for moving a module over from KAPT to KSP.
Using Moshi or Room with KSP
If you’re using Moshi or Room in your project, you can already try out KSP by making a quick fix to your module’s build file. For example, to use the KSP version of Room in a Gradle module you can simply replace the KAPT plugin with KSP and swap out the KSP dependency:
apply plugin: 'com.google.devtools.ksp' dependencies { ... implementation "androidx.room:room-runtime:$room_version"kapt "androidx.room:room-compiler:$room_version"ksp "androidx.room:room-compiler:$room_version" }
Check out the Room release notes for more info.
Conclusion
With the 1.0 release of KSP you will start to see improved build times for your Kotlin projects as you migrate away from libraries based on KAPT. We have also updated a number of Android specific libraries which are ready for you to try today and offer significant performance improvements.
from Android Developers Blog https://ift.tt/2WXpzZU
via IFTTT
Thus the article Accelerated Kotlin build times with Kotlin Symbol Processing 1.0
You are now reading the article Accelerated Kotlin build times with Kotlin Symbol Processing 1.0 By address link https://cellphone-prices-and-specifications.blogspot.com/2021/09/accelerated-kotlin-build-times-with.html
0 Komentar untuk "Accelerated Kotlin build times with Kotlin Symbol Processing 1.0"