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
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
project-name: "Structura"
publish: true
publish-on-discord: false
project-to-publish: "publish"
project-to-publish: "publishAll"
secrets:
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ build/
!**/src/test/**/build/
CLAUDE.md
target/
example-configs/

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

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

dependencies {
implementation("fr.traqueur:structura:<VERSION>") // Replace <VERSION> with the latest release
implementation("org.yaml:snakeyaml:2.4") // Required for YAML parsing
// Core (reading YAML). SnakeYAML is pulled in transitively.
implementation("fr.traqueur.structura:structura-core:<VERSION>") // Replace <VERSION> with the latest release

// Optional: reverse serialization (writing records back to YAML)
implementation("fr.traqueur.structura:structura-writer:<VERSION>")
}
```

Or use the BOM to align module versions:

```gradle
dependencies {
implementation(platform("fr.traqueur.structura:structura-bom:<VERSION>"))

implementation("fr.traqueur.structura:structura-core")
implementation("fr.traqueur.structura:structura-writer")
}
```

Expand Down
55 changes: 55 additions & 0 deletions bom/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
plugins {
`java-platform`
`maven-publish`
}

description = "Structura BOM (Bill of Materials)"

javaPlatform {
allowDependencies()
}

dependencies {
constraints {
api(project(":")) // fr.traqueur.structura:structura-core
api(project(":writer")) // fr.traqueur.structura:structura-writer
}
}

publishing {
publications {
create<MavenPublication>("maven") {
from(components["javaPlatform"])

groupId = project.group.toString()
artifactId = "structura-bom"
version = project.version.toString()

pom {
name.set("structura-bom")
description.set("Structura Bill of Materials — aligns versions across Structura modules")
url.set("https://github.com/Traqueur-dev/Structura")

licenses {
license {
name.set("MIT License")
url.set("https://opensource.org/licenses/MIT")
}
}

developers {
developer {
id.set("traqueur")
name.set("Traqueur")
}
}

scm {
connection.set("scm:git:git://github.com/Traqueur-dev/Structura.git")
developerConnection.set("scm:git:ssh://github.com/Traqueur-dev/Structura.git")
url.set("https://github.com/Traqueur-dev/Structura")
}
}
}
}
}
188 changes: 129 additions & 59 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,88 +2,158 @@ import java.util.*

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

group = "fr.traqueur"
version = property("version") as String
allprojects {
group = "fr.traqueur.structura"
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()
}

dependencies {
compileOnly("org.yaml:snakeyaml:2.4")
apply {
if (project.name != "bom")
plugin("java-library")
// example is a runnable demo, not a published artifact
if (project.name != "example")
plugin("maven-publish")
}

testImplementation("org.yaml:snakeyaml:2.4")
testImplementation("org.junit.jupiter:junit-jupiter:5.10.0")
}
// CI override: version becomes the short commit sha when building from the pipeline
System.getProperty("github.sha")?.let { version = it }

tasks.test {
useJUnitPlatform()
jvmArgs = listOf("-XX:+EnableDynamicAgentLoading")
repositories {
mavenCentral()
}

reports {
html.required.set(true)
junitXml.required.set(true)
if (project.name != "bom") {

dependencies {
testImplementation("org.yaml:snakeyaml:2.6")
testImplementation("org.junit.jupiter:junit-jupiter:6.1.0")
// Gradle 9 no longer auto-provisions the JUnit Platform launcher; declare it explicitly.
testRuntimeOnly("org.junit.platform:junit-platform-launcher:6.1.0")
}

val targetJavaVersion = 21
java {
val javaVersion = JavaVersion.toVersion(targetJavaVersion)
sourceCompatibility = javaVersion
targetCompatibility = javaVersion
if (JavaVersion.current() < javaVersion) {
toolchain.languageVersion.set(JavaLanguageVersion.of(targetJavaVersion))
}
withSourcesJar()
withJavadocJar()
}

tasks.test {
useJUnitPlatform()
jvmArgs = listOf("-XX:+EnableDynamicAgentLoading")

reports {
html.required.set(true)
junitXml.required.set(true)
}

testLogging {
showStandardStreams = true
events("passed", "skipped", "failed", "standardOut", "standardError")
exceptionFormat = org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL
}
}
}

testLogging {
showStandardStreams = true
events("passed", "skipped", "failed", "standardOut", "standardError")
exceptionFormat = org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL
// Centralized groupez publishing repository for any module applying maven-publish
plugins.withId("maven-publish") {
configure<PublishingExtension> {
repositories {
maven {
val repo = System.getProperty("repository.name", "snapshots")
name = "groupez${repo.replaceFirstChar { it.uppercase() }}"
url = uri("https://repo.groupez.dev/${repo.lowercase()}")
credentials {
username = (findProperty("${name}Username") as String?) ?: System.getenv("MAVEN_USERNAME")
password = (findProperty("${name}Password") as String?) ?: System.getenv("MAVEN_PASSWORD")
}
authentication {
create("basic", BasicAuthentication::class)
}
}
}
}
}
}

// ───────────────────────────── Core module (root project) ─────────────────────────────


val targetJavaVersion = 21
java {
val javaVersion = JavaVersion.toVersion(targetJavaVersion)
sourceCompatibility = javaVersion
targetCompatibility = javaVersion
if (JavaVersion.current() < javaVersion) {
toolchain.languageVersion.set(JavaLanguageVersion.of(targetJavaVersion))
}
dependencies {
api("org.yaml:snakeyaml:2.6")
}

// Generates src/main/resources/structura.properties — read at runtime by Updater.getVersion()
tasks.register("generateVersionProperties") {
// Capture values at configuration time so doLast does not touch `project`
// (required for the Gradle configuration cache / Gradle 10 compatibility).
val propertiesFile = project.file(
"src/main/resources/${project.name.lowercase(Locale.getDefault())}.properties"
)
val versionString = project.version.toString()
doLast {
val name = project.name.lowercase(Locale.getDefault())
val file = project.file("src/main/resources/$name.properties")
file.parentFile?.mkdirs()
file.writeText("version=${project.version}")
propertiesFile.parentFile?.mkdirs()
propertiesFile.writeText("version=$versionString")
}
}

tasks.build {
dependsOn(tasks.shadowJar)
}

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

tasks.processResources {
dependsOn("generateVersionProperties")
}

java {
withSourcesJar()
withJavadocJar()
publishing {
publications {
create<MavenPublication>("maven") {
from(components["java"])

groupId = project.group.toString()
artifactId = "structura-core"
version = project.version.toString()

pom {
name.set("structura-core")
description.set("Type-safe YAML configuration library for Java 21+ (core)")
url.set("https://github.com/Traqueur-dev/Structura")

licenses {
license {
name.set("MIT License")
url.set("https://opensource.org/licenses/MIT")
}
}

developers {
developer {
id.set("traqueur")
name.set("Traqueur")
}
}

scm {
connection.set("scm:git:git://github.com/Traqueur-dev/Structura.git")
developerConnection.set("scm:git:ssh://github.com/Traqueur-dev/Structura.git")
url.set("https://github.com/Traqueur-dev/Structura")
}
}
}
}
}

publishConfig {
githubOwner = "Traqueur-dev"
useRootProjectName = true
// Aggregates the publish task of the root project and every publishable subproject
tasks.register("publishAll") {
description = "Publishes all modules (core, writers, bom) to the Maven repository"
group = "publishing"

dependsOn(tasks.named("publish"))
subprojects.forEach { sub ->
sub.plugins.withId("maven-publish") {
dependsOn(sub.tasks.named("publish"))
}
}
}
32 changes: 32 additions & 0 deletions example/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
plugins {
id("java")
id("com.gradleup.shadow") version "9.0.0-beta11"
}

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

repositories {
mavenCentral()
}

dependencies {
implementation(project(":"))
implementation(project(":writer"))
}

java {
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}

tasks.shadowJar {
archiveClassifier.set("")
manifest {
attributes["Main-Class"] = "fr.traqueur.example.Main"
}
}

tasks.build {
dependsOn(tasks.shadowJar)
}
Loading
Loading