Skip to content

amithfernando/forge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Forge Maven Plugin

Forge is a custom Maven plugin for Java projects that helps generate development and deployment artifacts automatically, improving productivity and standardizing outputs across services.

It provides tooling for:

  • Code analysis & visualization
  • Containerization (Docker)
  • Kubernetes resource generation

🚀 Features

🔍 Code Analysis

  • Scans Java source code
  • Detects Spring @Service classes
  • Generates PlantUML sequence diagrams for public methods
  • Uses JavaParser for static analysis

🐳 Dockerfile Generation

  • Generates production-ready Dockerfiles
  • Supports default and custom templates
  • Configurable base image and ports

☸️ Kubernetes YAML Generation

  • Generates:
    • Deployment
    • Service
    • ConfigMap
  • Scans:
    • application.properties
    • application.yml
    • application.yaml
  • Extracts environment variables and maps them to Kubernetes configs

📦 Installation

Build and install locally:

mvn clean install

This installs the plugin into your local Maven repository.


⚙️ Usage

Add the plugin to your project's pom.xml:

<plugin>
  <groupId>com.amithfernando.forge</groupId>
  <artifactId>forge</artifactId>
  <version>0.0.1</version>
  <executions>
    <execution>
      <id>generate-forge-assets</id>
      <goals>
        <goal>analyze</goal>
        <goal>docker</goal>
        <goal>k8s</goal>
      </goals>
    </execution>
  </executions>
</plugin>

Run goals:

mvn forge:analyze
mvn forge:docker
mvn forge:k8s

🧩 Maven Goals

forge:analyze

Generates PlantUML sequence diagrams.

Defaults:

  • Source: src/main/java
  • Output: target/forge/sequences

Example:

mvn forge:analyze -Dforge.includePackages=com.example.service

forge:docker

Generates a Dockerfile.

Example:

mvn forge:docker

Properties:

  • forge.docker.baseImage
  • forge.docker.port
  • forge.docker.template

forge:k8s

Generates Kubernetes manifests.

Example:

mvn forge:k8s \
-Dforge.k8s.image=my-registry/my-app:latest \
-Dforge.k8s.replicas=2 \
-Dforge.k8s.containerPort=8080 \
-Dforge.k8s.servicePort=80

Properties:

  • forge.k8s.image
  • forge.k8s.replicas
  • forge.k8s.containerPort
  • forge.k8s.servicePort
  • forge.k8s.serviceType
  • forge.k8s.template
  • forge.k8s.config.enabled
  • forge.k8s.config.scanEnv

📁 Output Structure

target/
 └── forge/
     ├── sequences/
     │    ├── UserService_createUser.puml
     │    └── OrderService_placeOrder.puml
     └── k8s.yaml

Dockerfile

📝 Example Outputs

Sequence Diagram (PlantUML)

@startuml
User -> UserService : createUser()
UserService -> Repository : save()
@enduml

🧠 How It Works

  1. Analyze Goal
  • Parses Java code using JavaParser
  • Identifies Spring services
  • Builds method interaction flows
  1. Docker Goal
  • Applies template
  • Injects configuration properties
  1. K8s Goal
  • Reads application config
  • Extracts environment variables
  • Generates Kubernetes YAML

📊 Logging

The plugin logs:

  • Source and output paths
  • Detected service classes
  • Generated files
  • Environment variables found
  • Config file usage

⚠️ Limitations

Analyze

  • Static analysis only
  • Does not capture:
    • Runtime proxies
    • AOP behavior
    • Reflection
    • Dynamic dispatch

Kubernetes

  • Not production-ready by default
  • Requires manual adjustments for:
    • Secrets
    • Ingress
    • Monitoring
    • Security policies

🛣️ Roadmap

Planned improvements:

  • Support for additional Spring annotations (@Component, @RestController)
  • Better call graph resolution
  • Multi-module project support
  • Helm chart generation
  • Native support for Secrets
  • Ingress and observability configs

🤝 Contributing

Contributions are welcome!

  1. Fork the repository
  2. Create a feature branch
  3. Commit your changes
  4. Open a pull request

🧪 Testing

Run tests with:

mvn test

📄 License

This project is licensed under the MIT License.


👤 Author

Amith Fernando

Custom Maven plugin for:

  • Code analysis
  • Container generation
  • Kubernetes automation

⭐ Support

If you find this project useful:

  • Star the repository ⭐
  • Share it with others
  • Contribute improvements

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages