|
| 1 | +import com.netflix.graphql.dgs.codegen.gradle.GenerateJavaTask |
| 2 | + |
| 3 | +/* |
| 4 | +The Library Loader plugin currently has an IDEA bug that causes it to not recognize the "libs" variable. |
| 5 | +Until https://youtrack.jetbrains.com/issue/KTIJ-19369 is fixed the suppress annotation is required. |
| 6 | + */ |
| 7 | +@Suppress("DSL_SCOPE_VIOLATION") |
| 8 | +plugins { |
| 9 | + alias(libs.plugins.kotlin.jvm) |
| 10 | + alias(libs.plugins.kotlin.spring) |
| 11 | + alias(libs.plugins.kotlin.serialization) |
| 12 | + alias(libs.plugins.spring.boot) |
| 13 | + alias(libs.plugins.spring.dependencymanagement) |
| 14 | + alias(libs.plugins.kotlin.jpa) |
| 15 | + alias(libs.plugins.kotlin.kapt) |
| 16 | + alias(libs.plugins.dgs.codegen) |
| 17 | + alias(libs.plugins.kotlin.allopen) |
| 18 | + alias(libs.plugins.kotlin.noarg) |
| 19 | + java |
| 20 | + alias(libs.plugins.ksp) |
| 21 | + id("bee.generative") |
| 22 | + |
| 23 | +} |
| 24 | + |
| 25 | +allprojects { |
| 26 | + |
| 27 | + tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> { |
| 28 | + kotlinOptions { |
| 29 | + freeCompilerArgs = listOf("-Xjsr305=strict") |
| 30 | + jvmTarget = "17" |
| 31 | + } |
| 32 | + } |
| 33 | + |
| 34 | + tasks.register<Task>(name = "resolveDependencies") { |
| 35 | + group = "Build Setup" |
| 36 | + description = "Resolve and prefetch dependencies" |
| 37 | + doLast { |
| 38 | + rootProject.allprojects.forEach { |
| 39 | + it.buildscript.configurations.filter(Configuration::isCanBeResolved).forEach { it.resolve() } |
| 40 | + it.configurations.filter(Configuration::isCanBeResolved).forEach { it.resolve() } |
| 41 | + } |
| 42 | + } |
| 43 | + } |
| 44 | +} |
| 45 | + |
| 46 | +group = "com.beeproduced" |
| 47 | +version = libs.versions.bee.built.get() |
| 48 | +java.sourceCompatibility = JavaVersion.VERSION_17 |
| 49 | +java.targetCompatibility = JavaVersion.VERSION_17 |
| 50 | + |
| 51 | +configurations { |
| 52 | + compileOnly { |
| 53 | + extendsFrom(configurations.annotationProcessor.get()) |
| 54 | + } |
| 55 | +} |
| 56 | + |
| 57 | +repositories { |
| 58 | + mavenCentral() |
| 59 | +} |
| 60 | + |
| 61 | +dependencies { |
| 62 | + // in-house libraries |
| 63 | + implementation("com.beeproduced:events") |
| 64 | + implementation("com.beeproduced:events") { |
| 65 | + capabilities { requireCapability("com.beeproduced:events-simple") } |
| 66 | + } |
| 67 | + implementation("com.beeproduced:result") { |
| 68 | + capabilities { requireCapability("com.beeproduced:result-dgs") } |
| 69 | + } |
| 70 | + implementation("com.beeproduced:data") |
| 71 | + implementation("com.beeproduced:data") { |
| 72 | + capabilities { requireCapability("com.beeproduced:data-dgs") } |
| 73 | + } |
| 74 | + beeGenerative("com.beeproduced:bee.fetched") |
| 75 | + // external dependencies |
| 76 | + implementation(libs.kotlin.stdlib) |
| 77 | + implementation(libs.spring.boot.starter.web) |
| 78 | + implementation(libs.spring.boot.starter.data.jpa) |
| 79 | + implementation(libs.spring.boot.starter.websocket) |
| 80 | + implementation(libs.spring.boot.starter.validation) |
| 81 | + implementation(libs.spring.boot.starter.cache) |
| 82 | + implementation(libs.spring.boot.starter.actuator) |
| 83 | + implementation(libs.spring.boot.starter.aop) |
| 84 | + implementation(libs.spring.boot.starter.security) |
| 85 | + implementation(libs.spring.boot.starter.oauth2.resource.server) |
| 86 | + implementation(libs.spring.boot.starter.oauth2.client) |
| 87 | + implementation(libs.spring.security.config) |
| 88 | + implementation(libs.spring.security.messaging) |
| 89 | + implementation(libs.spring.security.web) |
| 90 | + implementation(libs.jackson.module.kotlin) |
| 91 | + implementation(platform(libs.dgs.platform)) |
| 92 | + implementation(libs.dgs.spring.starter) |
| 93 | + implementation(libs.dgs.pagination) |
| 94 | + implementation(libs.dgs.subscription.websockets) |
| 95 | + implementation(libs.dgs.extended.scalars) |
| 96 | + implementation(libs.konform) |
| 97 | + implementation(libs.mapstruct) |
| 98 | + implementation(libs.datafaker) |
| 99 | + implementation("org.apache.tika:tika-core:2.4.1") |
| 100 | + kapt(libs.mapstruct.processor) |
| 101 | + testImplementation(libs.spring.boot.starter.test) |
| 102 | + testImplementation(libs.spring.boot.starter.data.jpa) |
| 103 | + testImplementation(libs.spring.security.test) |
| 104 | + testImplementation(libs.junit.api) |
| 105 | + testImplementation(libs.kotlin.test) |
| 106 | + testRuntimeOnly(libs.junit.engine) |
| 107 | + implementation(libs.h2) |
| 108 | + testImplementation(libs.springmockk) |
| 109 | + |
| 110 | + if (System.getProperty("os.arch") == "aarch64" && System.getProperty("os.name") == "Mac OS X") { |
| 111 | + runtimeOnly("io.netty:netty-resolver-dns-native-macos:4.1.76.Final:osx-aarch_64") |
| 112 | + } |
| 113 | +} |
| 114 | + |
| 115 | +tasks.withType<Test> { |
| 116 | + useJUnitPlatform() |
| 117 | +} |
| 118 | + |
| 119 | + |
| 120 | +// DGS Codegen |
| 121 | +// See: https://stackoverflow.com/a/70954759/12347616 |
| 122 | +tasks.withType<GenerateJavaTask> { |
| 123 | + notCompatibleWithConfigurationCache("Remove later") |
| 124 | + packageName = "com.beeproduced.bee.fetched.graphql" |
| 125 | + subPackageNameTypes = "dto" |
| 126 | + generateCustomAnnotations = true |
| 127 | + generateClient = true |
| 128 | + typeMapping = mutableMapOf( |
| 129 | + "DateTime" to "java.time.Instant", |
| 130 | + "Upload" to "org.springframework.web.multipart.MultipartFile" |
| 131 | + ) |
| 132 | +} |
| 133 | + |
| 134 | +beeGenerative { |
| 135 | + arg("fetchedScanPackage", "com.beeproduced.bee.fetched.graphql.dto") |
| 136 | + arg("fetchedPackageName", "com.beeproduced.bee.fetched.graphql.fetcher") |
| 137 | +} |
| 138 | + |
| 139 | +kapt { |
| 140 | + // Fix error: incompatible types: NonExistentClass cannot be converted to Annotation |
| 141 | + // @error.NonExistentClass |
| 142 | + // https://stackoverflow.com/a/55646891/12347616 |
| 143 | + correctErrorTypes = true |
| 144 | + arguments { |
| 145 | + // Set Mapstruct Configuration options here |
| 146 | + // https://kotlinlang.org/docs/reference/kapt.html#annotation-processor-arguments |
| 147 | + // https://mapstruct.org/documentation/stable/reference/html/#configuration-options |
| 148 | + arg("mapstruct.defaultComponentModel", "spring") |
| 149 | + } |
| 150 | +} |
| 151 | + |
| 152 | +tasks.getByName<Jar>("jar") { |
| 153 | + enabled = false |
| 154 | +} |
| 155 | + |
| 156 | + |
| 157 | +tasks.bootRun { |
| 158 | + jvmArgs = listOf("-Dspring.output.ansi.enabled=ALWAYS") |
| 159 | +} |
0 commit comments