Coder Social home page Coder Social logo

zinc's Introduction

Zinc

tests lint maven central

An extensible compiler plugin for Kotlin to automatically expand data classes to include their own builder DSL.

Introduction

Zinc was originally conceived as a solution to reduce testing boilerplate, but supposedly there are production use cases too.

More information to come as this becomes more useful.

How it works

When enabled, Zinc analyzes specified source sets and generates builders and a DSL for each data class. There are two classes of builders generated: production and test.

See Examples

Production Builders

These builders are for use in production code when a builder pattern is preferable over using a constructor. All properties must be able to resolve a value. When a field does not have a default value, an exception will be thrown with details about the missing field.

Configure the source sets that should contribute to this classification by setting the productionSourceSetNames field on the plugin extension. See Setup

Test Builders

Not yet implemented.

This is the work-in-progress primary feature of this plugin. Builders in this classification will be generated with randomized default values for all fields. This essentially provides a clean, all fields optional way to supply fake data in tests.

Setup

Artifacts can be downloaded from Maven Central.

Gradle Kotlin Script

plugins {
  id("com.noheltcj.zinc") version "0.0.3"
}

zinc {
  // defaults to true
  enabled = true

  // defaults to setOf("main")
  productionSourceSetNames = setOf("main", "anotherSourceSet")
}

Gradle Groovy

plugins {
    id 'com.noheltcj.zinc' version '0.0.3'
}

zinc {
    productionSourceSetNames = ['main', 'anotherSourceSet']
}

zinc's People

Contributors

noheltcj avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.