Skip to content

About

How to make use of Antikythera

Resources

Stars

0 stars

Watchers

1 watching

Forks

Repository files navigation

Antikythera Examples

This module provides a suite of advanced utilities and tools built on top of the Antikythera framework. It serves as both a showcase of the framework's capabilities and a production-ready toolkit for Java/Spring Boot code analysis, optimization, and migration.

Table of Contents


General Configuration

Many tools in this project utilize a shared configuration format (typically generator.yml) to define project paths, AI service credentials, and other environment specifics.

Common Configuration Structure (generator.yml)

variables:
  projects_folder: ${HOME}/your-projects
  m2_folder: ${HOME}/.m2/repository

base_path: ${projects_folder}/your-project/

ai_service:
  provider: "gemini"
  model: "gemini-2.5-flash-lite-preview-09-2025"
  api_endpoint: "https://generativelanguage.googleapis.com/v1beta/models/{model}:generateContent"
  api_key: "${GEMINI_API_KEY}"
  timeout_seconds: 90
  max_retries: 2
  track_usage: true
  cost_per_1k_tokens: 0.00015

Key Requirements:

  • base_path: Must point to the root of the project you are analyzing/modifying.
  • GEMINI_API_KEY: Required for AI-powered features (Query Optimizer, Migrators).
  • Environment Variables: You can use ${VAR} syntax to reference environment variables.

Development Setup

If you want to extend these examples or debug the underlying Antikythera framework:

Build & Test

mvn clean compile
mvn test

IDE Setup (IntelliJ IDEA)

You can link the local antikythera source code to this project for seamless debugging:

  1. Module Approach (Recommended): Import the antikythera project as a module in the same IntelliJ window. IntelliJ will automatically use module dependencies.
  2. Attach Sources: In "Project Structure > Libraries", find sa.com.cloudsolutions:antikythera and click "Attach Sources...", pointing to your local antikythera source root.

Maven Parent POM Converter

A tool that converts Maven POMs with parent inheritance into completely standalone POMs by expanding all inherited configuration (<properties>, <dependencies>, <plugins>, <profiles>).

Quick Start

mvn exec:java -Dexec.mainClass="com.raditha.maven.PomFlattenerCLI"
# Run inside your project directory

Features

  • ✅ Resolves parent POMs from local repository or relativePath
  • ✅ Supports multi-level parent hierarchies
  • ✅ Merges all inherited configurations
  • ✅ Automatic timestamped backups

📖 User Guide


Query Optimizer

A comprehensive system for analyzing and optimizing Spring Data JPA repositories. It uses AI to optimize SQL/JPQL queries and an automated refactoring engine to apply those changes.

Quick Start

Analysis Only:

mvn exec:java -Dexec.mainClass="sa.com.cloudsolutions.antikythera.examples.QueryOptimizationChecker"

Optimization (Apply Changes):

mvn exec:java -Dexec.mainClass="sa.com.cloudsolutions.antikythera.examples.QueryOptimizer"

Features

  • AI-Powered Optimization: Uses LLMs to rewrite inefficient queries based on schema and cardinality.
  • Liquibase Generation: Automatically generates changesets for missing indexes.
  • Safe Refactoring: Updates @Query annotations and dependent method calls while preserving formatting.

Specific Configuration

Ensure your generator.yml is set up with valid AI service credentials and points to your project's base_path.


JPA Repository Analyzer

Bulk exports all JPA repository queries to CSV for auditing and analysis.

Quick Start

mvn exec:java -Dexec.mainClass="sa.com.cloudsolutions.antikythera.examples.JPARepositoryAnalyzer" \
  -Dexec.args="-b /path/to/project -o repository_queries.csv"

Features

  • Extracts all @Query annotations from JPA repositories
  • Exports query metadata to CSV format
  • Supports custom output file paths
  • Analyzes both explicit queries and derived query methods

Spring Boot Migration Tools

Automated tools to upgrade Spring Boot applications across major/minor versions.

Spring Boot 2.1→2.2 Migrator

Upgrades Spring Boot 2.1 apps to 2.2.

java -cp target/classes com.raditha.spring.SpringBoot21to22Migrator --project-path /path/to/project

📖 Documentation

Spring Boot 2.2→2.3 Migrator

Upgrades Spring Boot 2.2 apps to 2.3, handling validation changes, H2 console config, and more.

java -cp target/classes com.raditha.spring.SpringBoot22to23Migrator --project-path /path/to/project

📖 Quick Start

Spring Boot 2.3→2.4 Migrator

Upgrades Spring Boot 2.3 apps to 2.4.

java -cp target/classes com.raditha.spring.SpringBoot23to24Migrator --project-path /path/to/project

