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.6.9"
}
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
gradle cleanArchitecture --package=co.com.bancolombia --type=imperative --name=NameProject --coverage=jacoco gradle ca --package=co.com.bancolombia --type=imperative --name=NameProject --coverage=jacoco
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]
When use
mongodb
type please be sure that property 'reactive' is set correctly in gradle.properties-
For reactive projects should be:
reactive=true
-
For imperative projects should be:
reactive=false
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 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) webflux API REST (Spring Boot Starter WebFlux) 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
-
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