Quality Gate Status Maintainability Rating codecov GitHub license

Scaffolding of Clean Architecture

Gradle plugin to create a java application based on Clean Architecture following our best practices!

Plugin Implementation

To use the plugin you need Gradle version 5 or later, to start add the following section into your build.gradle file.

plugins {
 id "co.com.bancolombia.cleanArchitecture" version "1.6.4"
}

Tasks

The Scaffolding Clean Architecture plugin will allow you run 8 tasks :

1 The cleanArchitecture | ca task will generate a clean architecture structure in your project, this task has three optional parameters; package , type and name.

package = <package.we.need>: You can specify the main or default package of your project. Default Value = co.com.bancolombia

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

2 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

3 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

4 The generateDrivenAdapter | gda task will generate a class 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]

When use MONGODB type please be sure that property 'reactive' is set correctly in gradle.properties

reactive=true
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

5 The generateEntryPoint | gep task will generate a class 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)
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

6 The validateStructure | vs Validate that project references aren't violated.

gradle validateStructure  
gradle vs

7 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

8 The deleteModule | dm task will delete a sub project, this task has one required parameter module.

gradle deleteModule --module=[name]
gradle dm --module=[name]

How I can help?

Review the issues, we hear new ideas.

Whats Next?

Read more About Clean Architecure