openai/openai-java
Publicmirrored from https://github.com/openai/openai-javaAvailable
buildSrc/src/main/kotlin/openai.java.gradle.kts
55lines · modecode
| 1 | import com.diffplug.gradle.spotless.SpotlessExtension |
| 2 | import org.gradle.api.tasks.testing.logging.TestExceptionFormat |
| 3 | |
| 4 | plugins { |
| 5 | `java-library` |
| 6 | id("com.diffplug.spotless") |
| 7 | } |
| 8 | |
| 9 | repositories { |
| 10 | mavenCentral() |
| 11 | } |
| 12 | |
| 13 | configure<SpotlessExtension> { |
| 14 | java { |
| 15 | importOrder() |
| 16 | removeUnusedImports() |
| 17 | palantirJavaFormat() |
| 18 | toggleOffOn() |
| 19 | } |
| 20 | } |
| 21 | |
| 22 | java { |
| 23 | toolchain { |
| 24 | languageVersion.set(JavaLanguageVersion.of(21)) |
| 25 | } |
| 26 | |
| 27 | sourceCompatibility = JavaVersion.VERSION_1_8 |
| 28 | targetCompatibility = JavaVersion.VERSION_1_8 |
| 29 | } |
| 30 | |
| 31 | tasks.withType<JavaCompile>().configureEach { |
| 32 | options.compilerArgs.add("-Werror") |
| 33 | options.release.set(8) |
| 34 | } |
| 35 | |
| 36 | tasks.named<Jar>("jar") { |
| 37 | manifest { |
| 38 | attributes(mapOf( |
| 39 | "Implementation-Title" to project.name, |
| 40 | "Implementation-Version" to project.version |
| 41 | )) |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | tasks.withType<Test>().configureEach { |
| 46 | useJUnitPlatform() |
| 47 | |
| 48 | // Run tests in parallel to some degree. |
| 49 | maxParallelForks = (Runtime.getRuntime().availableProcessors() / 2).coerceAtLeast(1) |
| 50 | forkEvery = 100 |
| 51 | |
| 52 | testLogging { |
| 53 | exceptionFormat = TestExceptionFormat.FULL |
| 54 | } |
| 55 | } |
| 56 | |