diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..c80b256 --- /dev/null +++ b/.github/workflows/build.yml @@ -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: "" \ No newline at end of file diff --git a/.gitignore b/.gitignore index cd0d9ee..559cbb1 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ build/ !**/src/main/**/build/ !**/src/test/**/build/ CLAUDE.md +target/ ### IntelliJ IDEA ### .idea/modules.xml diff --git a/README.md b/README.md index 6263504..f6ad601 100644 --- a/README.md +++ b/README.md @@ -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:") // Replace with the latest release + implementation("fr.traqueur:structura:") // Replace with the latest release implementation("org.yaml:snakeyaml:2.4") // Required for YAML parsing } ``` diff --git a/build.gradle.kts b/build.gradle.kts index 497e8c0..c69f7e4 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -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() @@ -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") } @@ -65,10 +83,7 @@ java { withJavadocJar() } -publishing { - publications { - create("maven") { - from(components["java"]) - } - } +publishConfig { + githubOwner = "Traqueur-dev" + useRootProjectName = true } diff --git a/gradle.properties b/gradle.properties index 6eb5849..46f2d21 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1 +1 @@ -version=1.5.0 \ No newline at end of file +version=1.6.0 \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 6b04d56..6826537 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -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 diff --git a/settings.gradle.kts b/settings.gradle.kts index 50c8ff2..08842a3 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1 +1,11 @@ rootProject.name = "Structura" + +pluginManagement { + repositories { + maven { + name = "groupezReleases" + url = uri("https://repo.groupez.dev/releases") + } + gradlePluginPortal() + } +} \ No newline at end of file diff --git a/src/main/java/fr/traqueur/structura/conversion/ValueConverter.java b/src/main/java/fr/traqueur/structura/conversion/ValueConverter.java index 6f80dbd..a4a9f75 100644 --- a/src/main/java/fr/traqueur/structura/conversion/ValueConverter.java +++ b/src/main/java/fr/traqueur/structura/conversion/ValueConverter.java @@ -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; @@ -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; @@ -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()); } diff --git a/src/main/resources/structura.properties b/src/main/resources/structura.properties index 6eb5849..46f2d21 100644 --- a/src/main/resources/structura.properties +++ b/src/main/resources/structura.properties @@ -1 +1 @@ -version=1.5.0 \ No newline at end of file +version=1.6.0 \ No newline at end of file diff --git a/src/test/java/fr/traqueur/structura/conversion/ValueConverterTest.java b/src/test/java/fr/traqueur/structura/conversion/ValueConverterTest.java index bc3bc8c..92f55cf 100644 --- a/src/test/java/fr/traqueur/structura/conversion/ValueConverterTest.java +++ b/src/test/java/fr/traqueur/structura/conversion/ValueConverterTest.java @@ -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; @@ -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