All Projects → juanchosaravia → Autodsl

juanchosaravia / Autodsl

Licence: apache-2.0
Auto-generate Kotlin DSL

Programming Languages

kotlin
9241 projects
dsl
153 projects

Projects that are alternatives of or similar to Autodsl

PrimeAdapter
PrimeAdapter makes working with RecyclerView easier.
Stars: ✭ 54 (-82.91%)
Mutual labels:  builder, annotations
Tieguanyin
Activity Builder.
Stars: ✭ 113 (-64.24%)
Mutual labels:  builder, annotations
annotated research papers
This repo contains annotated research papers that I found really good and useful
Stars: ✭ 2,101 (+564.87%)
Mutual labels:  annotations
Loukoum
A simple SQL Query Builder
Stars: ✭ 305 (-3.48%)
Mutual labels:  builder
Inquiry Deprecated
[DEPRECATED]: Prefer Room by Google, or SQLDelight by Square.
Stars: ✭ 264 (-16.46%)
Mutual labels:  annotations
deber
📦🐋 Debian packaging with Docker
Stars: ✭ 20 (-93.67%)
Mutual labels:  builder
Immutables
Annotation processor to create immutable objects and builders. Feels like Guava's immutable collections but for regular value objects. JSON, Jackson, Gson, JAX-RS integrations included
Stars: ✭ 3,031 (+859.18%)
Mutual labels:  builder
AnnotationsRestored
Brings annotation support back to YouTube
Stars: ✭ 39 (-87.66%)
Mutual labels:  annotations
Php Sql Query Builder
An elegant lightweight and efficient SQL Query Builder with fluid interface SQL syntax supporting bindings and complicated query generation.
Stars: ✭ 313 (-0.95%)
Mutual labels:  builder
Uxmpdfkit
An iOS PDF viewer and annotator written in Swift that can be embedded into any application.
Stars: ✭ 260 (-17.72%)
Mutual labels:  annotations
Updated Carbanak Source With Plugins
https://twitter.com/itsreallynick/status/1120410950430089224
Stars: ✭ 303 (-4.11%)
Mutual labels:  builder
Eggnog Mapper
Fast genome-wide functional annotation through orthology assignment
Stars: ✭ 256 (-18.99%)
Mutual labels:  annotations
core
The XP Framework is an all-purpose, object oriented PHP framework.
Stars: ✭ 13 (-95.89%)
Mutual labels:  annotations
Memex
Browser Extension to full-text search your browsing history & bookmarks.
Stars: ✭ 3,344 (+958.23%)
Mutual labels:  annotations
email-template-builder
let this service generate your custom html/text emails
Stars: ✭ 25 (-92.09%)
Mutual labels:  builder
Singlefile
Web Extension for Firefox/Chrome/MS Edge and CLI tool to save a faithful copy of an entire web page in a single HTML file
Stars: ✭ 4,417 (+1297.78%)
Mutual labels:  annotations
the schema is
ActiveRecord schema annotations done right
Stars: ✭ 44 (-86.08%)
Mutual labels:  annotations
Substance
A JavaScript library for web-based content editing.
Stars: ✭ 2,737 (+766.14%)
Mutual labels:  annotations
Picocli
Picocli is a modern framework for building powerful, user-friendly, GraalVM-enabled command line apps with ease. It supports colors, autocompletion, subcommands, and more. In 1 source file so apps can include as source & avoid adding a dependency. Written in Java, usable from Groovy, Kotlin, Scala, etc.
Stars: ✭ 3,286 (+939.87%)
Mutual labels:  annotations
Gramateria
Drag and drop web builder with material design.
Stars: ✭ 310 (-1.9%)
Mutual labels:  builder

#[DEPRECATED] Unfortunately, since Kotlin 1.4.x this library doesn't work anymore. It has a strong dependency on me.eugeniomarletti.kotlin.metadata:kotlin-metadata lib which doesn't work anymore in 1.4.x to extract Kotlin Metadata.

If you think this feature should be back into 1.4.x then please let me know in the Issue section, probably we could invest some time trying to achieve the same with the new Kotlin Backend.

AutoDsl for Kotlin

Auto-generates DSL (Domain Specific Language) for your Kotlin projects using annotations.

CircleCI Download

Table of Contents

  1. Documentation
  2. Download

Create expressive, immutable and type-safe DSL without boilerplate code:

person {
    name = "Juan"
    age = 34
    newAddress {
        street = "200 Celebration Bv"
        zipCode = 34747
        location {
            lat = 100.0
            lng = 100.0
        }
    }
    friends {
        +person {
            name = "Arturo"
            age = 28
        }
        +person {
            name = "Tiwa"
            age = 30
        }
    }
}

To generate the previous DSL you just need to provide your desired classes with @AutoDsl:

@AutoDsl
class Person(
    val name: String,
    val age: Int,
    val address: Address?,
    val friends: List<Person>?
)

@AutoDsl("newAddress") // set custom name for DSL
data class Address(      // can be used in data classes
    val street: String,
    val zipCode: Int,
    val location: Location?
)

@AutoDsl
class Location {
    val lat: Double
    val lng: Double

    constructor() {
        lat = 0.0
        lng = 0.0
    }

    // in multiple constructors you can specify which one to use.
    @AutoDslConstructor
    constructor(lat: Double, lng: Double) {
        this.lat = lat
        this.lng = lng
    }
}

AutoDsl will be generating a builder class and extension function for the annotated class providing this super expressive DSL.

For required parameters like name the DSL will throw an exception at runtime indicating exactly which field is missed. To make it optional just set the property as nullable with the question mark like friends. The value will be null in case it's not set.

Note: Default parameters in constructor is not currently supported as there is no way to get that value in the process to generate the code. There is a workaround that you can use explained in the wiki page.

Documentation

Visit the Wiki for a full list of features and more details: AutoDsl-Wiki

For more Examples

Download

Add JCenter repository:
repositories {
    jcenter()
}
Add the dependencies

Download

dependencies {
    api "io.github.juanchosaravia.autodsl:annotation:latest_version"
    kapt "io.github.juanchosaravia.autodsl:processor:latest_version"
}

Debug

If you want to debug the processor do the following steps:

  1. Run this command:
    ./gradlew clean :app: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"
    
  2. In IntelliJ Idea go to Tools > Edit Configurations > press "+" icon in the left top corner. Add a new "Remote". Set a Name and check the "Single instance only" flag to true.
  3. Press "Debug" button to run the newly created "Remote" configuration.

Publish

  • Update version in release-brintray.gradle file:
libraryVersion = 'x.y.z'
  • Setup bintray user and pass in local.properties:
bintray.user=username
bintray.apikey=apikey
  • Run:
./gradlew :annotation:bintrayUpload
./gradlew :processor:bintrayUpload

License

Copyright 2018 Juan Ignacio Saravia

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.  
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].