Skip to content

guiaf04/spring-scaffold

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

32 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Spring Scaffold CLI

Maven Central CI Quality Gate Status License: MIT

πŸš€ Version 2.1.3 - Command-line application to assist in building Java and Spring Boot applications, offering automatic and functional scaffold generation for models, controllers, services, repositories, and complete projects.

πŸ“¦ Installation

Maven Central

Add to your pom.xml:

<dependency>
    <groupId>io.github.guiaf04</groupId>
    <artifactId>spring-scaffold-cli</artifactId>
    <version>2.1.3</version>
</dependency>

From Source

git clone https://github.com/guiaf04/spring-scaffold.git
cd spring-scaffold
mvn clean package -DskipTests

Pre-built JAR

Download from GitHub Releases

✨ What's New in v2.1.3

πŸš€ CI/CD & Release Management

  • Complete DevOps Pipeline: Automated CI/CD with GitHub Actions
  • Maven Central Integration: Automated deployment with GPG signing
  • Quality Assurance: SonarCloud integration and security scanning
  • Release Automation: Streamlined release process with automated testing

πŸ”§ Enhanced Developer Experience (v2.1.2)

  • Improved Documentation: Clear setup instructions for all integrations
  • Better Configuration: Enhanced workflow clarity and API key guidance

🎯 Intuitive Syntax and Positional Parameters (v2.1.0)

  • Short aliases: --pkg, --deps, --entity, --db, -p, -m, -t
  • Positional parameters: spring-scaffold model User name:String email:String age:Integer
  • 50% faster development: Less typing, more productivity
  • 100% compatible: All old syntax continues to work

✨ Features

🎯 Code Generation (100% Functional)

  • Models/Entities: Class creation with JPA annotations, validations, Lombok and constructors
  • Controllers: Complete REST controllers with CRUD endpoints, Swagger and validations
  • Services: Service classes with interfaces, implementations and transactions
  • Repositories: JPA/MongoDB repository interfaces with custom queries
  • Projects: Complete Spring Boot projects with Maven structure

πŸ—οΈ Project Templates

  • Spring Boot Project: Complete structure with pom.xml, application.properties
  • Database Configurations: Support for H2, MySQL, PostgreSQL
  • Docker: Optional Dockerfile files
  • Documentation: Automatic README.md and .gitignore

πŸš€ Quick Start

Prerequisites

  • Java 17+
  • Maven 3.8+

Basic Usage

🎯 New Syntax (v2.1.0) - Recommended

# Generate a model with natural syntax
./spring-scaffold model User name:String email:String age:Integer --pkg com.example.entity

# Generate a controller with aliases
./spring-scaffold controller UserController --entity User --pkg com.example.controller

# Generate a service with shortcuts
./spring-scaffold service UserService -m User -p com.example.service

# Generate a concise repository
./spring-scaffold repository UserRepository -m User -p com.example.repository -t JPA

# Create new project with aliases
./spring-scaffold project my-spring-app --pkg com.example.myapp --deps web,jpa,security

βšͺ Classic Syntax (still works)

# Generate a model
./spring-scaffold model User -p com.example.model -f "name:String,email:String,age:Integer"

# Generate a controller
./spring-scaffold controller UserController -m User

# Generate a service
./spring-scaffold service UserService -m User

# Generate a repository
./spring-scaffold repository UserRepository -m User

# Create new project
./spring-scaffold project my-spring-app --package com.example.myapp

πŸ“š Available Commands

model

Generates a model/entity class with JPA annotations.

πŸ’« New Syntax (v2.1.0):

spring-scaffold model <ClassName> [field:type] [field:type] [options]

Examples:

# Natural syntax with positional parameters
spring-scaffold model User name:String email:String age:Integer

# With aliases and validation
spring-scaffold model Product name:String price:BigDecimal --pkg com.example.entity --valid

# Using shortcuts
spring-scaffold model Customer name:String email:String -p com.app.model --entity --data

