|
| 1 | +import com.vanniktech.maven.publish.MavenPublishPluginExtension |
| 2 | +import io.gitlab.arturbosch.detekt.Detekt |
| 3 | +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile |
| 4 | + |
| 5 | +plugins { |
| 6 | + alias(libs.plugins.kotlin) |
| 7 | + alias(libs.plugins.detekt) |
| 8 | + `java-gradle-plugin` |
| 9 | + alias(libs.plugins.vanniktech.publish) |
| 10 | + id("distribution") |
| 11 | + alias(libs.plugins.buildConfig) |
| 12 | + alias(libs.plugins.kover) |
| 13 | +} |
| 14 | + |
| 15 | +version = property("versionName").toString() |
| 16 | + |
| 17 | +group = property("group").toString() |
| 18 | + |
| 19 | +dependencies { |
| 20 | + compileOnly(kotlin("stdlib")) |
| 21 | + compileOnly(gradleApi()) |
| 22 | + compileOnly(kotlin("gradle-plugin")) |
| 23 | + |
| 24 | + testImplementation(kotlin("gradle-plugin")) |
| 25 | + testImplementation(libs.junit) |
| 26 | + testImplementation(libs.junit.params) |
| 27 | + testImplementation(libs.mockk) |
| 28 | +} |
| 29 | + |
| 30 | +tasks.test { |
| 31 | + useJUnitPlatform() |
| 32 | +} |
| 33 | + |
| 34 | +java { |
| 35 | + sourceCompatibility = JavaVersion.VERSION_11 |
| 36 | + targetCompatibility = JavaVersion.VERSION_11 |
| 37 | +} |
| 38 | + |
| 39 | +tasks.withType<KotlinCompile> { kotlinOptions { jvmTarget = JavaVersion.VERSION_11.toString() } } |
| 40 | + |
| 41 | +gradlePlugin { |
| 42 | + plugins { |
| 43 | + create(property("id").toString()) { |
| 44 | + id = property("id").toString() |
| 45 | + implementationClass = property("implementationClass").toString() |
| 46 | + } |
| 47 | + } |
| 48 | +} |
| 49 | + |
| 50 | +val publish = extensions.getByType(MavenPublishPluginExtension::class.java) |
| 51 | +// signing is done when uploading files to MC |
| 52 | +// via gpg:sign-and-deploy-file (release.kts) |
| 53 | +publish.releaseSigningEnabled = false |
| 54 | + |
| 55 | +tasks.named("distZip").configure { |
| 56 | + dependsOn("publishToMavenLocal") |
| 57 | + this.doLast { |
| 58 | + val distributionFilePath = |
| 59 | + "${project.layout.buildDirectory.asFile.get().path}${sep}distributions${sep}${project.name}-${project.version}.zip" |
| 60 | + val file = File(distributionFilePath) |
| 61 | + if (!file.exists()) { |
| 62 | + throw IllegalStateException("Distribution file: $distributionFilePath does not exist") |
| 63 | + } |
| 64 | + if (file.length() == 0L) { |
| 65 | + throw IllegalStateException("Distribution file: $distributionFilePath is empty") |
| 66 | + } |
| 67 | + } |
| 68 | +} |
| 69 | + |
| 70 | +val sep = File.separator |
| 71 | + |
| 72 | +distributions { |
| 73 | + main { |
| 74 | + contents { |
| 75 | + from("build${sep}libs") |
| 76 | + from("build${sep}publications${sep}maven") |
| 77 | + } |
| 78 | + } |
| 79 | +} |
| 80 | + |
| 81 | +buildConfig { |
| 82 | + useKotlinOutput() |
| 83 | + packageName("io.sentry") |
| 84 | + className("BuildConfig") |
| 85 | + |
| 86 | + buildConfigField( |
| 87 | + "String", |
| 88 | + "SentryCocoaVersion", |
| 89 | + provider { "\"${project.property("sentryCocoaVersion")}\"" } |
| 90 | + ) |
| 91 | +} |
| 92 | + |
| 93 | +detekt { config.setFrom(rootProject.files("../config/detekt/detekt.yml")) } |
| 94 | + |
| 95 | +tasks.withType<Detekt>().configureEach { |
| 96 | + reports { |
| 97 | + html.required.set(true) |
| 98 | + html.outputLocation.set(file("build/reports/detekt.html")) |
| 99 | + } |
| 100 | +} |
0 commit comments