Skip to content

Commit dd5ec24

Browse files
committed
* Update CI configuration to use Java 21 and latest action versions.
* Switched to Maven
1 parent e3c08f6 commit dd5ec24

14 files changed

Lines changed: 343 additions & 432 deletions

.github/workflows/build.yml

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,18 @@ name: Build
22

33
on:
44
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
58

69
jobs:
710
build:
8-
runs-on: ubuntu-18.04
11+
runs-on: ubuntu-latest
912
steps:
10-
- uses: actions/checkout@v2
11-
12-
- name: Set up Java for publishing to GitHub Packages
13-
uses: actions/setup-java@v1
13+
- uses: actions/checkout@v6
14+
- uses: actions/setup-java@v5
1415
with:
15-
java-version: 11
16-
17-
- name: Gradle Build
18-
run: gradle clean build
19-
env:
20-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
21-
16+
java-version: '21'
17+
distribution: 'temurin'
18+
cache: 'maven'
19+
- run: mvn verify

.github/workflows/deploy-snapshot.yml

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,25 @@ name: Deploy Snapshot
22

33
on:
44
push:
5-
tags:
6-
- s*
5+
branches: [main]
76

87
jobs:
9-
deploy-snapshot:
8+
deploy:
109
runs-on: ubuntu-latest
1110
steps:
12-
- uses: actions/checkout@v2
13-
- name: Set up Java for publishing
14-
uses: actions/setup-java@v1
11+
- uses: actions/checkout@v6
12+
- uses: actions/setup-java@v5
1513
with:
16-
java-version: 11
17-
server-id: ossrh
18-
server-username: MAVEN_USERNAME
19-
server-password: MAVEN_PASSWORD
20-
- name: Publish package
21-
run: gradle publish
14+
java-version: '21'
15+
distribution: 'temurin'
16+
cache: 'maven'
17+
server-id: central
18+
server-username: MAVEN_CENTRAL_USERNAME
19+
server-password: MAVEN_CENTRAL_PASSWORD
20+
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
21+
gpg-passphrase: MAVEN_GPG_PASSPHRASE
22+
- run: mvn deploy -P release
2223
env:
23-
MAVEN_USERNAME: ${{ secrets.OSSRH_USER }}
24-
MAVEN_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
25-
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
26-
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
24+
MAVEN_CENTRAL_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
25+
MAVEN_CENTRAL_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
26+
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}

.github/workflows/deploy.yml

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,26 @@
1-
name: Deploy
1+
name: Deploy Release
22

33
on:
44
push:
5-
tags:
6-
- v*
5+
tags: ['v*']
76

87
jobs:
98
deploy:
109
runs-on: ubuntu-latest
1110
steps:
12-
- uses: actions/checkout@v2
13-
- name: Set up Java for publishing to GitHub Packages
14-
uses: actions/setup-java@v1
11+
- uses: actions/checkout@v6
12+
- uses: actions/setup-java@v5
1513
with:
16-
java-version: 11
17-
- name: Publish package
18-
run: gradle publish
14+
java-version: '21'
15+
distribution: 'temurin'
16+
cache: 'maven'
17+
server-id: central
18+
server-username: MAVEN_CENTRAL_USERNAME
19+
server-password: MAVEN_CENTRAL_PASSWORD
20+
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
21+
gpg-passphrase: MAVEN_GPG_PASSPHRASE
22+
- run: mvn deploy -P release
1923
env:
20-
MAVEN_USERNAME: ${{ secrets.OSSRH_USER }}
21-
MAVEN_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
22-
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
23-
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
24+
MAVEN_CENTRAL_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
25+
MAVEN_CENTRAL_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
26+
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}