Options:

  • -p, --pkg, --package <package>: Class package (default: com.example.model)
  • -f, --fields <fields>: Field list in "name:type,name:type" format (alternative to positional)
  • -t, --tbl, --table <table>: Table name (default: class name in snake_case)
  • --jpa, --entity: Add JPA annotations (default: true)
  • --data, --lombok: Use Lombok annotations (default: true)
  • --valid, --validation: Include Bean Validation annotations (default: false)

controller

Generates a REST controller with CRUD endpoints.

πŸ’« New Syntax (v2.1.0):

spring-scaffold controller <ControllerName> [options]

Examples:

# With intuitive aliases
spring-scaffold controller UserController --entity User --pkg com.example.controller

# Using shortcuts
spring-scaffold controller ProductController -m Product -p com.app.controller

Options:

  • -p, --pkg, --package <package>: Controller package (default: com.example.controller)
  • -m, --model, --entity <model>: Associated model class
  • --path <path>: API base path (default: /api/v1)

service

Generates a service class.

πŸ’« New Syntax (v2.1.0):

spring-scaffold service <ServiceName> [options]

Examples:

# With aliases
spring-scaffold service UserService --entity User --pkg com.example.service

# Maximum conciseness
spring-scaffold service ProductService -m Product -p com.app.service

Options:

  • -p, --pkg, --package <package>: Service package (default: com.example.service)
  • -m, --model, --entity <model>: Associated model class
  • --interface: Generate service interface (default: true)

repository

Generates a JPA repository.

πŸ’« New Syntax (v2.1.0):

spring-scaffold repository <RepositoryName> [options]

Examples:

# With aliases
spring-scaffold repository UserRepository --entity User --pkg com.example.repository

# Using single-letter shortcuts
spring-scaffold repository ProductRepository -m Product -p com.app.repo -t JPA

Options:

  • -p, --pkg, --package <package>: Repository package (default: com.example.repository)
  • -m, --model, --entity <model>: Associated model class
  • -t, --type <type>: Repository type (JPA, MongoDB) (default: JPA)

project

Creates a new Spring Boot project.

πŸ’« New Syntax (v2.1.0):

spring-scaffold project <project-name> [options]

Examples:

# With intuitive aliases
spring-scaffold project my-api --pkg com.example.myapi --deps web,jpa,security --db MYSQL

# Using shortcuts
spring-scaffold project ecommerce -p com.shop.ecommerce -d web,jpa,validation -s 3.2.0

Options:

  • -p, --pkg, --package <package>: Project base package (default: com.example)
  • -g, --group, --group-id <group>: Maven Group ID (default: --package value)
  • -s, --spring, --spring-version <version>: Spring Boot version (default: 3.2.0)
  • -j, --java, --java-version <version>: Java version (default: 17)
  • -d, --deps, --dependencies <deps>: Comma-separated dependencies
  • --db, --database <db>: Database type (H2, MYSQL, POSTGRESQL, MONGODB)

🎯 Syntax Comparison

Command ❌ Before (v2.0) βœ… Now (v2.1) πŸ’Ύ Savings
Model --package --fields name:String,email:String name:String email:String --pkg 35%
Project --package --dependencies --pkg --deps 50%
Controller --package --model --pkg --entity or -p -m 40%
Repository --package --model --type -p -m -t 65%

πŸ“ Examples

πŸš€ Creating a Complete CRUD (New Syntax v2.1)

# 1. Create the model with natural syntax
spring-scaffold model Product name:String price:BigDecimal description:String active:Boolean --pkg com.example.entity --valid

# 2. Create the repository with shortcuts
spring-scaffold repository ProductRepository -m Product -p com.example.repository

# 3. Create the concise service
spring-scaffold service ProductService -m Product -p com.example.service

# 4. Create the controller with aliases
spring-scaffold controller ProductController --entity Product --pkg com.example.controller

⚑ Rapid API Development

# Complete project with aliases
spring-scaffold project ecommerce-api --pkg com.example.ecommerce --deps web,jpa,security,validation --db POSTGRESQL

# Multiple entities quickly
cd ecommerce-api
spring-scaffold model User name:String email:String role:String
spring-scaffold model Order total:BigDecimal status:String userId:Long  
spring-scaffold model Item name:String price:BigDecimal stock:Integer

