|
| 1 | +import org.gradle.api.JavaVersion.VERSION_11 |
| 2 | +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile |
| 3 | + |
| 4 | +group = "org.utbot" |
| 5 | + |
| 6 | +val kotlinVersion: String by project |
| 7 | +val semVer: String? by project |
| 8 | +val coroutinesVersion: String by project |
| 9 | +val collectionsVersion: String by project |
| 10 | +val junit5Version: String by project |
| 11 | + |
| 12 | +version = semVer ?: "1.0-SNAPSHOT" |
| 13 | + |
| 14 | +plugins { |
| 15 | + `java-library` |
| 16 | + kotlin("jvm") version "1.7.10" |
| 17 | + `maven-publish` |
| 18 | +} |
| 19 | + |
| 20 | +configure<JavaPluginExtension> { |
| 21 | + sourceCompatibility = VERSION_11 |
| 22 | + targetCompatibility = VERSION_11 |
| 23 | +} |
| 24 | + |
| 25 | +allprojects { |
| 26 | + |
| 27 | + apply { |
| 28 | + plugin("maven-publish") |
| 29 | + plugin("kotlin") |
| 30 | + } |
| 31 | + |
| 32 | + tasks { |
| 33 | + withType<JavaCompile> { |
| 34 | + sourceCompatibility = "1.8" |
| 35 | + targetCompatibility = "1.8" |
| 36 | + options.encoding = "UTF-8" |
| 37 | + options.compilerArgs = options.compilerArgs + "-Xlint:all" |
| 38 | + } |
| 39 | + withType<KotlinCompile> { |
| 40 | + kotlinOptions { |
| 41 | + jvmTarget = "1.8" |
| 42 | + freeCompilerArgs = freeCompilerArgs + listOf("-Xallow-result-return-type", "-Xsam-conversions=class") |
| 43 | + allWarningsAsErrors = false |
| 44 | + } |
| 45 | + } |
| 46 | + compileTestKotlin { |
| 47 | + kotlinOptions { |
| 48 | + jvmTarget = "1.8" |
| 49 | + freeCompilerArgs = freeCompilerArgs + listOf("-Xallow-result-return-type", "-Xsam-conversions=class") |
| 50 | + allWarningsAsErrors = false |
| 51 | + } |
| 52 | + } |
| 53 | + withType<Test> { |
| 54 | + // set heap size for the test JVM(s) |
| 55 | + minHeapSize = "128m" |
| 56 | + maxHeapSize = "3072m" |
| 57 | + |
| 58 | + jvmArgs = listOf("-XX:MaxHeapSize=3072m") |
| 59 | + |
| 60 | + useJUnitPlatform { |
| 61 | + excludeTags = setOf("slow", "IntegrationTest") |
| 62 | + } |
| 63 | + |
| 64 | + addTestListener(object : TestListener { |
| 65 | + override fun beforeSuite(suite: TestDescriptor) {} |
| 66 | + override fun beforeTest(testDescriptor: TestDescriptor) {} |
| 67 | + override fun afterTest(testDescriptor: TestDescriptor, result: TestResult) { |
| 68 | + println("[$testDescriptor.classDisplayName] [$testDescriptor.displayName]: $result.resultType") |
| 69 | + } |
| 70 | + |
| 71 | + override fun afterSuite(testDescriptor: TestDescriptor, result: TestResult) { |
| 72 | + if (testDescriptor.parent == null) { // will match the outermost suite |
| 73 | + println("Test summary: ${result.resultType} (${result.testCount} tests, ${result.successfulTestCount} successes, ${result.failedTestCount} failures, ${result.skippedTestCount} skipped)") |
| 74 | + } |
| 75 | + } |
| 76 | + }) |
| 77 | + } |
| 78 | + } |
| 79 | + |
| 80 | + repositories { |
| 81 | + mavenCentral() |
| 82 | + maven("https://jitpack.io") |
| 83 | + maven("https://plugins.gradle.org/m2") |
| 84 | + maven("https://www.jetbrains.com/intellij-repository/releases") |
| 85 | + maven("https://cache-redirector.jetbrains.com/maven-central") |
| 86 | + } |
| 87 | + |
| 88 | + dependencies { |
| 89 | + implementation(group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-core", version = coroutinesVersion) |
| 90 | + implementation( |
| 91 | + group = "org.jetbrains.kotlinx", |
| 92 | + name = "kotlinx-collections-immutable-jvm", |
| 93 | + version = collectionsVersion |
| 94 | + ) |
| 95 | + implementation(group = "org.jetbrains.kotlin", name = "kotlin-stdlib-jdk8", version = kotlinVersion) |
| 96 | + implementation(group = "org.jetbrains.kotlin", name = "kotlin-reflect", version = kotlinVersion) |
| 97 | + |
| 98 | + testImplementation("org.junit.jupiter:junit-jupiter") { |
| 99 | + version { |
| 100 | + strictly(junit5Version) |
| 101 | + } |
| 102 | + } |
| 103 | + } |
| 104 | +} |
| 105 | + |
| 106 | +subprojects { |
| 107 | + group = rootProject.group |
| 108 | + version = rootProject.version |
| 109 | + |
| 110 | + publishing { |
| 111 | + publications { |
| 112 | + create<MavenPublication>("jar") { |
| 113 | + from(components["java"]) |
| 114 | + groupId = "org.utbot" |
| 115 | + artifactId = project.name |
| 116 | + } |
| 117 | + } |
| 118 | + } |
| 119 | +} |
| 120 | + |
| 121 | +dependencies { |
| 122 | + implementation(group = "org.jetbrains.kotlin", name = "kotlin-gradle-plugin", version = kotlinVersion) |
| 123 | + implementation(group = "org.jetbrains.kotlin", name = "kotlin-allopen", version = kotlinVersion) |
| 124 | +} |
| 125 | + |
| 126 | +configure( |
| 127 | + listOf( |
| 128 | + project(":utbot-api"), |
| 129 | + project(":utbot-core"), |
| 130 | + project(":utbot-framework"), |
| 131 | + project(":utbot-framework-api"), |
| 132 | + project(":utbot-fuzzers"), |
| 133 | + project(":utbot-instrumentation"), |
| 134 | + project(":utbot-summary") |
| 135 | + ) |
| 136 | +) { |
| 137 | + publishing { |
| 138 | + repositories { |
| 139 | + maven { |
| 140 | + name = "GitHubPackages" |
| 141 | + url = uri("https://maven.pkg.github.com/UnitTestBot/UTBotJava") |
| 142 | + credentials { |
| 143 | + username = System.getenv("GITHUB_ACTOR") |
| 144 | + password = System.getenv("GITHUB_TOKEN") |
| 145 | + } |
| 146 | + } |
| 147 | + } |
| 148 | + } |
| 149 | +} |
0 commit comments