-
Notifications
You must be signed in to change notification settings - Fork 34
/
build.gradle.kts
248 lines (220 loc) · 7.84 KB
/
build.gradle.kts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
import groovy.util.*
import kotlinx.team.infra.*
import org.gradle.jvm.tasks.Jar
import org.jetbrains.kotlin.gradle.*
// atomicfu
buildscript {
val atomicfuVersion: String by project
dependencies {
classpath("org.jetbrains.kotlinx:atomicfu-gradle-plugin:$atomicfuVersion")
}
}
apply(plugin = "kotlinx-atomicfu")
plugins {
java
kotlin("multiplatform")
id("maven-publish")
id("kotlinx.team.infra") version "0.4.0-dev-80"
}
repositories {
mavenCentral()
}
kotlin {
@OptIn(ExperimentalKotlinGradlePluginApi::class)
compilerOptions {
allWarningsAsErrors = true
}
jvm {
withJava()
val main by compilations.getting {
kotlinOptions.jvmTarget = "11"
}
val test by compilations.getting {
kotlinOptions.jvmTarget = "11"
}
}
sourceSets {
val jvmMain by getting {
kotlin.srcDir("src/jvm/main")
val kotlinVersion: String by project
val kotlinxCoroutinesVersion: String by project
val asmVersion: String by project
val byteBuddyVersion: String by project
dependencies {
compileOnly(project(":bootstrap"))
api("org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion")
api("org.jetbrains.kotlin:kotlin-stdlib-common:$kotlinVersion")
api("org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion")
api("org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlinxCoroutinesVersion")
api("org.ow2.asm:asm-commons:$asmVersion")
api("org.ow2.asm:asm-util:$asmVersion")
api("net.bytebuddy:byte-buddy:$byteBuddyVersion")
api("net.bytebuddy:byte-buddy-agent:$byteBuddyVersion")
}
}
val jvmTest by getting {
kotlin.srcDir("src/jvm/test")
val junitVersion: String by project
val jctoolsVersion: String by project
val mockkVersion: String by project
dependencies {
implementation(project(":bootstrap"))
implementation("junit:junit:$junitVersion")
implementation("org.jctools:jctools-core:$jctoolsVersion")
implementation("io.mockk:mockk:${mockkVersion}")
}
}
}
}
java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
toolchain {
val jdkToolchainVersion: String by project
languageVersion = JavaLanguageVersion.of(jdkToolchainVersion)
}
}
sourceSets.main {
java.srcDirs("src/jvm/main")
}
sourceSets.test {
java.srcDirs("src/jvm/test")
resources {
srcDir("src/jvm/test/resources")
}
}
val bootstrapJar = tasks.register<Copy>("bootstrapJar") {
dependsOn(":bootstrap:jar")
from(file("${project(":bootstrap").buildDir}/libs/bootstrap.jar"))
into(file("$buildDir/processedResources/jvm/main"))
}
tasks {
named("processResources").configure {
dependsOn(bootstrapJar)
}
replace("jvmSourcesJar", Jar::class).run {
from(sourceSets["main"].allSource)
}
fun Test.configureJvmTestCommon() {
maxParallelForks = 1
maxHeapSize = "6g"
val instrumentAllClasses: String by project
if (instrumentAllClasses.toBoolean()) {
systemProperty("lincheck.instrumentAllClasses", "true")
}
val extraArgs = mutableListOf<String>()
val withEventIdSequentialCheck: String by project
if (withEventIdSequentialCheck.toBoolean()) {
extraArgs.add("-Dlincheck.debug.withEventIdSequentialCheck=true")
}
extraArgs.add("-Dlincheck.version=$version")
jvmArgs(extraArgs)
}
val jvmTest = named<Test>("jvmTest") {
val ideaActive = System.getProperty("idea.active") == "true"
if (!ideaActive) {
// We need to be able to run these tests in IntelliJ IDEA.
// Unfortunately, the current Gradle support doesn't detect
// the `jvmTestIsolated` task.
exclude("**/*IsolatedTest*")
}
// Do not run JdkUnsafeTraceRepresentationTest on Java 12 or earlier,
// as this test relies on specific ConcurrentHashMap implementation.
val jdkToolchainVersion: String by project
if (jdkToolchainVersion.toInt() < 13) {
exclude("**/*JdkUnsafeTraceRepresentationTest*")
}
configureJvmTestCommon()
val runAllTestsInSeparateJVMs: String by project
forkEvery = when {
runAllTestsInSeparateJVMs.toBoolean() -> 1
// When running `jvmTest` from IntelliJ IDEA, we need to
// be able to run `*IsolatedTest`s and isolate these tests
// some way. Running all the tests in separate VM instances
// significantly slows down the build. Therefore, we run
// several tests in the same VM instance instead, trying
// to balance between slowing down the build because of launching
// new VM instances periodically and slowing down the build
// because of the hanging threads in the `*IsolatedTest` ones.
ideaActive -> 10
else -> 0
}
}
val jvmTestIsolated = register<Test>("jvmTestIsolated") {
group = jvmTest.get().group
testClassesDirs = jvmTest.get().testClassesDirs
classpath = jvmTest.get().classpath
enableAssertions = true
testLogging.showStandardStreams = true
outputs.upToDateWhen { false } // Always run tests when called
include("**/*IsolatedTest*")
configureJvmTestCommon()
forkEvery = 1
}
check {
dependsOn(jvmTestIsolated)
}
withType<Jar> {
dependsOn(bootstrapJar)
manifest {
val inceptionYear: String by project
val lastCopyrightYear: String by project
val version: String by project
attributes(
"Copyright" to
"Copyright (C) 2015 - 2019 Devexperts, LLC\n " +
"Copyright (C) $inceptionYear - $lastCopyrightYear JetBrains, s.r.o.",
// This attribute let us get the version from the code.
"Implementation-Version" to version
)
}
}
}
infra {
teamcity {
val name: String by project
val version: String by project
libraryStagingRepoDescription = "$name $version"
}
publishing {
include(":")
libraryRepoUrl = "https://github.com/Kotlin/kotlinx-lincheck"
sonatype {}
}
}
publishing {
project.establishSignDependencies()
}
fun Project.establishSignDependencies() {
// Sign plugin issues and publication:
// Establish dependency between 'sign' and 'publish*' tasks.
tasks.withType<AbstractPublishToMaven>().configureEach {
dependsOn(tasks.withType<Sign>())
}
}
mavenPublicationsPom {
description.set("Lincheck - Framework for testing concurrent data structures")
val licenceName = "Mozilla Public License Version 2.0"
licenses {
license {
name.set(licenceName)
url.set("https://www.mozilla.org/en-US/MPL/2.0/")
distribution.set("repo")
}
}
withXml {
removeAllLicencesExceptOne(licenceName)
}
}
// kotlinx.team.infra adds Apache License, Version 2.0, remove it manually
fun XmlProvider.removeAllLicencesExceptOne(licenceName: String) {
val licenseList = (asNode()["licenses"] as NodeList)[0] as Node
val licenses = licenseList["license"] as NodeList
licenses.filterIsInstance<Node>().forEach { licence ->
val name = (licence["name"] as NodeList)[0] as Node
val nameValue = (name.value() as NodeList)[0] as String
if (nameValue != licenceName) {
licenseList.remove(licence)
}
}
}