# Generate all layers with maximum efficiency
spring-scaffold controller UserController -m User -p com.example.ecommerce.controller
spring-scaffold controller OrderController -m Order -p com.example.ecommerce.controller
spring-scaffold controller ItemController -m Item -p com.example.ecommerce.controller

πŸ“Š Productivity Comparison

❌ Before (v2.0.0):

spring-scaffold model Customer --package com.example.entity --fields name:String,email:String,phone:String,age:Integer
spring-scaffold controller CustomerController --package com.example.controller --model Customer
spring-scaffold service CustomerService --package com.example.service --model Customer  
spring-scaffold repository CustomerRepository --package com.example.repository --model Customer --type JPA

βœ… Now (v2.1.0):

spring-scaffold model Customer name:String email:String phone:String age:Integer --pkg com.example.entity
spring-scaffold controller CustomerController --entity Customer --pkg com.example.controller
spring-scaffold service CustomerService -m Customer -p com.example.service
spring-scaffold repository CustomerRepository -m Customer -p com.example.repository -t JPA

🎯 Result: 50% less typing, more natural syntax!

🎯 Useful Command Templates

# Template for complete CRUD
ENTITY="Product"
PKG="com.example.ecommerce"

spring-scaffold model $ENTITY name:String price:BigDecimal --pkg $PKG.entity --valid
spring-scaffold repository ${ENTITY}Repository -m $ENTITY -p $PKG.repository
spring-scaffold service ${ENTITY}Service -m $ENTITY -p $PKG.service  
spring-scaffold controller ${ENTITY}Controller -m $ENTITY -p $PKG.controller

πŸ—οΈ Architecture

Project Structure

spring-scaffold-cli/
β”œβ”€β”€ src/main/java/
β”‚   β”œβ”€β”€ com/scaffold/
β”‚   β”‚   β”œβ”€β”€ SpringScaffoldCLI.java          # Main class
β”‚   β”‚   β”œβ”€β”€ commands/                        # CLI commands
β”‚   β”‚   β”‚   β”œβ”€β”€ ModelCommand.java
β”‚   β”‚   β”‚   β”œβ”€β”€ ControllerCommand.java
β”‚   β”‚   β”‚   β”œβ”€β”€ ServiceCommand.java
β”‚   β”‚   β”‚   β”œβ”€β”€ RepositoryCommand.java
β”‚   β”‚   β”‚   └── ProjectCommand.java
β”‚   β”‚   β”œβ”€β”€ generators/                      # Code generators
β”‚   β”‚   β”‚   β”œβ”€β”€ ModelGenerator.java
β”‚   β”‚   β”‚   β”œβ”€β”€ ControllerGenerator.java
β”‚   β”‚   β”‚   β”œβ”€β”€ ServiceGenerator.java
β”‚   β”‚   β”‚   β”œβ”€β”€ RepositoryGenerator.java
β”‚   β”‚   β”‚   └── ProjectGenerator.java
β”‚   β”‚   β”œβ”€β”€ templates/                       # Template engine
β”‚   β”‚   β”‚   β”œβ”€β”€ TemplateEngine.java
β”‚   β”‚   β”‚   └── TemplateContext.java
β”‚   β”‚   β”œβ”€β”€ models/                          # Data models
β”‚   β”‚   β”‚   β”œβ”€β”€ FieldInfo.java
β”‚   β”‚   β”‚   β”œβ”€β”€ ClassInfo.java
β”‚   β”‚   β”‚   └── ProjectInfo.java
β”‚   β”‚   └── utils/                           # Utilities
β”‚   β”‚       β”œβ”€β”€ FileUtils.java
β”‚   β”‚       β”œβ”€β”€ NamingUtils.java
β”‚   β”‚       └── ValidationUtils.java
β”œβ”€β”€ src/main/resources/
β”‚   └── templates/                           # Mustache templates
β”‚       β”œβ”€β”€ model.java.mustache
β”‚       β”œβ”€β”€ controller.java.mustache
β”‚       β”œβ”€β”€ service.java.mustache
β”‚       β”œβ”€β”€ service-impl.java.mustache
β”‚       β”œβ”€β”€ repository.java.mustache
β”‚       └── project/                         # Project templates
β”‚           β”œβ”€β”€ pom.xml.mustache
β”‚           β”œβ”€β”€ application.yml.mustache
β”‚           └── main-class.java.mustache
└── pom.xml

