All Projects → ktargeter → Ktargeter

ktargeter / Ktargeter

Licence: apache-2.0
Kotlin compiler plugin that allows overriding annotation use-site targets for properties

Programming Languages

kotlin
9241 projects

Projects that are alternatives of or similar to Ktargeter

No Copy
A Kotlin compiler plugin that removes the `copy` method of data classes.
Stars: ✭ 90 (+275%)
Mutual labels:  gradle-plugin, annotations
Gradle Release
gradle-release is a plugin for providing a Maven-like release process for projects using Gradle
Stars: ✭ 731 (+2945.83%)
Mutual labels:  gradle-plugin
Label Studio
Label Studio is a multi-type data labeling and annotation tool with standardized output format
Stars: ✭ 7,264 (+30166.67%)
Mutual labels:  annotations
Yedda
YEDDA: A Lightweight Collaborative Text Span Annotation Tool. Code for ACL 2018 Best Demo Paper Nomination.
Stars: ✭ 704 (+2833.33%)
Mutual labels:  annotations
Scabbard
🗡 A tool to visualize Dagger 2 dependency graphs
Stars: ✭ 615 (+2462.5%)
Mutual labels:  gradle-plugin
Ktlint Gradle
A ktlint gradle plugin
Stars: ✭ 713 (+2870.83%)
Mutual labels:  gradle-plugin
Sdkhotfix
在用户规模千万级别的app中验证过,稳定无兼容问题,5分钟让你的SDK拥有热修复能力。A SDK hotfix library with stable verified in tens of millions of users can be accessed in only five minutes.
Stars: ✭ 585 (+2337.5%)
Mutual labels:  gradle-plugin
Hoodie
Hoodie is a type safe wrapper around jersey http client
Stars: ✭ 22 (-8.33%)
Mutual labels:  annotations
Typescript Generator
Generates TypeScript from Java - JSON declarations, REST service client
Stars: ✭ 729 (+2937.5%)
Mutual labels:  gradle-plugin
D3 Annotation
Use d3-annotation with built-in annotation types, or extend it to make custom annotations. It is made for d3-v4 in SVG.
Stars: ✭ 693 (+2787.5%)
Mutual labels:  annotations
Shot
Gradle plugin developed to facilitate screenshot testing for Android
Stars: ✭ 668 (+2683.33%)
Mutual labels:  gradle-plugin
Jsonschema2pojo
Generate Java types from JSON or JSON Schema and annotate those types for data-binding with Jackson, Gson, etc
Stars: ✭ 5,633 (+23370.83%)
Mutual labels:  gradle-plugin
Img Optimizer Gradle Plugin
一款用于优化png图片的gradle插件,有效减少APK体积,支持极限压缩和无损压缩。
Stars: ✭ 718 (+2891.67%)
Mutual labels:  gradle-plugin
Swoft
🚀 PHP Microservice Full Coroutine Framework
Stars: ✭ 5,420 (+22483.33%)
Mutual labels:  annotations
Labelme
Image Polygonal Annotation with Python (polygon, rectangle, circle, line, point and image-level flag annotation).
Stars: ✭ 7,742 (+32158.33%)
Mutual labels:  annotations
Cvat
Powerful and efficient Computer Vision Annotation Tool (CVAT)
Stars: ✭ 6,557 (+27220.83%)
Mutual labels:  annotations
React Decoration
A collection of decorators for React Components
Stars: ✭ 641 (+2570.83%)
Mutual labels:  annotations
Gogradle
A Gradle Plugin Providing Full Support for Go
Stars: ✭ 712 (+2866.67%)
Mutual labels:  gradle-plugin
Waveform Playlist
Multitrack Web Audio editor and player with canvas waveform preview. Set cues, fades and shift multiple tracks in time. Record audio tracks or provide audio annotations. Export your mix to AudioBuffer or WAV! Project inspired by Audacity.
Stars: ✭ 919 (+3729.17%)
Mutual labels:  annotations
Entity Recognition Datasets
A collection of corpora for named entity recognition (NER) and entity recognition tasks. These annotated datasets cover a variety of languages, domains and entity types.
Stars: ✭ 891 (+3612.5%)
Mutual labels:  annotations

ktargeter build Maven Central GitHub License

ktargeter logo

Ktargeter is a Kotlin compiler plugin that allows overriding annotation use-site targets for properties. Using Java annotations in Kotlin code often requires specifying use-site targets, which is inconvenient and leads to bugs in runtime when a target is not specified. Instead of memorizing whether it is @get:Email, @field:Email, or @set:Email. You can configure it once in Gradle and use @Email throughout your code. Ktargeter works during compilation and adds no overhead in runtime.

As an example, you can replace this code:

data class User(
    @get:One
    val firstName: String,
    @field:Two
    val lastName: String,
    @set:Three
    var birthday: LocalDate,     
)

with this:

data class User(
    @One
    val firstName: String,
    @Two
    val lastName: String,
    @Three
    var birthday: LocalDate,     
)

Usage

You have to have Kotlin 1.4 or later.

Add ktargeter to the plugins section of your build.gradle:

plugins {
    id 'org.ktargeter' version '0.1.0'
}

Enable IR compilation:

compileKotlin {
    kotlinOptions.useIR = true
}

Define annotations with new targets in the following way:

ktargeter.annotations = [
        "com.sample.annotations.One"  : "get",
        "com.sample.annotations.Two"  : "field",
        "com.sample.annotations.Three": "set"
]

This will instruct the plugin to override use-site targets for the specified annotations when they are used on properties.

Ktargeter will not override targets of annotations that specify their targets explicitly.

Note: Ktargeter uses Kotlin IR backend which is in beta in Kotlin 1.4 and will be a default in Kotlin 1.5.

Contributing

If you found a bug or have an idea on how to improve ktargeter feel free to open an issue. You can also propose your changes via a Pull Request.

Development setup

In order to debug/develop ktargeter, use the following steps:

  1. Install Gradle and Kotlin plugins into the local Maven repository:
./gradlew publishToMavenLocal -x signMavenPublication \
 -x signPluginMavenPublication -x signSimplePluginPluginMarkerMavenPublication
  1. Import the project to IntelliJ IDEA (the Debug Kotlin Plugin configuration should be available in Run/Debug configuration box).

  2. Add breakpoints to the classes in the compiler-plugin module.

  3. Clone and build the sample project using the following command:

./gradlew clean build --no-daemon -Dorg.gradle.debug=true \
 -Dkotlin.compiler.execution.strategy="in-process" \
 -Dkotlin.daemon.jvm.options="-Xdebug,-Xrunjdwp:transport=dt_socket,address=5005,server=y,suspend=n"
  1. Run the Debug Kotlin Plugin configuration in Debug mode.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].