Gradle plugin to create a java application based on Clean Architecture following our best practices!
To use the plugin you need Gradle version 5.6 or later, to start add the following section into your build.gradle file.
plugins {
id "co.com.bancolombia.cleanArchitecture" version "1.9.9"
}
Or if is a new project execute this script in the root directory of your project.
echo "plugins {
id \"co.com.bancolombia.cleanArchitecture\" version \"1.9.9\"
}" > build.gradle
The Scaffolding Clean Architecture plugin will allow you run 8 tasks:
The cleanArchitecture | ca
task will generate a clean architecture structure in your project, this task has four optional parameters; package
, type
, name
and coverage
.
-
package
= <package.we.need>
: You can specify the main or default package of your project.Default Value = co.com.bancolombia
-
type
= <imperative | reactive>
: With this parameter the task will generate a POO project.Default Value = imperative
-
name
= NameProject
: This parameter is going to specify the name of the project.Default Value = cleanArchitecture
-
coverage
= <jacoco | cobertura>
: This parameter is going to specify the coverage tool for the project.Default Value = jacoco
-
lombok
= <true | false>
: Specify if you want to use this plugin .Default Value = true
gradle cleanArchitecture --package=co.com.bancolombia --type=imperative --name=NameProject --coverage=jacoco --lombok=true
gradle ca --package=co.com.bancolombia --type=imperative --name=NameProject --coverage=jacoco --lombok=true
The structure will look like this:
π¦NameProject
β£ πapplications
β β πapp-service
β β β£ πsrc
β β β β£ πmain
β β β β β£ πjava
β β β β β β π[package]
β β β β β β β£ πconfig
β β β β β β β β π[configs and beans]
β β β β β β β πMainApplication.java
β β β β β πresources
β β β β β β£ π[properties]
β β β β πtest
β β β β β πjava
β β β β β β π[package]
β β β πbuild.gradle
β£ πdeployment
β β£ π[Dockerfile, Pipelines as a code]
β£ πdomain
β β£ πmodel
β β β£ πsrc
β β β β£ πmain
β β β β β πjava
β β β β β β π[package]
β β β β πtest
β β β β β πjava
β β β β β β π[package]
β β β πbuild.gradle
β β πusecase
β β β£ πsrc
β β β β£ πmain
β β β β β πjava
β β β β β β π[package]
β β β β πtest
β β β β β πjava
β β β β β β π[package]
β β β β β β β πusecase
β β β πbuild.gradle
β£ πinfrastructure
β β£ πdriven-adapters
β β£ πentry-points
β β πhelpers
β£ π.gitignore
β£ πbuild.gradle
β£ πgradle.properties
β£ πlombok.config
β£ πmain.gradle
β£ πREADME.md
β πsettings.gradle
The generateModel | gm
task will generate a class and interface in model layer, this task has one required parameter name
.
gradle generateModel --name=[modelName]
gradle gm --name [modelName]
This task will generate something like that:
π¦domain
β£ πmodel
β β£ πsrc
β β β£ πmain
β β β β πjava
β β β β β π[package]
β β β β β β πmodel
β β β β β β β£ πgateways
β β β β β β β β πModelRepository.java
β β β β β β β πModel.java
β β β πtest
β β β β πjava
β β β β β π[package]
β β β β β β πmodel
β β πbuild.gradle
The generateUseCase | guc
task will generate a class in model layer, this task has one required parameter name
.
gradle generateUseCase --name=[useCaseName]
gradle guc --name [useCaseName]
This task will generate something like that:
π¦domain
β πusecase
β β£ πsrc
β β β£ πmain
β β β β πjava
β β β β β π[package]
β β β β β β πusecase
β β β β β β β πbusiness
β β β β β β β β πBusinessUseCase.java
β β β πtest
β β β β πjava
β β β β β π[package]
β β β β β β πusecase
β β β β β β β πbusiness
β β πbuild.gradle
The generateDrivenAdapter | gda
task will generate a module in Infrastructure layer, this task has one required parameter type
.
Whether you'll use generic one also parameter name
is required.
gradle generateDrivenAdapter --type=[drivenAdapterType]
gradle gda --type [drivenAdapterType]
Reference for drivenAdapterType | Name | Additional Options |
---|---|---|
generic | Empty Driven Adapter | --name [name] |
jpa | JPA Repository | --secret [true-false] |
mongodb | Mongo Repository | --secret [true-false] |
asynceventbus | Async Event Bus | |
restconsumer | Rest Client Consumer | --url [url] |
redis | Redis | --mode [template-repository] --secret [true-false] |
rsocket | RSocket Requester | |
r2dbc | R2dbc Postgresql Client | |
kms | AWS Key Management Service | |
secrets | Secrets Manager Bancolombia | |
s3 | AWS Simple Storage Service | |
mq | JMS MQ Client to send messages |
This task will generate something like that:
π¦infrastructure
β£ πdriven-adapters
β β πjpa-repository
β β β£ πsrc
β β β β£ πmain
β β β β β πjava
β β β β β β π[package]
β β β β β β β πjpa
β β β β β β β β£ πconfig
β β β β β β β β β πDBSecret.java
β β β β β β β β£ πhelper
β β β β β β β β β πAdapterOperations.java
β β β β β β β β£ πJPARepository.java
β β β β β β β β πJPARepositoryAdapter.java
β β β β πtest
β β β β β πjava
β β β β β β π[package]
β β β β β β β πjpa
β β β β β β β β πhelper
β β β πbuild.gradle
The generateEntryPoint | gep
task will generate a module in Infrastructure layer, this task has one required parameter type
.
Whether you'll use generic one also parameter name
is required.
gradle generateEntryPoint --type=[entryPointType]
gradle gep --type [entryPointType]
Reference for entryPointType | Name | Additional Options |
---|---|---|
generic | Empty Entry Point | --name [name] |
restmvc | API REST (Spring Boot Starter Web) | --server [serverOption] default undertow |
webflux | API REST (Spring Boot Starter WebFlux) | --router [true, false] default true |
rsocket | Rsocket Controller Entry Point | |
graphql | API GraphQL | --pathgql [name path] default /graphql |
asynceventhandler | Async Event Handler | |
mq | JMS MQ Client to listen messages |
Additionally, if you'll use a restmvc, you can specify the web server on which the application will run. By default, undertow.
```shell
gradle generateEntryPoint --type=restmvc --server=[serverOption] gradle gep --type=restmvc --server=[serverOption]
| Reference for **serverOption** | Name |
| ------------------------------ | ------------------------- |
| undertow | Undertow server (default) |
| tomcat | Tomcat server |
| jetty | Jetty server |
_**This task will generate something like that:**_
```bash
π¦infrastructure
β£ πentry-points
β β πgeneric
β β β£ πsrc
β β β β£ πmain
β β β β β πjava
β β β β β β π[package]
β β β β β β β πgeneric
β β β β πtest
β β β β β πjava
β β β β β β π[package]
β β β β β β β πgeneric
β β β πbuild.gradle
The generateHelper | gh
task will generate a module in Infrastructure layer, this task has one required parameter name
.
gradle generateHelper --name=[helperName]
gradle gh --name=[helperName]
The generatePipeline | gpl
task will generate CI pipeline inside the folder "./deployment/", this task has one required parameter type
.
gradle generatePipeline --type=[pipelineType]
gradle gpl --type=[pipelineType]
Reference for pipelineType | Name |
---|---|
azure | Azure Pipeline |
github | GitHub Action |
The generateAcceptanceTest | gat
task will generate subproject by karate framework inside the folder "./deployment/",this task does not have required parameters.
```shell
gradle generateAcceptanceTest
gradle gat
```
Karate is an open-source tool to combine API test-automation, mocks, performance-testing and even UI automation into a single, unified framework. The BDD syntax popularized by Cucumber is language-neutral, and easy for even non-programmers. Assertions and HTML reports are built-in, and you can run tests in parallel for speed.
The validateStructure | vs
Validate that project references aren't violated.
gradle validateStructure
gradle vs
The deleteModule | dm
task will delete a sub project, this task has one required parameter module
.
gradle deleteModule --module=[name]
gradle dm --module=[name]
Review the issues, we hear new ideas. Read more Contributing
Read more About Clean Architecure