A collection of utility libraries for Kotlin and Java development.
This repository contains a modular collection of utility libraries designed to simplify and enhance Kotlin and Java development. Each module focuses on a specific domain or framework, providing extension functions, DSLs, and utility classes that reduce boilerplate code and improve developer productivity.
Three modules — core-utils, json-utils, and ktor-client-utils — are built with
Kotlin Multiplatform and can be used from JVM, JS, wasmJs, and
Native (iOS/macOS/tvOS/watchOS/Linux/Windows) projects. Their portable APIs live in commonMain; JVM-specific
functions (e.g. hashing, URL codecs, classpath resources) remain available to JVM consumers unchanged via jvmMain.
The remaining modules are JVM-only, as they integrate JVM-specific frameworks.
core-utils (multiplatform)
Fundamental utility functions and extensions for common programming tasks.
- String, number, and collection utilities
- I/O operations with security enhancements
- Atomic operations and thread-safe delegates
- Date/time formatting and duration helpers (
DateUtils), zone-neutral by default - Reflection utilities
Utilities for Dropwizard Metrics integration.
- Metrics DSL for cleaner configuration
- Health check utilities
- JMX integration helpers
Enhancements for JetBrains Exposed SQL framework.
- Custom SQL expressions
- UPSERT statement support
- Database operation utilities
gRPC server and client utilities.
- Server configuration DSL
- TLS/SSL utilities for secure communication
- Server extension functions
Google Guava integration and extensions.
- Concurrent programming utilities
- Service lifecycle management
- Thread-safe monitoring and waiting mechanisms
- Archive (ZIP) processing utilities
Jetty 12 (EE11) web server integration utilities.
- Server configuration DSL
- Lambda-based servlet implementations (Jakarta Servlet 6.1)
- Version endpoint utilities
ktor-client-utils (multiplatform)
Ktor HTTP client enhancements.
- Client configuration DSL
- Request/response utilities
Ktor server-side utilities.
- Heroku HTTPS redirect feature
- Response handling utilities
- Server configuration helpers
json-utils (multiplatform)
JSON processing utilities with Kotlinx.serialization.
- JsonElement extension functions for easy data access
- Nested path navigation with dot notation
- Multiple JSON format configurations (pretty, raw, lenient, strict)
- Type-safe value extraction with null safety
Prometheus metrics integration.
- Metrics DSL for clean metric definitions
- System metrics collection
- Instrumented thread factories
- Custom gauge collectors
Zipkin distributed tracing utilities.
- Tracing configuration DSL
- Span management utilities
Redis client utilities and extensions.
- Connection management
- Common Redis operation patterns
- Jedis client enhancements
Common base classes and interfaces for scripting engines.
- Abstract engine implementations
- Script pool management
- Expression evaluator frameworks
JavaScript engine integration.
- JavaScript execution utilities
- Script pooling for performance
Kotlin script engine integration.
- Kotlin script execution
- Expression evaluation
- Script compilation and caching
Python (Jython) script engine integration.
- Python script execution via Jython
- Expression evaluation capabilities
Email sending utilities using Resend.
- Email composition and sending via Resend API
- Resend webhook message handling
- HTML email support via Ktor HTML builder
Google reCAPTCHA verification utilities.
- reCAPTCHA configuration and service
- Server-side verification via Ktor HTTP client
Service lifecycle and configuration management.
- Generic service base classes
- Admin interface configuration
- Metrics service integration
- Servlet service management
- Zipkin reporting service
This library is available on Maven Central.
dependencies {
// Include specific modules as needed
implementation("com.pambrose.common-utils:core-utils:3.2.0")
implementation("com.pambrose.common-utils:json-utils:3.2.0")
implementation("com.pambrose.common-utils:ktor-server-utils:3.2.0")
// ... other modules
}For the multiplatform modules (core-utils, json-utils, ktor-client-utils), Maven consumers must
depend on the -jvm artifact (e.g. core-utils-jvm); Gradle consumers resolve the correct variant from the
root coordinate automatically. The JVM-only modules keep their plain artifact ids.
<dependencies>
<dependency>
<groupId>com.pambrose.common-utils</groupId>
<artifactId>core-utils-jvm</artifactId>
<version>3.2.0</version>
</dependency>
<!-- Add other modules as needed -->
</dependencies>- Languages: Kotlin 2.4.10, Java
- Build System: Gradle 9.6.1 with Kotlin DSL
- Testing: Kotest, MockK
- Serialization: Kotlinx.serialization
- Concurrency: Kotlin Coroutines, Guava
- Web Frameworks: Ktor, Jetty 12 (EE11)
- Metrics: Dropwizard Metrics, Prometheus
- Databases: JetBrains Exposed
- Caching: Redis (Jedis)
- Tracing: Zipkin, Brave
# Show every available make target with descriptions
make help
# Build all modules
./gradlew build
# Build without tests
make build
# Run tests
./gradlew test
# Run tests for a specific module
./gradlew :core-utils:test
# Lint check (Kotlinter + Detekt)
make lint
# Detekt static analysis only
make detekt
# Aggregated Kover coverage reports (HTML + XML)
make coverageThis project maintains high code quality standards:
- Linting: Kotlinter (ktlint) and Detekt (config in
config/detekt/) - Testing: Comprehensive test coverage with Kotest
- Coverage: Kotlinx Kover with aggregated HTML/XML reports and Codecov upload from CI
- Security: Regular dependency updates and security reviews
- Documentation: Comprehensive module documentation
- Create module directory with
build.gradle.kts - Add module to
settings.gradle.kts - Create module-specific
README.md - Follow existing package structure:
com.pambrose.common.* - Add comprehensive tests using Kotest
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Follow the existing code style and conventions
- Add tests for new functionality
- Update documentation as needed
- Submit a pull request
Licensed under the Apache License, Version 2.0. See License.txt for details.
For questions, issues, or contributions, please use the GitHub issue tracker.