import com.github.jk1.license.filter.DependencyFilter import com.github.jk1.license.filter.LicenseBundleNormalizer import com.github.jk1.license.importer.DependencyDataImporter import com.github.jk1.license.importer.XmlReportImporter import com.github.jk1.license.render.* import org.jetbrains.kotlin.gradle.tasks.KotlinCompile import org.openapitools.generator.gradle.plugin.tasks.GenerateTask val ktor_version: String by project val kotlin_version: String by project val h2_version: String by project val coroutines_version: String by project plugins { alias(libs.plugins.kotlin.jvm) alias(libs.plugins.detekt) alias(libs.plugins.spring.boot) alias(libs.plugins.kotlin.spring) alias(libs.plugins.openapi.generator) alias(libs.plugins.kover) alias(libs.plugins.license.report) } apply { plugin("io.spring.dependency-management") } group = "dev.usbharu" version = "0.0.1" sourceSets { create("intTest") { // test { compileClasspath += sourceSets.main.get().output runtimeClasspath += sourceSets.main.get().output kotlin.srcDirs("src/intTest/kotlin") java.srcDirs("src/intTest/java") resources.srcDirs("src/intTest/resources") // } } create("e2eTest") { // test { compileClasspath += sourceSets.main.get().output runtimeClasspath += sourceSets.main.get().output kotlin.srcDirs("src/e2eTest/kotlin") java.srcDirs("src/e2eTest/java") resources.srcDirs("src/e2eTest/resources") // } } } val intTestImplementation by configurations.getting { extendsFrom(configurations.implementation.get()) } val intTestRuntimeOnly by configurations.getting { extendsFrom(configurations.runtimeOnly.get()) } val e2eTestImplementation by configurations.getting { extendsFrom(configurations.implementation.get()) } val e2eTestRuntimeOnly by configurations.getting { extendsFrom(configurations.runtimeOnly.get()) } val integrationTest = task("integrationTest") { description = "Runs integration tests." group = "verification" testClassesDirs = sourceSets["intTest"].output.classesDirs classpath = sourceSets["intTest"].runtimeClasspath shouldRunAfter("test") useJUnitPlatform() } val e2eTest = task("e2eTest") { description = "Runs e2e tests." group = "verification" testClassesDirs = sourceSets["e2eTest"].output.classesDirs classpath = sourceSets["e2eTest"].runtimeClasspath shouldRunAfter("test") useJUnitPlatform() } tasks.check { dependsOn(integrationTest) dependsOn(e2eTest) } tasks.withType { useJUnitPlatform() doFirst { jvmArgs = arrayOf( "--add-opens", "java.base/java.lang=ALL-UNNAMED", "--add-opens", "java.base/java.util=ALL-UNNAMED", "--add-opens", "java.naming/javax.naming=ALL-UNNAMED", ).toMutableList() } } tasks.withType { kotlinOptions { freeCompilerArgs += "-Xjsr305=strict" } dependsOn("openApiGenerateMastodonCompatibleApi") mustRunAfter("openApiGenerateMastodonCompatibleApi") } tasks.clean { delete += listOf("$rootDir/src/main/resources/static") } tasks.create("openApiGenerateMastodonCompatibleApi", GenerateTask::class) { generatorName.set("kotlin-spring") inputSpec.set("$rootDir/src/main/resources/openapi/mastodon.yaml") outputDir.set("$buildDir/generated/sources/mastodon") apiPackage.set("dev.usbharu.hideout.controller.mastodon.generated") modelPackage.set("dev.usbharu.hideout.domain.mastodon.model.generated") configOptions.put("interfaceOnly", "true") configOptions.put("useSpringBoot3", "true") configOptions.put("reactive", "true") additionalProperties.put("useTags", "true") importMappings.put("org.springframework.core.io.Resource", "org.springframework.web.multipart.MultipartFile") typeMappings.put("org.springframework.core.io.Resource", "org.springframework.web.multipart.MultipartFile") schemaMappings.put( "StatusesRequest", "dev.usbharu.hideout.mastodon.interfaces.api.status.StatusesRequest" ) templateDir.set("$rootDir/templates") } repositories { mavenCentral() maven { url = uri("https://git.usbharu.dev/api/packages/usbharu/maven") } maven { name = "GitHubPackages" url = uri("https://maven.pkg.github.com/usbharu/http-signature") credentials { username = project.findProperty("gpr.user") as String? ?: System.getenv("USERNAME") password = project.findProperty("gpr.key") as String? ?: System.getenv("TOKEN") } } maven { name = "GitHubPackages2" url = uri("https://maven.pkg.github.com/multim-dev/emoji-kt") credentials { username = project.findProperty("gpr.user") as String? ?: System.getenv("USERNAME") password = project.findProperty("gpr.key") as String? ?: System.getenv("TOKEN") } } } kotlin { target { compilations.all { kotlinOptions.jvmTarget = JavaVersion.VERSION_21.toString() } } } sourceSets.main { kotlin.srcDirs( "$buildDir/generated/ksp/main", "$buildDir/generated/sources/openapi/src/main/kotlin", "$buildDir/generated/sources/mastodon/src/main/kotlin" ) } val os = org.gradle.nativeplatform.platform.internal .DefaultNativePlatform.getCurrentOperatingSystem() dependencies { developmentOnly("com.h2database:h2:$h2_version") detektPlugins(libs.detekt.formatting) implementation(libs.bundles.exposed) implementation(libs.bundles.coroutines) implementation(libs.bundles.ktor.client) implementation(libs.bundles.apache.tika) implementation(libs.bundles.openapi) implementation(libs.bundles.owl.producer) implementation(libs.bundles.owl.broker) implementation(libs.bundles.spring.boot.oauth2) implementation(libs.bundles.spring.boot.data.mongodb) implementation(libs.bundles.spring.boot.data.mongodb) implementation("org.springframework.boot:spring-boot-starter-actuator") implementation("org.springframework.boot:spring-boot-starter-web") implementation("org.springframework.boot:spring-boot-starter-security") implementation("org.springframework.boot:spring-boot-starter-thymeleaf") implementation("org.springframework.boot:spring-boot-starter-log4j2") implementation("org.springframework.boot:spring-boot-starter-validation") implementation("dev.usbharu:owl-common-serialize-jackson:0.0.1") implementation("io.trbl:blurhash:1.0.0") implementation("software.amazon.awssdk:s3:2.25.23") implementation("org.jsoup:jsoup:1.17.2") implementation("com.googlecode.owasp-java-html-sanitizer:owasp-java-html-sanitizer:20240325.1") implementation("org.postgresql:postgresql:42.7.3") implementation("com.twelvemonkeys.imageio:imageio-webp:3.10.1") implementation("net.coobird:thumbnailator:0.4.20") implementation("org.flywaydb:flyway-core") implementation(libs.javacv) { exclude(module = "opencv") exclude(module = "flycapture") exclude(module = "artoolkitplus") exclude(module = "libdc1394") exclude(module = "librealsense") exclude(module = "librealsense2") exclude(module = "tesseract") exclude(module = "libfreenect") exclude(module = "libfreenect2") } if (os.isWindows) { implementation(variantOf(libs.javacv.ffmpeg) { classifier("windows-x86_64") }) } else { implementation(variantOf(libs.javacv.ffmpeg) { classifier("linux-x86_64") }) } implementation("dev.usbharu:http-signature:1.0.0") implementation("dev.usbharu:emoji-kt:2.0.0") testImplementation("org.springframework.boot:spring-boot-starter-test") testImplementation("org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version") testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutines_version") testImplementation("io.ktor:ktor-client-mock:$ktor_version") testImplementation("com.h2database:h2:$h2_version") testImplementation("org.mockito.kotlin:mockito-kotlin:5.3.1") testImplementation("org.mockito:mockito-inline:5.2.0") testImplementation("nl.jqno.equalsverifier:equalsverifier:3.16.1") testImplementation("com.jparams:to-string-verifier:1.4.8") intTestImplementation("org.springframework.boot:spring-boot-starter-test") intTestImplementation("org.springframework.security:spring-security-test") intTestImplementation("org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version") intTestImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutines_version") intTestImplementation("org.mockito.kotlin:mockito-kotlin:5.3.1") intTestImplementation("com.h2database:h2:$h2_version") e2eTestImplementation("org.springframework.boot:spring-boot-starter-test") e2eTestImplementation("org.springframework.security:spring-security-test") e2eTestImplementation("org.springframework.boot:spring-boot-starter-webflux") e2eTestImplementation("org.jsoup:jsoup:1.17.2") e2eTestImplementation("com.intuit.karate:karate-junit5:1.4.1") e2eTestImplementation("com.h2database:h2:$h2_version") } detekt { parallel = true config = files("../detekt.yml") buildUponDefaultConfig = true basePath = "${rootDir.absolutePath}/src/main/kotlin" autoCorrect = true } tasks.withType { exclude("**/generated/**") doFirst { } setSource("src/main/kotlin") exclude("build/") } tasks.withType().configureEach { exclude("**/org/koin/ksp/generated/**", "**/generated/**") } tasks.withType().configureEach { exclude("**/org/koin/ksp/generated/**", "**/generated/**") } configurations { all { exclude("org.springframework.boot", "spring-boot-starter-logging") exclude("ch.qos.logback", "logback-classic") } } project.gradle.taskGraph.whenReady { println(this.allTasks) this.allTasks.map { println(it.name) } if (this.hasTask(":koverGenerateArtifact")) { println("has task") val task = this.allTasks.find { it.name == "test" } val verificationTask = task as VerificationTask verificationTask.ignoreFailures = true } } kover { excludeSourceSets { names("aot", "e2eTest", "intTest") } } koverReport { filters { excludes { packages( "dev.usbharu.hideout.activitypub.domain.exception", "dev.usbharu.hideout.core.domain.exception", "dev.usbharu.hideout.core.domain.exception.media", "dev.usbharu.hideout.core.domain.exception.resource", "dev.usbharu.hideout.core.domain.exception.resource.local" ) annotatedBy("org.springframework.context.annotation.Configuration") annotatedBy("org.springframework.boot.context.properties.ConfigurationProperties") packages( "dev.usbharu.hideout.controller.mastodon.generated", "dev.usbharu.hideout.domain.mastodon.model.generated" ) packages("org.springframework") packages("org.jetbrains") } } } springBoot { buildInfo() } licenseReport { excludeOwnGroup = true importers = arrayOf(XmlReportImporter("hideout", File("$projectDir/license-list.xml"))) renderers = arrayOf( InventoryHtmlReportRenderer(), CsvReportRenderer(), JsonReportRenderer(), XmlReportRenderer() ) filters = arrayOf(LicenseBundleNormalizer("$projectDir/license-normalizer-bundle.json", true)) allowedLicensesFile = File("$projectDir/allowed-licenses.json") configurations = arrayOf("productionRuntimeClasspath") }