plugins { kotlin("jvm") version "2.3.21" id("maven-publish") `java-gradle-plugin` `kotlin-dsl` } group = "no.iktdev" version = "1.0-SNAPSHOT" val named = "ts-gen" val dynamicVersion = providers.provider { val ref = System.getenv("GITHUB_REF") ?: "" val isSnapshot = ref.endsWith("/master") || ref.endsWith("/main") val latestTag = providers.exec { commandLine("git", "describe", "--tags", "--abbrev=0") }.standardOutput.asText.getOrElse("0.0.0").trim().removePrefix("v") if (isSnapshot) { val parts = latestTag.split(".") val patch = parts.lastOrNull()?.toIntOrNull()?.plus(1) ?: 1 val base = if (parts.size >= 2) "${parts[0]}.${parts[1]}" else latestTag val buildNumber = providers.exec { commandLine("git", "rev-list", "v$latestTag..HEAD", "--count") }.standardOutput.asText.getOrElse("0").trim().toIntOrNull() ?: 0 "$base.$patch-SNAPSHOT-$buildNumber" } else { latestTag } } repositories { mavenCentral() } gradlePlugin { plugins { create("tsGenerator") { id = "no.iktdev.ts-gen" implementationClass = "no.iktdev.tsgen.TsGeneratorPlugin" // Denne er viktig for Gradle-menyen: displayName = "TS Generator" description = "Genererer TypeScript definisjoner fra Kotlin DTO-er" } } } dependencies { implementation(gradleApi()) implementation("com.google.code.gson:gson:2.8.9") implementation(kotlin("reflect")) implementation(kotlin("stdlib")) testImplementation("org.assertj:assertj-core:3.27.7") testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.10.2") // Bruk BOM for å styre alle JUnit-versjoner automatisk testImplementation(platform("org.junit:junit-bom:5.10.2")) testImplementation("org.junit.jupiter:junit-jupiter") testRuntimeOnly("org.junit.platform:junit-platform-launcher") } tasks.test { useJUnitPlatform() } kotlin { jvmToolchain(21) } val reposiliteUrl = if (version.toString().endsWith("SNAPSHOT")) { "https://reposilite.iktdev.no/snapshots" } else { "https://reposilite.iktdev.no/releases" } publishing { publications { create("plugin") { groupId = "no.iktdev" artifactId = "ts-gen" // Hent ut verdien eksplisitt med .get() version = dynamicVersion.get() artifact(tasks.jar) } } repositories { mavenLocal() maven { name = "reposilite" url = uri(reposiliteUrl) credentials { username = System.getenv("reposiliteUsername") password = System.getenv("reposilitePassword") } } } }