forked from gradle/gradle
/
build.gradle.kts
86 lines (71 loc) · 3.23 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
import gradlebuild.basics.FlakyTestStrategy
import gradlebuild.basics.PublicApi
import gradlebuild.basics.PublicKotlinDslApi
import gradlebuild.basics.flakyTestStrategy
plugins {
id("gradlebuild.internal.java")
id("gradlebuild.binary-compatibility")
}
description = """Verifies that Gradle code complies with architectural rules.
| For example that nullable annotations are used consistently or that or that public api classes do not extend internal types.
""".trimMargin()
dependencies {
currentClasspath(project(":distributions-full"))
testImplementation(project(":base-services"))
testImplementation(project(":model-core"))
testImplementation(project(":file-temp"))
testImplementation(project(":core"))
testImplementation(libs.futureKotlin("stdlib"))
testImplementation(libs.inject)
testImplementation(libs.archunitJunit5)
testImplementation(libs.guava)
testImplementation("org.junit.jupiter:junit-jupiter")
testImplementation(libs.assertj)
testRuntimeOnly(project(":distributions-full"))
}
val acceptedApiChangesFile = layout.projectDirectory.file("src/changes/accepted-public-api-changes.json")
val verifyAcceptedApiChangesOrdering = tasks.register<gradlebuild.binarycompatibility.AlphabeticalAcceptedApiChangesTask>("verifyAcceptedApiChangesOrdering") {
group = "verification"
description = "Ensures the accepted api changes file is kept alphabetically ordered to make merging changes to it easier"
apiChangesFile.set(acceptedApiChangesFile)
}
val sortAcceptedApiChanges = tasks.register<gradlebuild.binarycompatibility.SortAcceptedApiChangesTask>("sortAcceptedApiChanges") {
group = "verification"
description = "Sort the accepted api changes file alphabetically"
apiChangesFile.set(acceptedApiChangesFile)
}
tasks.test {
// Looks like loading all the classes requires more than the default 512M
maxHeapSize = "900M"
// Only use one fork, so freezing doesn't have concurrency issues
maxParallelForks = 1
systemProperty("org.gradle.public.api.includes", (PublicApi.includes + PublicKotlinDslApi.includes).joinToString(":"))
systemProperty("org.gradle.public.api.excludes", (PublicApi.excludes + PublicKotlinDslApi.excludes).joinToString(":"))
jvmArgumentProviders.add(ArchUnitFreezeConfiguration(
project.file("src/changes/archunit_store"),
providers.gradleProperty("archunitRefreeze").map { true })
)
dependsOn(verifyAcceptedApiChangesOrdering)
enabled = flakyTestStrategy != FlakyTestStrategy.ONLY
predictiveSelection {
// PTS doesn't work well with architecture tests which scan all classes
enabled.set(false)
}
}
class ArchUnitFreezeConfiguration(
@get:InputDirectory
@get:PathSensitive(PathSensitivity.RELATIVE)
val location: File,
@get:Optional
@get:Input
val refreeze: Provider<Boolean>
) : CommandLineArgumentProvider {
override fun asArguments(): Iterable<String> {
val refreezeBoolean = refreeze.getOrElse(false)
return listOf(
"-Darchunit.freeze.store.default.path=${location.absolutePath}",
"-Darchunit.freeze.refreeze=${refreezeBoolean}",
"-Darchunit.freeze.store.default.allowStoreUpdate=${refreezeBoolean}"
)
}
}