Zinc

Kotlin compiler plugin that generates data classes for production and testing.

License

License

Categories

Categories

Gradle Build Tools
GroupId

GroupId

com.noheltcj.zinc
ArtifactId

ArtifactId

com.noheltcj.zinc.gradle.plugin
Last Version

Last Version

0.0.3
Release Date

Release Date

Type

Type

pom
Description

Description

Zinc
Kotlin compiler plugin that generates data classes for production and testing.
Project URL

Project URL

https://github.com/noheltcj/zinc
Source Code Management

Source Code Management

https://github.com/noheltcj/zinc

Download com.noheltcj.zinc.gradle.plugin

How to add to project

<!-- https://jarcasting.com/artifacts/com.noheltcj.zinc/com.noheltcj.zinc.gradle.plugin/ -->
<dependency>
    <groupId>com.noheltcj.zinc</groupId>
    <artifactId>com.noheltcj.zinc.gradle.plugin</artifactId>
    <version>0.0.3</version>
    <type>pom</type>
</dependency>
// https://jarcasting.com/artifacts/com.noheltcj.zinc/com.noheltcj.zinc.gradle.plugin/
implementation 'com.noheltcj.zinc:com.noheltcj.zinc.gradle.plugin:0.0.3'
// https://jarcasting.com/artifacts/com.noheltcj.zinc/com.noheltcj.zinc.gradle.plugin/
implementation ("com.noheltcj.zinc:com.noheltcj.zinc.gradle.plugin:0.0.3")
'com.noheltcj.zinc:com.noheltcj.zinc.gradle.plugin:pom:0.0.3'
<dependency org="com.noheltcj.zinc" name="com.noheltcj.zinc.gradle.plugin" rev="0.0.3">
  <artifact name="com.noheltcj.zinc.gradle.plugin" type="pom" />
</dependency>
@Grapes(
@Grab(group='com.noheltcj.zinc', module='com.noheltcj.zinc.gradle.plugin', version='0.0.3')
)
libraryDependencies += "com.noheltcj.zinc" % "com.noheltcj.zinc.gradle.plugin" % "0.0.3"
[com.noheltcj.zinc/com.noheltcj.zinc.gradle.plugin "0.0.3"]

Dependencies

compile (1)

Group / Artifact Type Version
com.noheltcj.zinc : gradle-plugin jar 0.0.3

Project Modules

There are no modules declared in this project.

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']
}

Versions

Version
0.0.3
0.0.2