-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
855 lines (704 loc) · 26.4 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
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
import com.android.build.api.dsl.ApplicationExtension
import com.android.build.gradle.LibraryExtension
import org.jetbrains.kotlin.de.undercouch.gradle.tasks.download.Download
import org.jetbrains.kotlin.de.undercouch.gradle.tasks.download.Verify
import org.jetbrains.kotlin.gradle.dsl.KotlinAndroidProjectExtension
import org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension
val gradleVersionRequired = "8.10.2"
val gradleVersionReceived = gradle.gradleVersion
if (gradleVersionRequired != gradleVersionReceived) {
throw GradleException(
"Gradle version $gradleVersionRequired is required to run this build. You are using Gradle $gradleVersionReceived",
)
}
plugins {
signing
id("org.jetbrains.kotlin.jvm")
.version("1.9.0")
.apply(false)
id("org.jetbrains.kotlin.android")
.version("1.9.0")
.apply(false)
id("com.github.ben-manes.versions")
.version("0.51.0")
.apply(true)
/*
* The AndroidX plugin for navigation (including view binding generation).
*
* https://developer.android.com/jetpack/androidx/releases/navigation
*/
id("androidx.navigation.safeargs.kotlin")
.version("2.7.1")
.apply(false)
id("com.android.library")
.version("8.5.0")
.apply(false)
id("com.android.application")
.version("8.5.0")
.apply(false)
/*
* Android Junit5 plugin. Required to run JUnit 5 tests on Android projects.
*
* https://github.com/mannodermaus/android-junit5
*/
id("de.mannodermaus.android-junit5")
.version("1.9.3.0")
.apply(false)
/*
* Download plugin. Used to fetch artifacts such as Scando during the build.
*
* https://plugins.gradle.org/plugin/de.undercouch.download
*/
id("de.undercouch.download")
.version("5.4.0")
.apply(false)
/*
* https://developers.google.com/android/guides/google-services-plugin
*/
id("com.google.gms.google-services")
.version("4.3.15")
.apply(false)
/*
* https://firebase.google.com/docs/crashlytics/get-started?platform=android
*/
id("com.google.firebase.crashlytics")
.version("2.9.9")
.apply(false)
id("maven-publish")
}
/*
* The various paths used during the build.
*/
val palaceRootBuildDirectory =
"$rootDir/build"
val palaceDeployDirectory =
"$palaceRootBuildDirectory/maven"
val palaceScandoJarFile =
"$rootDir/scando.jar"
val palaceKtlintJarFile =
"$rootDir/ktlint.jar"
/**
* Convenience functions to read strongly-typed values from property files.
*/
fun property(
project: Project,
name: String,
): String {
return project.extra[name] as String
}
fun propertyOptional(project: Project, name: String): String? {
val map = project.extra
if (map.has(name)) {
return map[name] as String?
}
return null
}
fun propertyInt(
project: Project,
name: String,
): Int {
val text = property(project, name)
return text.toInt()
}
fun propertyBoolean(
project: Project,
name: String,
): Boolean {
val text = property(project, name)
return text.toBooleanStrict()
}
fun propertyBooleanOptional(
project: Project,
name: String,
defaultValue: Boolean,
): Boolean {
val value = propertyOptional(project, name) ?: return defaultValue
return value.toBooleanStrict()
}
/**
* Configure Maven publishing. Artifacts are published to a local directory
* so that they can be pushed to Maven Central in one step using brooklime.
*/
fun configurePublishingFor(project: Project) {
val mavenCentralUsername =
(project.findProperty("mavenCentralUsername") ?: "") as String
val mavenCentralPassword =
(project.findProperty("mavenCentralPassword") ?: "") as String
val versionName =
property(project, "VERSION_NAME")
val packaging =
property(project, "POM_PACKAGING")
val publishSources =
propertyBoolean(project, "org.thepalaceproject.build.publishSources")
val enableSigning =
propertyBooleanOptional(project, "org.thepalaceproject.build.enableSigning", true)
/*
* Create an empty JavaDoc jar. Required for Maven Central deployments.
*/
val taskJavadocEmpty =
project.task("JavadocEmptyJar", org.gradle.jvm.tasks.Jar::class) {
this.archiveClassifier = "javadoc"
}
/*
* Create a publication. Note that the name of the publication must be unique across all
* modules, because the broken Gradle signing plugin will create a signing task for each
* one that, in the case of a name conflict, will silently overwrite the previous signing
* task.
*/
project.publishing {
publications {
create<MavenPublication>("_${project.name}_MavenPublication") {
groupId = property(project, "GROUP")
artifactId = property(project, "POM_ARTIFACT_ID")
version = versionName
/*
* https://central.sonatype.org/publish/requirements/#sufficient-metadata
*/
pom {
name.set(property(project, "POM_NAME"))
description.set(property(project, "POM_DESCRIPTION"))
url.set(property(project, "POM_URL"))
scm {
connection.set(property(project, "POM_SCM_CONNECTION"))
developerConnection.set(property(project, "POM_SCM_DEV_CONNECTION"))
url.set(property(project, "POM_SCM_URL"))
}
licenses {
license {
name.set(property(project, "POM_LICENCE_NAME"))
url.set(property(project, "POM_LICENCE_URL"))
}
}
developers {
developer {
name.set("The Palace Project")
email.set("[email protected]")
organization.set("The Palace Project")
organizationUrl.set("https://thepalaceproject.org/")
}
}
}
artifact(taskJavadocEmpty)
from(
when (packaging) {
"jar" -> {
project.components["java"]
}
"aar" -> {
project.components["release"]
}
"apk" -> {
project.components["release"]
}
else -> {
throw java.lang.IllegalArgumentException(
"Cannot set up publishing for packaging type $packaging",
)
}
},
)
}
}
repositories {
maven {
name = "Directory"
url = uri(palaceDeployDirectory)
}
/*
* Only deploy to the Sonatype snapshots repository if the current version is a
* snapshot version.
*/
if (versionName.endsWith("-SNAPSHOT")) {
maven {
name = "SonatypeCentralSnapshots"
url = uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")
credentials {
username = mavenCentralUsername
password = mavenCentralPassword
}
}
}
}
}
/*
* If source publications are disabled in the project properties, it seems that the only
* way to stop the Android plugins from publishing sources is to manually "disable" the
* publication tasks by deleting all of the actions within the tasks, and then specifying
* a dependency on our own task that produces an empty jar file.
*/
if (!publishSources) {
logger.info("org.thepalaceproject.build.publishSources is false, so source jars are disabled.")
val taskSourcesEmpty =
project.task("SourcesEmptyJar", org.gradle.jvm.tasks.Jar::class) {
this.archiveClassifier = "sources"
}
project.tasks.matching { task -> task.name.endsWith("SourcesJar") }
.forEach { task ->
task.actions.clear()
task.dependsOn.add(taskSourcesEmpty)
}
}
/*
* Configure signing.
*/
if (enableSigning) {
signing {
useGpgCmd()
sign(project.publishing.publications)
}
}
}
/*
* A task that cleans up the Maven deployment directory. The "clean" tasks of
* each project are configured to depend upon this task. This prevents any
* deployment of stale artifacts to remote repositories.
*/
val cleanTask = task("CleanMavenDeployDirectory", Delete::class) {
this.delete.add(palaceDeployDirectory)
}
/**
* A function to download and verify the Scando jar file.
*
* @return The verification task
*/
fun createScandoDownloadTask(project: Project): Task {
val scandoVersion =
"1.0.0"
val scandoSHA256 =
"08fba5fc4bc3b5a49d205a4c38356dc8c7e01f4963adb661b67f9d2ed23751ae"
val scandoSource =
"https://repo1.maven.org/maven2/com/io7m/scando/com.io7m.scando.cmdline/$scandoVersion/com.io7m.scando.cmdline-$scandoVersion-main.jar"
val scandoMakeDirectory =
project.task("ScandoMakeDirectory") {
mkdir(palaceRootBuildDirectory)
}
val scandoDownload =
project.task("ScandoDownload", Download::class) {
src(scandoSource)
dest(file(palaceScandoJarFile))
overwrite(true)
this.dependsOn.add(scandoMakeDirectory)
}
return project.task("ScandoDownloadVerify", Verify::class) {
src(file(palaceScandoJarFile))
checksum(scandoSHA256)
algorithm("SHA-256")
this.dependsOn(scandoDownload)
}
}
/**
* A task to execute Scando to analyze semantic versioning.
*/
fun createScandoAnalyzeTask(project: Project): Task {
val group =
property(project, "GROUP")
val artifactId =
property(project, "POM_ARTIFACT_ID")
val versionCurrent =
property(project, "VERSION_NAME")
val versionPrevious =
property(project, "VERSION_PREVIOUS")
val oldGroup =
group.replace('.', '/')
val oldPath =
"$oldGroup/$artifactId/$versionPrevious/$artifactId-$versionPrevious.aar"
val oldUrl =
"https://repo1.maven.org/maven2/$oldPath"
val commandLineArguments: List<String> = arrayListOf(
"java",
"-jar",
palaceScandoJarFile,
"--excludeList",
"${project.rootDir}/VERSIONING.txt",
"--oldJarUri",
oldUrl,
"--oldJarVersion",
versionPrevious,
"--ignoreMissingOld",
"--newJar",
"${project.buildDir}/outputs/aar/$artifactId-debug.aar",
"--newJarVersion",
versionCurrent,
"--textReport",
"${project.buildDir}/scando-report.txt",
"--htmlReport",
"${project.buildDir}/scando-report.html",
)
return project.task("ScandoAnalyze", Exec::class) {
commandLine = commandLineArguments
}
}
/*
* Create a task in the root project that downloads Scando.
*/
lateinit var scandoDownloadTask: Task
rootProject.afterEvaluate {
apply(plugin = "de.undercouch.download")
scandoDownloadTask = createScandoDownloadTask(this)
}
/**
* A function to download and verify the ktlint jar file.
*
* @return The verification task
*/
fun createKtlintDownloadTask(project: Project): Task {
val ktlintVersion =
"0.50.0"
val ktlintSHA256 =
"c704fbc28305bb472511a1e98a7e0b014aa13378a571b716bbcf9d99d59a5092"
val ktlintSource =
"https://repo1.maven.org/maven2/com/pinterest/ktlint/$ktlintVersion/ktlint-$ktlintVersion-all.jar"
val ktlintMakeDirectory =
project.task("KtlintMakeDirectory") {
mkdir(palaceRootBuildDirectory)
}
val ktlintDownload =
project.task("KtlintDownload", Download::class) {
src(ktlintSource)
dest(file(palaceKtlintJarFile))
overwrite(true)
onlyIfModified(true)
this.dependsOn.add(ktlintMakeDirectory)
}
return project.task("KtlintDownloadVerify", Verify::class) {
src(file(palaceKtlintJarFile))
checksum(ktlintSHA256)
algorithm("SHA-256")
this.dependsOn(ktlintDownload)
}
}
/**
* A task to execute ktlint to check sources.
*/
val ktlintPatterns: List<String> = arrayListOf(
"*/src/**/*.kt",
"*/build.gradle.kts",
"build.gradle.kts",
"!*/src/test/**",
)
fun createKtlintCheckTask(project: Project): Task {
val commandLineArguments: ArrayList<String> = arrayListOf(
"java",
"-jar",
palaceKtlintJarFile,
)
commandLineArguments.addAll(ktlintPatterns)
return project.task("KtlintCheck", Exec::class) {
commandLine = commandLineArguments
}
}
/**
* A task to execute ktlint to reformat sources.
*/
fun createKtlintFormatTask(project: Project): Task {
val commandLineArguments: ArrayList<String> = arrayListOf(
"java",
"-jar",
palaceKtlintJarFile,
"-F",
)
commandLineArguments.addAll(ktlintPatterns)
return project.task("KtlintFormat", Exec::class) {
commandLine = commandLineArguments
}
}
/*
* Create a task in the root project that downloads ktlint.
*/
lateinit var ktlintDownloadTask: Task
rootProject.afterEvaluate {
apply(plugin = "de.undercouch.download")
ktlintDownloadTask = createKtlintDownloadTask(this)
val enableKtlintChecks =
propertyBoolean(this, "org.thepalaceproject.build.enableKtLint")
if (enableKtlintChecks) {
val checkActual = createKtlintCheckTask(this)
checkActual.dependsOn.add(ktlintDownloadTask)
cleanTask.dependsOn.add(checkActual)
}
/*
* Create a task that can be used to reformat sources. This is purely for manual execution
* from the command-line, and is not executed otherwise.
*/
val formatTask = createKtlintFormatTask(this)
formatTask.dependsOn.add(ktlintDownloadTask)
}
allprojects {
/*
* Configure the project metadata.
*/
this.group =
property(this, "GROUP")
this.version =
property(this, "VERSION_NAME")
val jdkBuild =
propertyInt(this, "org.thepalaceproject.build.jdkBuild")
val jdkBytecodeTarget =
propertyInt(this, "org.thepalaceproject.build.jdkBytecodeTarget")
/*
* Configure builds and tests for various project types.
*/
when (extra["POM_PACKAGING"]) {
"pom" -> {
logger.info("Configuring ${this.project} $version as a pom project")
}
"apk" -> {
logger.info("Configuring ${this.project} $version as an apk project")
apply(plugin = "com.android.application")
apply(plugin = "org.jetbrains.kotlin.android")
/*
* Configure the JVM toolchain version that we want to use for Kotlin.
*/
val kotlin: KotlinAndroidProjectExtension =
this.extensions["kotlin"] as KotlinAndroidProjectExtension
val java: JavaPluginExtension =
this.extensions["java"] as JavaPluginExtension
kotlin.jvmToolchain(jdkBuild)
java.toolchain.languageVersion.set(JavaLanguageVersion.of(jdkBuild))
/*
* Configure the various required Android properties.
*/
val android: ApplicationExtension =
this.extensions["android"] as ApplicationExtension
android.namespace =
property(this, "POM_ARTIFACT_ID")
android.compileSdk =
propertyInt(this, "org.thepalaceproject.build.androidSDKCompile")
android.defaultConfig {
multiDexEnabled = true
targetSdk =
propertyInt(this@allprojects, "org.thepalaceproject.build.androidSDKTarget")
minSdk =
propertyInt(this@allprojects, "org.thepalaceproject.build.androidSDKMinimum")
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
/*
* Produce JDK bytecode of the correct version.
*/
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions.jvmTarget = jdkBytecodeTarget.toString()
}
java.sourceCompatibility = JavaVersion.toVersion(jdkBytecodeTarget)
java.targetCompatibility = JavaVersion.toVersion(jdkBytecodeTarget)
android.compileOptions {
encoding = "UTF-8"
sourceCompatibility = JavaVersion.toVersion(jdkBytecodeTarget)
targetCompatibility = JavaVersion.toVersion(jdkBytecodeTarget)
isCoreLibraryDesugaringEnabled = true
}
}
"aar" -> {
logger.info("Configuring ${this.project} $version as an aar project")
apply(plugin = "com.android.library")
apply(plugin = "org.jetbrains.kotlin.android")
apply(plugin = "de.mannodermaus.android-junit5")
/*
* Configure the JVM toolchain version that we want to use for Kotlin.
*/
val kotlin: KotlinAndroidProjectExtension =
this.extensions["kotlin"] as KotlinAndroidProjectExtension
val java: JavaPluginExtension =
this.extensions["java"] as JavaPluginExtension
kotlin.jvmToolchain(jdkBuild)
java.toolchain.languageVersion.set(JavaLanguageVersion.of(jdkBuild))
/*
* Configure the various required Android properties.
*/
val android: LibraryExtension =
this.extensions["android"] as LibraryExtension
android.namespace =
property(this, "POM_ARTIFACT_ID")
android.compileSdk =
propertyInt(this, "org.thepalaceproject.build.androidSDKCompile")
android.defaultConfig {
multiDexEnabled = true
minSdk =
propertyInt(this@allprojects, "org.thepalaceproject.build.androidSDKMinimum")
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
/*
* Produce JDK bytecode of the correct version.
*/
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions.jvmTarget = jdkBytecodeTarget.toString()
}
java.sourceCompatibility = JavaVersion.toVersion(jdkBytecodeTarget)
java.targetCompatibility = JavaVersion.toVersion(jdkBytecodeTarget)
android.compileOptions {
encoding = "UTF-8"
sourceCompatibility = JavaVersion.toVersion(jdkBytecodeTarget)
targetCompatibility = JavaVersion.toVersion(jdkBytecodeTarget)
isCoreLibraryDesugaringEnabled = true
}
android.testOptions {
execution = "ANDROIDX_TEST_ORCHESTRATOR"
animationsDisabled = true
/*
* Enable the production of reports for all unit tests.
*/
unitTests {
isIncludeAndroidResources = true
all { test ->
// Required for the Mockito ByteBuddy agent on modern VMs.
test.systemProperty("jdk.attach.allowAttachSelf", "true")
test.reports.html.required = true
test.reports.junitXml.required = true
}
}
}
/*
* Configure semantic versioning analysis.
*/
afterEvaluate {
val enableSemanticVersionChecks =
propertyBoolean(this, "org.thepalaceproject.build.checkSemanticVersioning")
if (enableSemanticVersionChecks) {
val verifyActual = createScandoAnalyzeTask(this)
verifyActual.dependsOn.add(scandoDownloadTask)
verifyActual.dependsOn.add("assembleDebug")
val verifyTask = project.task("verifySemanticVersioning")
verifyTask.dependsOn.add(verifyActual)
} else {
// Create a do-nothing task to keep interface compatibility.
project.task("verifySemanticVersioning")
}
}
}
"jar" -> {
logger.info("Configuring ${this.project} $version as a jar project")
apply(plugin = "java-library")
apply(plugin = "org.jetbrains.kotlin.jvm")
/*
* Configure the JVM toolchain versions that we want to use for Kotlin and Java.
*/
val kotlin: KotlinProjectExtension =
this.extensions["kotlin"] as KotlinProjectExtension
val java: JavaPluginExtension =
this.extensions["java"] as JavaPluginExtension
kotlin.jvmToolchain(jdkBuild)
java.toolchain.languageVersion.set(JavaLanguageVersion.of(jdkBuild))
/*
* Produce JDK bytecode of the correct version.
*/
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions.jvmTarget = jdkBytecodeTarget.toString()
}
java.sourceCompatibility = JavaVersion.toVersion(jdkBytecodeTarget)
java.targetCompatibility = JavaVersion.toVersion(jdkBytecodeTarget)
/*
* Configure JUnit tests.
*/
tasks.named<Test>("test") {
useJUnitPlatform()
// Required for the Mockito ByteBuddy agent on modern VMs.
systemProperty("jdk.attach.allowAttachSelf", "true")
testLogging {
events("passed")
}
this.reports.html.required = true
this.reports.junitXml.required = true
}
}
}
/*
* Configure publishing.
*/
when (extra["POM_PACKAGING"]) {
"jar", "aar" -> {
apply(plugin = "maven-publish")
afterEvaluate {
configurePublishingFor(this.project)
}
}
}
/*
* Configure some aggressive version resolution behaviour. The listed configurations have
* transitive dependency resolution enabled; all other configurations do not. This forces
* projects to be extremely explicit about what is imported.
*/
val transitiveConfigurations = setOf(
"androidTestDebugImplementation",
"androidTestDebugImplementationDependenciesMetadata",
"androidTestImplementation",
"androidTestImplementationDependenciesMetadata",
"androidTestReleaseImplementation",
"androidTestReleaseImplementationDependenciesMetadata",
"annotationProcessor",
"coreLibraryDesugaring",
"debugAndroidTestCompilationImplementation",
"debugAndroidTestImplementation",
"debugAndroidTestImplementationDependenciesMetadata",
"debugAnnotationProcessor",
"debugAnnotationProcessorClasspath",
"debugUnitTestCompilationImplementation",
"debugUnitTestImplementation",
"debugUnitTestImplementationDependenciesMetadata",
"kotlinBuildToolsApiClasspath",
"kotlinCompilerClasspath",
"kotlinCompilerPluginClasspath",
"kotlinCompilerPluginClasspathDebug",
"kotlinCompilerPluginClasspathDebugAndroidTest",
"kotlinCompilerPluginClasspathDebugUnitTest",
"kotlinCompilerPluginClasspathMain",
"kotlinCompilerPluginClasspathRelease",
"kotlinCompilerPluginClasspathReleaseUnitTest",
"kotlinCompilerPluginClasspathTest",
"kotlinKlibCommonizerClasspath",
"kotlinNativeCompilerPluginClasspath",
"kotlinScriptDef",
"kotlinScriptDefExtensions",
"mainSourceElements",
"releaseAnnotationProcessor",
"releaseAnnotationProcessorClasspath",
"releaseUnitTestCompilationImplementation",
"releaseUnitTestImplementation",
"releaseUnitTestImplementationDependenciesMetadata",
"testDebugImplementation",
"testDebugImplementationDependenciesMetadata",
"testFixturesDebugImplementation",
"testFixturesDebugImplementationDependenciesMetadata",
"testFixturesImplementation",
"testFixturesImplementationDependenciesMetadata",
"testFixturesReleaseImplementation",
"testFixturesReleaseImplementationDependenciesMetadata",
"testImplementation",
"testImplementationDependenciesMetadata",
"testReleaseImplementation",
"testReleaseImplementationDependenciesMetadata",
)
/*
* Write the set of available configurations to files, for debugging purposes. Plugins can
* add new configurations at any time, and so it's nice to have a list of the available
* configurations visible.
*/
val configurationsActual = mutableSetOf<String>()
afterEvaluate {
configurations.all {
configurationsActual.add(this.name)
}
File("configurations.txt").writeText(configurationsActual.joinToString("\n"))
}
afterEvaluate {
configurations.all {
isTransitive = transitiveConfigurations.contains(name)
// resolutionStrategy.failOnVersionConflict()
}
}
/*
* Configure all "clean" tasks to depend upon the global Maven deployment directory cleaning
* task.
*/
afterEvaluate {
tasks.matching { task -> task.name == "clean" }
.forEach { task -> task.dependsOn(cleanTask) }
}
/*
* Configure all "test" tasks to be disabled. The tests are enabled only in those modules
* that specifically ask for them. Why do this? Because the Android plugins do lots of
* expensive per-module configuration for tests that don't exist.
*/
afterEvaluate {
tasks.matching { task -> task.name.contains("UnitTest") }
.forEach { task -> task.enabled = false }
}
}