AGENTS.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# AGENTS.md
2+
3+
This file provides guidance to AI coding agents when working with code in this repository.
4+
5+
## Project Overview
6+
7+
Argumenthor is a Kotlin library for parsing configuration values from multiple sources (command-line arguments, properties files, environment variables) with type-safe field definitions. Published to Maven Central under `org.dxworks.utils`.
8+
9+
## Build Commands
10+
11+
```bash
12+
mvn clean verify # Build and run tests
13+
mvn test # Run tests only
14+
mvn install # Install to local ~/.m2
15+
```
16+
17+
## Release Workflow
18+
19+
- **Snapshots**: Auto-published on push to `main` branch
20+
- **Releases**: Triggered by pushing a `v*` tag (e.g., `v1.0.1`)
21+
22+
To release:
23+
1. Update version in `pom.xml` (remove `-SNAPSHOT`)
24+
2. Commit: `git commit -am "Release 1.0.1"`
25+
3. Tag: `git tag v1.0.1`
26+
4. Push: `git push && git push --tags`
27+
5. Bump to next snapshot in pom.xml: `<version>1.0.2-SNAPSHOT</version>`
28+
6. Commit & push
29+
30+
## Architecture
31+
32+
### Core Components
33+
34+
- **Argumenthor** (`Argumenthor.kt`) - Main facade providing `getValue<T>(name)` and `getValue<T>(name, source)` methods
35+
- **ArgumenthorConfiguration** - Holds field and source registrations; `setDefaultSources()` configures Args + Properties + Env sources
36+
37+
### Configuration Sources (`/config/sources/impl/`)
38+
39+
Sources implement `ConfigurationSource` interface with `get(field: FieldConfig<T>): T?`:
40+
41+
- **ArgsSource** - Parses `-argName=value` format from command-line
42+
- **PropertiesSource** - Lazy-loads Java properties files
43+
- **EnvSource** - Reads environment variables with optional prefix
44+
- **YamlSource** - Stub (not implemented)
45+
46+
### Field Types (`/config/fields/impl/`)
47+
48+
Fields extend `FieldConfig<T>` with abstract `parse(value: String?): T?`:
49+
50+
- **StringField** - Basic strings with quote trimming
51+
- **NumberField** - Numeric values using custom `+` operator
52+
- **StringListField** / **NumberListField** - Comma-separated values
53+
54+
### Design Patterns
55+
56+
1. **Multi-source fallback** - Values are looked up across sources in priority order
57+
2. **Pluggable sources** - Add custom sources by implementing `ConfigurationSource`
58+
3. **Type-safe fields** - Generic field definitions provide compile-time type safety
59+
60+
## Tech Stack
61+
62+
- Kotlin 2.3.0 targeting Java 11
63+
- JUnit 6.0.2 for testing
64+
- Maven with central-publishing-maven-plugin for Maven Central Portal publishing

CLAUDE.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Claude Code Instructions
2+
3+
See [AGENTS.md](./AGENTS.md) for project guidance.

README.md

Lines changed: 65 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,68 @@
1-
# Dxworks Argumenthor
1+
# Argumenthor
22

3-
Visit us on [Github](https://github.com/dxworks/argumenthor).
3+
A Kotlin library for parsing configuration values from multiple sources with type-safe field definitions.
4+
5+
[![Build](https://github.com/dxworks/argumenthor/actions/workflows/build.yml/badge.svg)](https://github.com/dxworks/argumenthor/actions/workflows/build.yml)
6+
[![Maven Central](https://img.shields.io/maven-central/v/org.dxworks.utils/argumenthor)](https://central.sonatype.com/artifact/org.dxworks.utils/argumenthor)
7+
8+
## Installation
9+
10+
### Gradle (Kotlin DSL)
11+
```kotlin
12+
implementation("org.dxworks.utils:argumenthor:1.0.0")
13+
```
14+
15+
### Gradle (Groovy)
16+
```groovy
17+
implementation 'org.dxworks.utils:argumenthor:1.0.0'
18+
```
19+
20+
### Maven
21+
```xml
22+
<dependency>
23+
<groupId>org.dxworks.utils</groupId>
24+
<artifactId>argumenthor</artifactId>
25+
<version>1.0.0</version>
26+
</dependency>
27+
```
428

529
## Features
6-
To be added...
30+
31+
- **Multi-source configuration** - Read values from command-line arguments, properties files, and environment variables
32+
- **Type-safe fields** - Generic field definitions with compile-time type safety
33+
- **Priority-based fallback** - Values are looked up across sources in configurable order
34+
- **Pluggable architecture** - Add custom sources by implementing `ConfigurationSource`
35+
36+
## Usage
37+
38+
```kotlin
39+
// Set up default sources (Args > Properties > Env)
40+
ArgumenthorConfiguration.setDefaultSources()
41+
42+
// Register a field
43+
val portField = NumberField("port")
44+
ArgumenthorConfiguration.registerField(portField)
45+
46+
// Get value (checks all sources in priority order)
47+
val port: Number? = Argumenthor.getValue("port")
48+
49+
// Or get from a specific source
50+
val portFromEnv: Number? = Argumenthor.getValue("port", "env")
51+
```
52+
53+
### Configuration Sources
54+
55+
- **ArgsSource** - Parses `-argName=value` format from command-line arguments
56+
- **PropertiesSource** - Loads values from Java properties files
57+
- **EnvSource** - Reads environment variables with optional prefix
58+
59+
### Field Types
60+
61+
- `StringField` - Basic strings
62+
- `NumberField` - Numeric values
63+
- `StringListField` - Comma-separated string lists
64+
- `NumberListField` - Comma-separated number lists
65+
66+
## License
67+
68+
Apache License 2.0

build.gradle

Lines changed: 0 additions & 92 deletions
This file was deleted.

gradle.properties

Lines changed: 0 additions & 1 deletion
This file was deleted.

gradle/wrapper/gradle-wrapper.jar

-57.5 KB
Binary file not shown.

gradle/wrapper/gradle-wrapper.properties

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)