Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mike-neck/rule-base-model-generation-plugin
This is plugin for Gradle, which generates interfaces for rule base model.
https://github.com/mike-neck/rule-base-model-generation-plugin
Last synced: 15 days ago
JSON representation
This is plugin for Gradle, which generates interfaces for rule base model.
- Host: GitHub
- URL: https://github.com/mike-neck/rule-base-model-generation-plugin
- Owner: mike-neck
- License: apache-2.0
- Created: 2015-08-14T22:46:45.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2015-08-24T19:24:56.000Z (about 9 years ago)
- Last Synced: 2024-08-01T16:27:14.925Z (3 months ago)
- Language: Groovy
- Size: 254 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
rule-base-model-generation-plugin
===This is plugin for Gradle, which generates interfaces for rule base model.
Usage
===### Applying plugin
Copy & paste this snipet into your `build.gradle`.
```groovy
plugins {
id 'org.mikeneck.rule-based-model-generation' version '0.1'
}
```### Model definition
You can define your model via `model{}` block.
```groovy
model {
metaModel { // use metaModel{} block to define you model.
srcDir = 'src/main/groovy' // default is 'src/main/java'
packageName = 'sample.gradle.model' // mandatory
classes.create {
name = 'Person' // your model class name. classes.name should be Java class name style.
type = INTERFACE // the type of this class. you can select INTERFACE or ENUM.
fields.create { // if you select INTERFACE, fields is mandatory.
name = 'name' // name of field
type = STRING // the type of field. you can select STRING/INTEGER/LONG/FILE/MODEL_SET...etc.
}
fields.create {
name = 'livingIn' // fields.name should be Java property style.
type = MODEL_SET
refType = 'City' // if you defined field as MODEL_SET or MODEL_MAP, refType is mandatory.
}
fields.create {
name = 'sex'
type = ENUM // also you can select ENUM which refers your model.
refType = 'Sex' // if you defined property as ENUM or OTHER, refType is mandatory.
}
}
classes.create {
name = 'Sex'
type = ENUM
values.create { // if you select ENUM as classes.type, values is mandatory.
value = 'WOMEN' // enum value should be constructed with upper case letters and underscore only.
}
values.create {
value = 'MEN'
}
values.create {
value = 'UNKNOWN'
}
}
classes.create {
name = 'City'
type = INTERFACE
fields.create {
name = 'name'
type = STRING
}
fields.create {
name = 'country'
type = STRING
}
}
}
}
```The `generateModel` task will create 2 interfaces and an enum defined at `src/main/groovy` by this sample `model{}` block.
* interface `sample.gradle.model.Person`
* enum `sample.gradle.model.Sex`
* interface `sample.gradle.model.City`Tasks
===* `generateModel` - generates interface defined by `model{}` block.
* `generatePojo` - generates POJO which implements generated interface. This task depends on `generateModel`.Requirement
===This plugin is written under these condition...
* Java SE8
* Grdle version 2.6License
===Apache 2