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.8.8"
}
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
andcoverage
.-
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 parametername
.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 parametername
.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 class in Infrastructure layer, this task has one required parametertype
.
Whether you'll use generic one also parametername
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 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 class in Infrastructure layer, this task has one required parametertype
.
Whether you'll use generic one also parametername
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 Additionally, if you'll use a restmvc, you can specify the web server on which the application will run. By default, undertow.
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:
📦infrastructure ┣ 📂entry-points ┃ ┗ 📂generic ┃ ┃ ┣ 📂src ┃ ┃ ┃ ┣ 📂main ┃ ┃ ┃ ┃ ┗ 📂java ┃ ┃ ┃ ┃ ┃ ┗ 📂[package] ┃ ┃ ┃ ┃ ┃ ┃ ┗ 📂generic ┃ ┃ ┃ ┗ 📂test ┃ ┃ ┃ ┃ ┗ 📂java ┃ ┃ ┃ ┃ ┃ ┗ 📂[package] ┃ ┃ ┃ ┃ ┃ ┃ ┗ 📂generic ┃ ┃ ┗ 📜build.gradle
-
The
validateStructure | vs
Validate that project references aren't violated.gradle validateStructure gradle vs
-
The
generatePipeline | gpl
task will generate CI pipeline inside the folder "./deployment/", this task has one required parametertype
.gradle generatePipeline --type=[pipelineType] gradle gpl --type=[pipelineType]
Reference for pipelineType Name azure Azure Pipeline github GitHub Action
-
The
deleteModule | dm
task will delete a sub project, this task has one required parametermodule
.gradle deleteModule --module=[name] gradle dm --module=[name]
Review the issues, we hear new ideas. Read more Contributing
Read more About Clean Architecure