|
| 1 | +@file:Suppress("ktlint:standard:max-line-length") |
| 2 | + |
| 3 | +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile |
| 4 | + |
| 5 | +version = properties["serverLogbackVersion"].toString() |
| 6 | + |
| 7 | +plugins { |
| 8 | + `java-library` |
| 9 | + kotlin("jvm") |
| 10 | + id("com.android.lint") |
| 11 | + |
| 12 | + // publish |
| 13 | + `maven-publish` |
| 14 | + signing |
| 15 | + id("org.jetbrains.dokka") |
| 16 | + |
| 17 | + // plugins |
| 18 | + id("com.github.gmazzo.buildconfig") |
| 19 | + |
| 20 | + // tests |
| 21 | + id("org.jetbrains.kotlinx.kover") |
| 22 | + |
| 23 | + // compatibility |
| 24 | + id("ru.vyarus.animalsniffer") |
| 25 | +} |
| 26 | + |
| 27 | +buildConfig { |
| 28 | + useKotlinOutput() |
| 29 | + packageName("com.posthog.server.logback") |
| 30 | + buildConfigField("String", "SDK_NAME", "\"posthog-server-logback\"") |
| 31 | + buildConfigField("String", "VERSION_NAME", "\"${project.version}\"") |
| 32 | +} |
| 33 | + |
| 34 | +java { |
| 35 | + withSourcesJar() |
| 36 | + sourceCompatibility = PosthogBuildConfig.Build.JAVA_VERSION |
| 37 | + targetCompatibility = PosthogBuildConfig.Build.JAVA_VERSION |
| 38 | +} |
| 39 | + |
| 40 | +val dokkaJavadocJar by tasks.register<Jar>("dokkaJavadocJar") { |
| 41 | + dependsOn(tasks.dokkaJavadoc) |
| 42 | + from(tasks.dokkaJavadoc.flatMap { it.outputDirectory }) |
| 43 | + archiveClassifier.set("javadoc") |
| 44 | +} |
| 45 | + |
| 46 | +val dokkaHtmlJar by tasks.register<Jar>("dokkaHtmlJar") { |
| 47 | + dependsOn(tasks.dokkaHtml) |
| 48 | + from(tasks.dokkaHtml.flatMap { it.outputDirectory }) |
| 49 | + archiveClassifier.set("html-doc") |
| 50 | +} |
| 51 | + |
| 52 | +publishing { |
| 53 | + publications { |
| 54 | + create<MavenPublication>("maven") { |
| 55 | + from(components["java"]) |
| 56 | + artifact(dokkaJavadocJar) |
| 57 | + artifact(dokkaHtmlJar) |
| 58 | + |
| 59 | + postHogConfig(project.name, project.version.toString()) |
| 60 | + pom.postHogConfig( |
| 61 | + project.name, |
| 62 | + moduleDescription = "Logback appender that reports errors to PostHog via the server SDK", |
| 63 | + ) |
| 64 | + } |
| 65 | + } |
| 66 | + signing.postHogConfig("maven", this) |
| 67 | +} |
| 68 | + |
| 69 | +tasks.withType<KotlinCompile>().configureEach { |
| 70 | + compilerOptions.postHogConfig() |
| 71 | +} |
| 72 | + |
| 73 | +kotlin { |
| 74 | + explicitApi() |
| 75 | +} |
| 76 | + |
| 77 | +configure<SourceSetContainer> { |
| 78 | + test { |
| 79 | + java.srcDir("src/test/java") |
| 80 | + } |
| 81 | +} |
| 82 | + |
| 83 | +dependencies { |
| 84 | + // Expose the server SDK transitively: consumers configure and use a PostHog server client |
| 85 | + // alongside the appender, so it belongs on the compile classpath of anything depending on this. |
| 86 | + api(project(":posthog-server")) |
| 87 | + |
| 88 | + implementation(kotlin("stdlib-jdk8", PosthogBuildConfig.Kotlin.KOTLIN)) |
| 89 | + |
| 90 | + // Logback is provided by the host application; keep it off our runtime classpath and pin a |
| 91 | + // conservative Java 8-compatible floor (the 1.3.x line; 1.4.x+ requires Java 11). |
| 92 | + compileOnly("ch.qos.logback:logback-classic:${PosthogBuildConfig.Dependencies.LOGBACK}") |
| 93 | + compileOnly("org.codehaus.mojo:animal-sniffer-annotations:${PosthogBuildConfig.Plugins.ANIMAL_SNIFFER_SDK_ANNOTATION}") |
| 94 | + |
| 95 | + // compatibility |
| 96 | + signature("org.codehaus.mojo.signature:java18:${PosthogBuildConfig.Plugins.SIGNATURE_JAVA18}@signature") |
| 97 | + |
| 98 | + // tests |
| 99 | + testImplementation("ch.qos.logback:logback-classic:${PosthogBuildConfig.Dependencies.LOGBACK}") |
| 100 | + testImplementation("org.jetbrains.kotlin:kotlin-test-junit:${PosthogBuildConfig.Kotlin.KOTLIN}") |
| 101 | + testImplementation("com.squareup.okhttp3:mockwebserver:${PosthogBuildConfig.Dependencies.OKHTTP}") |
| 102 | + testImplementation("com.google.code.gson:gson:${PosthogBuildConfig.Dependencies.GSON}") |
| 103 | +} |
| 104 | + |
| 105 | +tasks.javadoc { |
| 106 | + if (JavaVersion.current().isJava9Compatible) { |
| 107 | + (options as StandardJavadocDocletOptions).addBooleanOption("html5", true) |
| 108 | + } |
| 109 | +} |
0 commit comments