diff --git a/README.md b/README.md index a913e76..6a0290b 100644 --- a/README.md +++ b/README.md @@ -20,11 +20,40 @@ JSON5 extends JSON with the following features: Add the dependency to your `build.gradle.kts`: ```kotlin +repositories { + maven { + name = "GitHubPackages" + url = uri("https://maven.pkg.github.com/hossain-khan/json5-kotlin") + credentials { + username = project.findProperty("gpr.user") as String? ?: System.getenv("USERNAME") + password = project.findProperty("gpr.key") as String? ?: System.getenv("TOKEN") + } + } +} + dependencies { - implementation("io.github.json5:json5-kotlin:VERSION") + implementation("hossain.dev:json5kt:1.0.0") } ``` +### Authentication for GitHub Packages + +To access GitHub Packages, you need to authenticate with GitHub. You can do this by: + +1. **Using environment variables:** + ```bash + export USERNAME=your_github_username + export TOKEN=your_github_personal_access_token + ``` + +2. **Using gradle.properties:** + ```properties + gpr.user=your_github_username + gpr.key=your_github_personal_access_token + ``` + +You can generate a personal access token at [GitHub > Settings > Developer settings > Personal access tokens](https://github.com/settings/tokens) with `read:packages` permission. + ## Usage ### Basic Parsing and Stringifying diff --git a/lib/build.gradle.kts b/lib/build.gradle.kts index 02d2f14..80ccc83 100644 --- a/lib/build.gradle.kts +++ b/lib/build.gradle.kts @@ -3,6 +3,7 @@ plugins { id("buildsrc.convention.kotlin-jvm") alias(libs.plugins.kover) alias(libs.plugins.kotlinPluginSerialization) + `maven-publish` } dependencies { @@ -21,3 +22,62 @@ dependencies { tasks.test { useJUnitPlatform() } + +// Configure JAR to include sources +val sourcesJar by tasks.registering(Jar::class) { + archiveClassifier.set("sources") + from(sourceSets.main.get().allSource) + duplicatesStrategy = DuplicatesStrategy.EXCLUDE +} + +// Publishing configuration +publishing { + publications { + register("maven") { + groupId = "hossain.dev" + artifactId = "json5kt" + version = "1.0.0" + + from(components["java"]) + artifact(sourcesJar) + + pom { + name.set("JSON5 Kotlin") + description.set("A robust JSON5 parser and serializer for Kotlin/JVM that extends JSON with helpful features like comments, trailing commas, and unquoted keys while maintaining full backward compatibility with JSON.") + url.set("https://github.com/hossain-khan/json5-kotlin") + + licenses { + license { + name.set("MIT License") + url.set("https://opensource.org/licenses/MIT") + } + } + + developers { + developer { + id.set("hossain-khan") + name.set("Hossain Khan") + email.set("hossain@hossain.dev") + } + } + + scm { + connection.set("scm:git:git://github.com/hossain-khan/json5-kotlin.git") + developerConnection.set("scm:git:ssh://github.com:hossain-khan/json5-kotlin.git") + url.set("https://github.com/hossain-khan/json5-kotlin") + } + } + } + } + + repositories { + maven { + name = "GitHubPackages" + url = uri("https://maven.pkg.github.com/hossain-khan/json5-kotlin") + credentials { + username = project.findProperty("gpr.user") as String? ?: System.getenv("USERNAME") + password = project.findProperty("gpr.key") as String? ?: System.getenv("TOKEN") + } + } + } +}