Spring Boot 2.4→2.5 Migrator

Upgrades Spring Boot 2.4 apps to 2.5.

java -cp target/classes com.raditha.spring.SpringBoot24to25Migrator --project-path /path/to/project

Spring Boot Version Detector

Detects the Spring Boot version from a POM file.

java -cp target/classes sa.com.cloudsolutions.antikythera.examples.SpringBootVersionDetector /path/to/pom.xml

Outputs the detected Spring Boot version to stdout.

Circular Dependency Tool

Detects and resolves circular bean dependencies using strategies like @Lazy, setter injection, and Method Extraction for @PostConstruct cycles.

Quick Start:

mvn exec:java -Dexec.mainClass="com.raditha.spring.cycle.CircularDependencyTool" \
  -Dexec.args="--config your-config.yml --strategy auto"

📖 Documentation


Code Quality & Analysis Tools

AnnotationFinder

Finds all classes and methods annotated with a specific annotation.

Quick Start:

# Detailed output (default) - includes full method signatures
mvn exec:java -Dexec.mainClass="sa.com.cloudsolutions.antikythera.examples.AnnotationFinder" \
  -Dexec.args="Service"

# Simple output - method name only, duplicates eliminated
mvn exec:java -Dexec.mainClass="sa.com.cloudsolutions.antikythera.examples.AnnotationFinder" \
  -Dexec.args="Service --simple"

Features:

  • Searches entire codebase for specified annotation
  • Handles both simple names (e.g., Service) and fully qualified names (e.g., org.springframework.stereotype.Service)
  • Two output modes: detailed (default) and simple
  • Supports any annotation name (e.g., @Service, @Test, @Entity, @Query)

Output Format:

  • Class annotations: com.example.MyService (same in both modes)
  • Method annotations (detailed mode): com.example.MyClass#print() or com.example.MyClass#print(String s)
  • Method annotations (simple mode): com.example.MyClass#print (method name only, no duplicates for overloaded methods)

Options:

  • --simple or -s: Enable simple output mode (method name only, eliminates duplicates)

TestFixer

Identifies and fixes bad testing patterns (missing assertions, framework migration).

mvn exec:java -Dexec.mainClass="sa.com.cloudsolutions.antikythera.examples.TestFixer" -Dexec.args="--dry-run"

📖 Documentation

Logger Analysis

Analyzes and standardizes logger usage across the codebase, ensuring consistent logging patterns.

mvn exec:java -Dexec.mainClass="sa.com.cloudsolutions.antikythera.examples.Logger"

Processes all classes in the project and standardizes logger field declarations and usage.

Liquibase Tools

#Audits database indexes defined in Liquibase changelogs.

mvn exec:java -Dexec.mainClass="sa.com.cloudsolutions.liquibase.Indexes" -Dexec.args="path/to/db.changelog-master.xml"

📖 Documentation

Liquibase Validator

Validates Liquibase changelog XML files for syntax errors and structural issues.

mvn exec:java -Dexec.mainClass="sa.com.cloudsolutions.antikythera.mcp.LiquibaseValidator" \
  -Dexec.args="path/to/changelog.xml"

Outputs validation results in JSON format with exit code 0 for valid files, 1 for invalid.

Liquibase Validation MCP Server

MCP (Model Context Protocol) server for Liquibase validation, enabling integration with AI agents and tools.

mvn exec:java -Dexec.mainClass="sa.com.cloudsolutions.antikythera.mcp.LiquibaseValidationMcpServer"

Starts an MCP server that provides Liquibase validation capabilities via the MCP protocol.

HardDelete Detection

Finds hard delete operations in repositories to enforce soft-delete policies.

mvn exec:java -Dexec.mainClass="sa.com.cloudsolutions.antikythera.examples.HardDelete"

📖 Documentation

UsageFinder

Analyzes collection usage (List, Set, Map) in non-entity classes to detect potential memory issues or N+1 problems.

mvn exec:java -Dexec.mainClass="sa.com.cloudsolutions.antikythera.examples.UsageFinder"

📖 Documentation — includes the helper API and validation metric used in tests.


Knowledge Graph

KnowledgeGraphCLI

Generates knowledge graphs from Java codebases, visualizing relationships between classes, methods, and dependencies.

mvn exec:java -Dexec.mainClass="com.raditha.graph.KnowledgeGraphCLI" \
  -Dexec.args="--base-path=/path/to/project --config=src/main/resources/graph.yml"

Features

  • Builds comprehensive dependency graphs
  • Configurable analysis scope via YAML configuration
  • Visualizes code relationships and dependencies

About

How to make use of Antikythera

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages