-
Notifications
You must be signed in to change notification settings - Fork 28
/
build.gradle.kts
363 lines (276 loc) · 10.1 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
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
import org.gradle.util.internal.VersionNumber
import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask
import org.gradle.api.specs.Spec
val vs = versions()
buildscript {
repositories {
// Add here whatever repositories you're already using
mavenCentral()
}
dependencies {
classpath("ch.epfl.scala:gradle-bloop_2.12:1.6.2") // suffix is always 2.12, weird
}
}
tasks.named<DependencyUpdatesTask>("dependencyUpdates").configure {
filterConfigurations = Spec<Configuration> {
!it.name.startsWith("incrementalScalaAnalysis")
}
}
plugins {
`java-test-fixtures`
scala
idea
signing
`maven-publish`
id("io.github.gradle-nexus.publish-plugin") version "2.0.0"
id("com.github.ben-manes.versions") version "0.51.0"
id("io.github.cosmicsilence.scalafix") version "0.2.2"
}
val sonatypeApiUser = providers.gradleProperty("sonatypeApiUser")
val sonatypeApiKey = providers.gradleProperty("sonatypeApiKey")
if (sonatypeApiUser.isPresent && sonatypeApiKey.isPresent) {
nexusPublishing {
repositories {
sonatype {
// nexusUrl.set(uri("https://oss.sonatype.org/service/local/"))
// snapshotRepositoryUrl.set(uri("https://oss.sonatype.org/content/repositories/snapshots/"))
username.set(sonatypeApiUser)
password.set(sonatypeApiKey)
// useStaging.set(true)
}
}
}
} else {
logger.warn("Sonatype API key not defined, skipping configuration of Maven Central publishing repository")
}
allprojects {
apply(plugin = "java-library")
apply(plugin = "java-test-fixtures")
// apply(plugin = "bloop")
// DO NOT enable! In VSCode it will cause the conflict:
// Cannot add extension with name 'bloop', as there is an extension already registered with that name
apply(plugin = "scala")
apply(plugin = "idea")
apply(plugin = "signing")
apply(plugin = "maven-publish")
group = vs.projectGroup
version = vs.projectV
repositories {
mavenCentral()
// jcenter()
maven("https://dl.bintray.com/kotlin/kotlin-dev")
maven("https://scala-ci.typesafe.com/artifactory/scala-integration/") // scala SNAPSHOT
}
fun includeShims(from: String, to: String) {
sourceSets {
main {
scala {
setSrcDirs(srcDirs + listOf("src/main/scala-${from}+/${to}"))
}
resources {
setSrcDirs(srcDirs + listOf("src/main/resources-${from}+/${to}"))
}
}
testFixtures {
scala {
setSrcDirs(srcDirs + listOf("src/testFixtures/scala-${from}+/${to}"))
}
resources {
setSrcDirs(srcDirs + listOf("src/testFixtures/resources-${from}+/${to}"))
}
}
test {
scala {
setSrcDirs(srcDirs + listOf("src/test/scala-${from}+/${to}"))
}
resources {
setSrcDirs(srcDirs + listOf("src/test/resources-${from}+/${to}"))
}
}
}
}
val vn = VersionNumber.parse(vs.scalaV)
val supportedPatchVs = 7..12
for (from in supportedPatchVs) {
if (vn.micro >= from) {
includeShims("2.13.${from}", "latest")
}
for (to in supportedPatchVs) {
if (vn.micro <= to) {
includeShims("2.13.${from}", "2.13.${to}")
}
}
}
dependencies {
constraints {}
// see https://github.com/gradle/gradle/issues/13067
// fun bothImpl(constraintNotation: Any) {
// implementation(constraintNotation)
// testFixturesImplementation(constraintNotation)
// }
implementation("${vs.scalaGroup}:scala-library:${vs.scalaV}")
val scalaTestV = "3.2.11"
testFixturesApi("org.scalatest:scalatest_${vs.scalaBinaryV}:${scalaTestV}")
testImplementation("org.junit.jupiter:junit-jupiter:5.11.2")
testRuntimeOnly("co.helmethair:scalatest-junit-runner:0.2.0")
}
task("dependencyTree") {
dependsOn("dependencies")
}
val jvmTarget = JavaVersion.VERSION_1_8
java {
withSourcesJar()
withJavadocJar()
sourceCompatibility = jvmTarget
targetCompatibility = jvmTarget
}
tasks {
withType<ScalaCompile> {
sourceCompatibility = jvmTarget.toString()
targetCompatibility = jvmTarget.toString()
scalaCompileOptions.apply {
// isForce = true
loggingLevel = "verbose"
val compilerOptions =
mutableListOf(
"-encoding", "UTF-8",
"-deprecation",
"-unchecked",
"-feature",
"-language:higherKinds",
"-language:existentials",
"-Ywarn-value-discard",
"-Ywarn-unused:imports",
"-Ywarn-unused:implicits",
"-Ywarn-unused:params",
"-Ywarn-unused:patvars"
// "-Ydebug-error"
)
additionalParameters = compilerOptions
forkOptions.apply {
memoryInitialSize = "1g"
memoryMaximumSize = "4g"
// this may be over the top but the test code in macro & core frequently run implicit search on church encoded Nat type
jvmArgs = listOf(
"-Xss256m"
)
}
}
}
test {
minHeapSize = "1024m"
maxHeapSize = "4096m"
testLogging {
showExceptions = true
showCauses = true
showStackTraces = true
// stdout is used for occasional manual verification
showStandardStreams = true
}
// useJUnit()
useJUnitPlatform {
includeEngines("scalatest")
testLogging {
events("passed", "skipped", "failed")
}
}
}
}
apply(plugin = "io.github.cosmicsilence.scalafix")
scalafix {
semanticdb.autoConfigure.set(true)
semanticdb.version.set("4.8.11")
}
idea {
module {
excludeDirs = excludeDirs + files(
"target",
"out",
".idea",
".vscode",
".bloop",
".bsp",
".metals",
"bin",
".ammonite",
"logs",
)
isDownloadJavadoc = true
isDownloadSources = true
}
}
}
subprojects {
// https://stackoverflow.com/a/66352905/1772342
// val signingKeyID = providers.gradleProperty("signing.gnupg.keyID")
val signingSecretKey = providers.gradleProperty("signing.gnupg.secretKey")
val signingKeyPassphrase = providers.gradleProperty("signing.gnupg.passphrase")
signing {
useGpgCmd()
if (signingSecretKey.isPresent) {
useInMemoryPgpKeys(signingSecretKey.get(), signingKeyPassphrase.get())
// useInMemoryPgpKeys(signingKeyID.get(), signingSecretKey.get(), signingKeyPassphrase.get())
sign(extensions.getByType<PublishingExtension>().publications)
} else {
logger.warn("PGP signing key not defined, skipping signing configuration")
}
}
publishing {
val suffix = "_" + vs.scalaV
val rootID = vs.projectRootID
val moduleID =
if (project.name.equals(rootID))// rootID + "-" + "parent" + suffix
throw kotlin.UnsupportedOperationException("root project should not be published")
else if (project.name.equals("core")) rootID + suffix
else rootID + "-" + project.name + suffix
val whitelist = setOf("core")
if (whitelist.contains(project.name)) {
publications {
create<MavenPublication>("maven") {
val javaComponent = components["java"] as AdhocComponentWithVariants
from(javaComponent)
javaComponent.withVariantsFromConfiguration(configurations["testFixturesApiElements"]) { skip() }
javaComponent.withVariantsFromConfiguration(configurations["testFixturesRuntimeElements"]) { skip() }
artifactId = moduleID
version = project.version.toString()
pom {
licenses {
license {
name.set("MIT")
url.set("http://opensource.org/licenses/MIT")
}
}
name.set("splain")
description.set("A scala compiler plugin for more concise errors")
val github = "https://github.com/tek"
val repo = github + "/splain"
url.set(repo)
developers {
developer {
id.set("tryp")
name.set("Torsten Schmits")
email.set("[email protected]")
url.set(github)
}
}
scm {
connection.set("scm:[email protected]:tek/splain")
url.set(repo)
}
}
}
}
}
}
}
idea {
targetVersion = "2020"
module {
excludeDirs = excludeDirs + files(
".gradle",
"gradle",
"spike",
".history"
)
}
}