How vavr-io/vavr works
Project Type and Purpose
• Vavr is an open-source, multi-module Maven project that provides an object-functional extension for Java.
• It consists of a Scala-based code generator module plus a core library module delivering immutable collections, functional control structures, pattern matching, concurrency abstractions, etc.
High-Level File‐Structure Analysis
• Top-level:
– pom.xml (parent POM orchestrating modules)
– .github/ (CI/CD workflows: ci.yml, doclint-version.yml, release.yml)
– vavr/ (multi-module directory)
• vavr/generator (Scala module)
– Generator.scala: generates Java sources under vavr/src-gen
– Its own pom.xml, invoked during a Maven build
• vavr/src-gen (generated code)
– main/java/io/vavr: API.java, FunctionN, TupleN, etc.
– test/java/io/vavr: unit tests for generated code
• vavr/src/main/java (core library)
– io.vavr.collection, io.vavr.control, io.vavr.concurrent, value types, pattern-matching support
• vavr/src/test/java (core tests)
• .github/workflows (CI pipelines)
README Insights
• Describes library features, Maven/Gradle usage, and contributors’ branches.
• No runtime services or external dependencies beyond the JVM.
Main Components
A. Developer + GitHub Repository
• Source code (generator + core)
• GitHub Actions workflows (CI, doclint, release)
B. Build System (Maven)
• Parent POM orchestrates two child modules:
1. generator module (Scala) → produces vavr/src-gen
2. core library module (Java) → consumes both src/main and src-gen
• Lifecycle phases: generate-sources → compile → test → package → verify → deploy
C. Code Generator Module
• Reads configuration/templates → generates Java API/FunctionN/TupleN classes → writes to src-gen
D. Core Library Module
• Packages:
– io.vavr.collection (persistent collections)
– io.vavr.control (Either, Option, Try, Validation)
– io.vavr.concurrent (Future, Promise, Task)
– io.vavr (Lazy, PartialFunction, MatchError, etc.)
• Unit tests validate both handwritten and generated code
• Javadoc plugin for API docs
E. CI/CD Pipeline
• CI workflow: runs mvn clean test, jacoco, code coverage
• doclint workflow: generates Javadoc, checks doc style
• release workflow: on tag → mvn deploy → publish to Maven Central
F. Consumers
• Maven Central / Gradle users fetch io.vavr:vavr jar
Relationships and Data Flows
• Developer push → GitHub repo triggers CI workflows
• CI invokes Maven parent POM
→ generator module runs in generate-sources phase → outputs to vavr/src-gen
→ compiler compiles src/main + src-gen
→ tests run (on core + generated code)
→ package phase produces .jar, source.jar, javadoc.jar
• Release workflow pushes artifacts to Maven Central
• End users (Java developers) retrieve artifact as a dependency
Architectural Patterns and Design Principles
• Multi-module Maven (separation of concerns: code generation vs. core logic)
• Code-generation pipeline (Scala → Java) to avoid boilerplate in API
• Clear package boundaries for functional domains (collection, control, concurrent)
• Immutable and persistent data structures throughout the library