Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Build Action

on:
push:
branches: [ main, develop ]
pull_request:
types: [ opened, synchronize, reopened ]
workflow_dispatch:

permissions:
contents: read
packages: write

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
name: Build and Publish Structura
uses: GroupeZ-dev/actions/.github/workflows/build.yml@main
with:
project-name: "Structura"
publish: true
publish-on-discord: false
project-to-publish: "publish"
secrets:
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
WEBHOOK_URL: ""
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ build/
!**/src/main/**/build/
!**/src/test/**/build/
CLAUDE.md
target/

### IntelliJ IDEA ###
.idea/modules.xml
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ Add Structura to your project:

```gradle
repository {
maven { url = "https://jitpack.io" } // JitPack repository for Structura
maven { url = "https://repo.groupez.dev/releases" } // Add Structura repository replace releases with snapshots if needed
}

dependencies {
implementation("com.github.Traqueur-dev:Structura:<VERSION>") // Replace <VERSION> with the latest release
implementation("fr.traqueur:structura:<VERSION>") // Replace <VERSION> with the latest release
implementation("org.yaml:snakeyaml:2.4") // Required for YAML parsing
}
```
Expand Down
31 changes: 23 additions & 8 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,20 @@ import java.util.*

plugins {
id("java-library")
id("maven-publish")
id("re.alwyn974.groupez.publish") version "1.0.0"
id("com.gradleup.shadow") version "9.0.0-beta11"
}

group = "fr.traqueur"
version = property("version")!!
version = property("version") as String

extra.set("targetFolder", file("target/"))
extra.set("classifier", System.getProperty("archive.classifier"))
extra.set("sha", System.getProperty("github.sha"))

rootProject.extra.properties["sha"]?.let { sha ->
version = sha
}

repositories {
mavenCentral()
Expand Down Expand Up @@ -56,6 +65,15 @@ tasks.register("generateVersionProperties") {
}
}

tasks.build {
dependsOn(tasks.shadowJar)
}

tasks.shadowJar {
archiveClassifier.set("")
destinationDirectory.set(rootProject.extra["targetFolder"] as File)
}

tasks.processResources {
dependsOn("generateVersionProperties")
}
Expand All @@ -65,10 +83,7 @@ java {
withJavadocJar()
}

publishing {
publications {
create<MavenPublication>("maven") {
from(components["java"])
}
}
publishConfig {
githubOwner = "Traqueur-dev"
useRootProjectName = true
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version=1.5.0
version=1.6.0
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Tue Mar 25 10:59:06 CET 2025
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
10 changes: 10 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
rootProject.name = "Structura"

pluginManagement {
repositories {
maven {
name = "groupezReleases"
url = uri("https://repo.groupez.dev/releases")
}
gradlePluginPortal()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;
Expand All @@ -21,6 +22,7 @@
public class ValueConverter {

private static final DateTimeFormatter DATE_FORMATTER = DateTimeFormatter.ISO_LOCAL_DATE;
private static final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ISO_LOCAL_DATE_TIME;

private final RecordInstanceFactory recordFactory;

Expand Down Expand Up @@ -277,6 +279,10 @@ private Object convertPrimitive(Object value, Class<?> targetType, String prefix
return LocalDate.parse(value.toString(), DATE_FORMATTER);
}

if(targetType == LocalDateTime.class) {
return LocalDateTime.parse(value.toString(), DATE_TIME_FORMATTER);
}

if (targetType == int.class || targetType == Integer.class) {
return value instanceof Number n ? n.intValue() : Integer.parseInt(value.toString());
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/structura.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version=1.5.0
version=1.6.0
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.time.LocalDateTime;
import java.util.Collection;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -108,6 +109,13 @@ void shouldHandleLocalDateConversion() {
var localDate = java.time.LocalDate.of(2023, 10, 5);
assertEquals(localDate, valueConverter.convert("2023-10-05", java.time.LocalDate.class, "test"));
}

@Test
@DisplayName("Should handle LocalDateTime conversion from string")
void shouldHandleLocalDateTimeConversion() {
var localDate = LocalDateTime.of(2023, 10, 5, 14, 30, 0);
assertEquals(localDate, valueConverter.convert("2023-10-05T14:30:00", LocalDateTime.class, "test"));
}
}

@Nested
Expand Down
Loading