This document provides essential information for AI agents working on the iCal4j codebase.
iCal4j is a Java library for reading and writing iCalendar (RFC5545) data streams. It provides:
- Parser and builder for .ics files
- Object model for calendar components (events, todos, journals, etc.)
- Timezone support with Olson database integration
- Validation and transformation utilities
- Groovy DSL for calendar building
Key Stats:
- ~572 Java files + 148 Groovy files
- Java 11+ target (currently supports Java 17, 21)
- Uses Gradle build system
- Comprehensive test suite with Spock Framework
# Build the project
./gradlew build
# Run tests only
./gradlew test
# Run all checks (includes tests, validation, style checks)
./gradlew check
# Clean build
./gradlew clean
# Install to local Maven repository
./gradlew publishToMavenLocal# Recommended approach - uses Makefile wrapper
make clean # Clean build
make test # Run tests
make build # Build project
make check # Run all checks
make install # Install to local repo
make verify # Verify build# API compatibility checks
./gradlew revapi
make listApiChanges
# Coverage reports (enabled by default)
# Results in: build/reports/jacoco/test/html/index.html# Check current version
./gradlew -q currentVersion
make currentVersion
# Mark next version (for maintainers)
make markNextVersion <version>src/
├── main/java/net/fortuna/ical4j/
│ ├── model/ # Core object model
│ │ ├── component/ # Calendar components (VEvent, VTodo, etc.)
│ │ ├── property/ # Calendar properties (DtStart, Summary, etc.)
│ │ └── parameter/ # Property parameters (TzId, Value, etc.)
│ ├── data/ # Parsing and output
│ ├── validate/ # Validation framework
│ ├── filter/ # Filtering and querying
│ ├── transform/ # Data transformation
│ ├── util/ # Utilities
│ └── agent/ # User agent implementations
├── main/groovy/ # Groovy DSL and extensions
├── test/java/ # Java tests
├── test/groovy/ # Groovy/Spock tests
└── test/resources/ # Test resources and sample files
- Classes: PascalCase (
VEvent,DtStart,CalendarBuilder) - Properties: camelCase (
dtStart,lastModified) - Constants: UPPER_SNAKE_CASE (
PROPERTY_NAME) - Packages: lowercase dot notation (
net.fortuna.ical4j.model)
- Properties extend
Propertybase class - Components extend
Componentbase class - Immutable variants exist for core properties (in
immutable/packages) - Factory pattern used extensively for object creation
- Model classes follow RFC5545 structure closely
- Property names match iCalendar specification (DTSTART → DtStart)
- Parameter names often use underscore suffix in DSL (
tzid_for TZID parameter)
All Java files include BSD-3-Clause license header:
/**
* Copyright (c) 2012, Ben Fortuna
* All rights reserved.
* ...
*/- Extensive Javadoc with RFC references
- Properties include RFC section quotes in class documentation
- Package-level documentation in
package-info.javafiles
- Java Tests: JUnit 5 for unit tests
- Groovy Tests: Spock Framework for BDD-style tests
- Test Resources: Sample .ics files in
src/test/resources/
- Groovy specs use
SomeClassSpec.groovypattern - Java tests use
SomeClassTest.javapattern - Test methods descriptive:
"test Component.calculateRecurrenceSet"
// Spock data-driven tests
where:
period | expectedResults
value1 | result1
value2 | result2
// Content builder for test data
ContentBuilder builder = []
VEvent event = builder.vevent {
dtstart '20240101T140000'
summary 'Test Event'
}- Java Features: Multiple optional feature sets (groovyDsl, schemaValidation, etc.)
- Testing: JUnit Platform with Spock integration
- Coverage: Jacoco with 70% minimum threshold (non-failing)
- Publishing: Maven Central deployment
- Signing: GPG signing for releases
- Core: SLF4J, Commons Lang3, Commons Collections4, ThreeTen-Extra
- Optional: Caffeine (caching), JParsec (expressions), Groovy (DSL)
- Test: Spock, JUnit 5, Hamcrest, Testcontainers
gradle.properties- Build configurationgradle/libs.versions.toml- Version catalogsettings.gradle- Project settings
- Read existing code - Follow established patterns
- Check RFC compliance - Properties/components must match specifications
- Add tests - Both unit tests and integration tests
- Validate - Run
make checkbefore committing - API compatibility - Run
make listApiChangesfor public API changes
- Adding Properties: Extend
Property, add factory, add tests - Adding Components: Extend
Component, add validation rules, add tests - Parser Changes: Update
CalendarParserImpl, add test samples - Validation: Add rules to appropriate validator classes
- Properties must match RFC5545 specification exactly
- Parameter names and values follow iCalendar standards
- Validation rules enforce RFC requirements
- Test with real-world calendar files
Key configuration properties (see README.md for full list):
# Relaxed parsing for non-compliant files
ical4j.parsing.relaxed=true
ical4j.unfolding.relaxed=true
ical4j.validation.relaxed=true
# Compatibility modes
ical4j.compatibility.outlook=true
ical4j.compatibility.notes=true
# Timezone configuration
net.fortuna.ical4j.timezone.cache.impl=net.fortuna.ical4j.util.MapTimeZoneCache
net.fortuna.ical4j.timezone.update.enabled=true- Microsoft Outlook: Special folding and parsing rules
- Lotus Notes: Alternative property handling
- Mozilla Calendar: Relaxed unfolding support
- Version 4.x: Uses new Java Date/Time API (
LocalDate,ZonedDateTime, etc.) - Version 3.x: Uses legacy
Date/DateTimeclasses - Time zones handled via
TimeZoneRegistryand embedded Olson database
- Line folding can vary between implementations
- Non-standard properties may need relaxed parsing
- Timezone definitions should be included in calendar files
- Large calendars with many recurrences can consume significant memory
- Timezone cache implementation affects memory usage
- Consider streaming for very large files
- Requires Java 11+ for building
- Gradle wrapper handles Gradle version
- Docker available for timezone data updates
- Unit Tests: Individual class functionality
- Integration Tests: Full parsing/building workflows
- Compatibility Tests: Real-world calendar files
- Performance Tests: Large dataset handling
- Checkstyle: Code style enforcement (config in
etc/checkstyle.xml) - Jacoco: Code coverage reporting (70% minimum)
- RevApi: API compatibility checking
- SpotBugs: Static analysis (when enabled)
Test resources include samples for:
- Various calendar applications (Outlook, Apple Calendar, Google Calendar)
- Edge cases and malformed files
- Timezone handling scenarios
- Recurrence pattern validation
- RFC5545: iCalendar Core Object Specification
- RFC5546: iCalendar Transport-Independent Interoperability Protocol (iTIP)
- RFC7986: New Properties for iCalendar
- See README.md for complete RFC list
- Build: Gradle 8.x with wrapper
- Testing: Spock Framework, JUnit 5
- CI/CD: GitHub Actions workflows
- IDE: IntelliJ IDEA project configuration included