Technologies Used

  • Picocli: CLI framework
  • Mustache: Template engine
  • Lombok: Boilerplate reduction
  • Jackson: JSON/YAML manipulation
  • Maven: Dependency management

πŸ› οΈ Development

How to Contribute

  1. Fork the repository
  2. Create a branch for your feature (git checkout -b feature/new-feature)
  3. Commit your changes (git commit -am 'Add new feature')
  4. Push to the branch (git push origin feature/new-feature)
  5. Open a Pull Request

Adding New Commands

  1. Create command class in src/main/java/com/scaffold/commands/
  2. Implement generator in src/main/java/com/scaffold/generators/
  3. Create template in src/main/resources/templates/
  4. Register command in main class

Running Tests

mvn test

Template Testing

⚠️ Important: Always run the template test script instead of testing multiple commands manually:

./test-templates.sh

This script performs comprehensive testing of all templates:

  • βœ… Generates complete Spring Boot project
  • βœ… Tests all component generation (model, service, repository, controller)
  • βœ… Validates Maven compilation and tests
  • βœ… Verifies code quality and internationalization
  • βœ… Ensures all templates work correctly together

The script automatically cleans up test artifacts and provides detailed feedback on each test phase.

Build

mvn clean package

🌍 Documentation

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

🀝 Support

For support, open an issue on GitHub or contact through [email].

πŸ“‹ Changelog

Version 2.1.3 (2025-08-23)

  • πŸ”§ CI/CD Pipeline: Enhanced GPG key handling and Maven deployment configuration
  • πŸ› οΈ Release Workflow: Improved GPG agent configuration and Maven settings management
  • πŸ“¦ Deployment: Fixed GPG signing issues in Maven Central deployment process

Version 2.1.2 (2025-08-23)

  • πŸ“ Documentation: Updated SonarQube and OWASP Dependency Check workflow steps
  • πŸ”‘ Configuration: Added clear instructions for enabling API key requirements
  • πŸ”§ CI/CD: Improved workflow clarity and configuration guidance

Version 2.1.1 (2025-08-23)

  • πŸš€ CI/CD Pipeline: Complete GitHub Actions workflow implementation
  • πŸ“‹ Project Templates: Added GitHub templates and configuration
  • πŸ”§ Build System: Enhanced Maven configuration for Central publishing

Version 2.1.0 (2025-08-22)

  • ✨ NEW SYNTAX: Intuitive aliases and positional parameters
  • 🎯 Positional parameters: model User name:String email:String age:Integer
  • ⚑ Short aliases: --pkg, --deps, --entity, --db, -p, -m, -t
  • πŸš€ Productivity: Up to 50% faster development
  • πŸ”„ Compatibility: 100% compatible with v2.0.0 syntax
  • πŸ“ Documentation: Updated README with comparative examples
  • 🌍 Internationalization: Main docs in English, Portuguese in docs/pt-BR/

Version 2.0.0 (2025-08-22)

  • βœ… FUNCTIONAL: All commands now generate real files
  • 🎯 Complete REST controllers with CRUD, Swagger, validations
  • πŸ”§ Services with interface + implementation or single class
  • πŸ“¦ JPA repositories with custom queries
  • πŸ—οΈ Complete Spring Boot projects with Maven
  • πŸ› Bug fixes and stability improvements

Version 1.0.0 (2025-08-22)

  • πŸŽ‰ Initial version with CLI structure
  • πŸ“‹ Functional model command
  • ⚠️ Other commands only simulated generation

See CHANGELOG.md for complete details.

πŸ—ΊοΈ Roadmap

  • Kotlin support
  • Microservices templates
  • Spring Cloud integration
  • Automatic documentation generation
  • IDE plugins
  • GraphQL support
  • Performance testing templates