Skip to content

Generation of modularized Gradle projects in different logic layers

License

Notifications You must be signed in to change notification settings

cdsap/ProjectGenerator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Project Generator

CLI generating modularized Gradle projects based on different shapes

Usage

CLI

./projectGenerator --shape triangle --layers 5 --modules 100

This command generates a project with 100 modules using Kotlin DSL. The project is divided in 5 layers + 1 layer acting as a main entry point of the project. The project generated guarantee relationships for project dependencies in the contiguous layers.

Install CLI

curl -L https://github.com/cdsap/ProjectGenerator/releases/download/v0.1.6/projectGenerator --output projectGenerator
chmod 0757 projectGenerator
./projectGenerator --shape triangle --layers 5 --modules 100

Library

ProjectGenerator(
    modules = 50,
    shape = Shape.MIDDLE_BOTTLENECK,
    layers = 5
).write()

Dependency

  implementation("io.github.cdsap:projectgenerator:0.1.6")

Options

modules

Number of modules to create in the project

layers

Number of layers where the modules will be distributed.

shape

Defines the shape of the project dependency graph based on the distribution of modules by layer. Current shapes supported:

triangle

Triangle

inverse_triangle

Triangle

rhombus

Rhombus

rectangle

Rectangle

flat

Flat

middle_bottleneck

Flat

language

kts

default

The project generated includes modules build scripts in Kotlin DSL

groovy

The project generated includes modules build scripts in Groovy

both

Two projects will be generated using Kotlin DSL and Groovy

Example

// dependency
ProjectGenerator(
    modules = 50,
    shape = Shape.MIDDLE_BOTTLENECK,
    layers = 5,
    language = Language.GROOVY
).write()

// cli
./projectGenerator --shape triangle --layers 5 --modules 100 --language groovy

type

Type of project generated:

android

default

Android project

jvm

Kotlin-JVM project

Example

// dependency
ProjectGenerator(
    modules = 50,
    shape = Shape.MIDDLE_BOTTLENECK,
    layers = 5,
    typeOfProjectRequested = TypeProjectRequested.JVM
).write()

// cli
./projectGenerator --shape triangle --layers 5 --modules 100 --type jvm

Classes Module

Classes generated per module, options:

  • classes: Classes to generate per module. Default 5.
  • type:
    • Fixed(default): Each module will create n classes where n represents the argument classes.
    • Random: Each module will create Random.nextInt(2, classesPerModule.classes) classes.

Example

// dependency
ProjectGenerator(
    modules = 50,
    layers = 5,
    shape = Shape.INVERSE_TRIANGLE,
    classesPerModule = ClassesPerModule(ClassesPerModuleType.RANDOM,100)
)

// cli
./projectGenerator --shape triangle --layers 5 --modules 100 --classes-module-type random --classes-module 150

AGP/KGP

AGP version

Android Gradle Plugin version (default 8.5.1)

Example
// dependency
ProjectGenerator(
    modules = 50,
    layers = 5,
    shape = Shape.INVERSE_TRIANGLE,
    versions = Versions(agp = "8.1.3")
)

// cli
./projectGenerator --shape triangle --layers 5 --modules 100 --agp-version 8.1.3

KGP version

Kotlin Gradle Plugin version (default 1.9.24)

Example
// dependency
ProjectGenerator(
    modules = 50,
    layers = 5,
    shape = Shape.INVERSE_TRIANGLE,
    versions = Versions(kgp = "1.9.0")
)

// cli
./projectGenerator --shape triangle --layers 5 --modules 100 --kgp-version 1.9.0

String Resources type

Normal

Each module generated includes 8 string resources in the file strings.xml. Default.

Large

Each module generated includes 900 string resources in the file strings.xml

Example
// dependency
ProjectGenerator(
    modules = 50,
    layers = 5,
    shape = Shape.INVERSE_TRIANGLE,
    typeOfStringResources = TypeOfStringResources.LARGE
)

// cli
./projectGenerator --shape triangle --layers 5 --modules 100 --type-of-string-rresources large

Generate Unit Test

default false

If enabled, each module will generate n unit tests, where n is the argument classes

Example
// dependency
ProjectGenerator(
    modules = 50,
    layers = 5,
    shape = Shape.INVERSE_TRIANGLE,
    generateUnitTest = true
)

// cli
./projectGenerator --shape triangle --layers 5 --modules 100 --generate-unit-test true

Gradle

Gradle used, versions supported:

  • Gradle 8.2
  • Gradle 8.5
  • Gradle 8.9. default
Example
// dependency
ProjectGenerator(
    modules = 50,
    layers = 5,
    shape = Shape.INVERSE_TRIANGLE,
    gradle = GradleWrapper(Gradle.GRADLE_7_6_2)
)

// cli
./projectGenerator --shape triangle --layers 5 --modules 100 --gradle 7.6.2

Dependency Plugins

default false

Includes in the root build gradle the plugins:

Example
// dependency
ProjectGenerator(
    modules = 50,
    layers = 5,
    shape = Shape.INVERSE_TRIANGLE,
    dependencyPlugins = true
)

// cli
./projectGenerator --shape triangle --layers 5 --modules 100 --dependency-plugins true

Extending Project

The default project generated is composed by the modules and one convention plugin defined as composite build. This convention plugin is used in all the modules of the project.

If you want to extend the build logic used in the project:

Main root Build Gradle

BuildGradle.kt

Gradle properties

GradleProperties.kt

Root Settings Gradle

SettingsGradle.kt

Build Gradle composite build

CompositeBuildBuildGradle.kt

Convention Plugin used in the modules

CompositeBuildPlugin1.kt

Settings Gradle composite build

CompositeBuildSettingsGradle.kt

Libraries used

About

Generation of modularized Gradle projects in different logic layers

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages