-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuild.gradle.kts
186 lines (162 loc) · 5.5 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
import org.gradle.api.tasks.testing.logging.TestLogEvent
import org.jetbrains.dokka.Platform
import org.jetbrains.dokka.gradle.AbstractDokkaLeafTask
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.openstreetmap.josm.gradle.plugin.GitDescriber
import org.openstreetmap.josm.gradle.plugin.api.gitlab.setupGitlabPublishing
import org.openstreetmap.josm.gradle.plugin.logCoverage
import org.openstreetmap.josm.gradle.plugin.logPublishedMavenArtifacts
import org.openstreetmap.josm.gradle.plugin.logSkippedTasks
import org.openstreetmap.josm.gradle.plugin.logTaskDuration
import java.net.URL
typealias IKotlinCompile<T> = org.jetbrains.kotlin.gradle.dsl.KotlinCompile<T>
plugins {
id("org.jetbrains.dokka")
jacoco
}
gradle.projectsEvaluated {
allprojects {
extensions.findByType(JacocoPluginExtension::class)?.toolVersion = Versions.jacoco
}
val jacocoTestReport by tasks.registering(JacocoReport::class) {
group = "Verification"
setOf(
project(":common").tasks.getByName<Test>("jvmTest"),
project(":i18n").tasks.getByName<Test>("jvmTest"),
project(":plugin").tasks.getByName<Test>("test")
).forEach {
executionData(it)
dependsOn(it)
}
setOf(":common", ":i18n").map { project(it) }.let { mppProjects ->
mppProjects.forEach { mppProject ->
sourceDirectories.from(
mppProject.extensions.getByType(KotlinMultiplatformExtension::class).sourceSets
.filter { it.name.endsWith("Main") }
.map { it.kotlin.sourceDirectories }
)
}
mppProjects.forEach { classDirectories.from(it.layout.buildDirectory.dir("classes/kotlin/jvm")) }
}
sourceSets(*
subprojects
.mapNotNull { it.extensions.getByType(SourceSetContainer::class).findByName(SourceSet.MAIN_SOURCE_SET_NAME) }
.toTypedArray()
)
}
val build by tasks.getting {
dependsOn(tasks.dokkaHtmlMultiModule)
}
val check by tasks.getting {
dependsOn(jacocoTestReport)
}
}
val javaVersion = JavaVersion.VERSION_1_8
// Logging
gradle.taskGraph.logPublishedMavenArtifacts()
gradle.taskGraph.logTaskDuration()
logSkippedTasks()
allprojects {
group = "org.openstreetmap.josm" + if (name != "plugin") ".gradle-josm-plugin" else ""
version = GitDescriber(rootProject.projectDir).describe()
repositories.mavenCentral()
tasks.withType(JacocoReport::class).all {
tasks.findByName("test")?.let { dependsOn(it) }
logCoverage()
}
tasks.withType(Zip::class).all {
// make the produces archives (more) reproducible
isReproducibleFileOrder = true
isPreserveFileTimestamps = false
}
}
subprojects {
tasks.withType(Test::class).all {
useJUnitPlatform()
testLogging {
lifecycle {
events = setOf(TestLogEvent.FAILED, TestLogEvent.PASSED, TestLogEvent.STANDARD_ERROR)
}
}
}
tasks.withType(IKotlinCompile::class).all {
if (this is KotlinCompile) {
kotlinOptions.jvmTarget = javaVersion.toString()
}
kotlinOptions {
freeCompilerArgs = freeCompilerArgs + "-Xopt-in=kotlin.RequiresOptIn"
}
}
tasks.withType(AbstractDokkaLeafTask::class) {
dokkaSourceSets.all {
if (platform.get() == Platform.jvm) {
jdkVersion.set(javaVersion.ordinal + 1)
externalDocumentationLink(URL("https://docs.gradle.org/${gradle.gradleVersion}/javadoc/"))
externalDocumentationLink(URL("http://docs.groovy-lang.org/next/html/api/"))
}
project.projectDir.resolve("packages.md")
.takeIf { it.isFile }
?.let { packagesFile ->
includes.from(packagesFile)
}
file("src/${[email protected]}/kotlin").takeIf { it.exists() }?.let { localSrcDir ->
sourceLink {
remoteUrl.set(URL("https://gitlab.com/JOSM/gradle-josm-plugin/-/tree/v${project.version}/${project.name}/src/${[email protected]}/kotlin"))
localDirectory.set(localSrcDir)
remoteLineSuffix.set("#L")
}
}
}
}
pluginManager.withPlugin("java") {
extensions.findByType(JavaPluginExtension::class)?.apply {
sourceCompatibility = javaVersion
withSourcesJar()
}
}
configureIfMultiplatform { multiplatformExtension ->
multiplatformExtension.configureMultiplatformDefaults()
configureIfJacoco {
tasks.register("jacocoTestReport", JacocoReport::class).configure {
group = "Verification"
dependsOn(tasks.getByName("jvmTest"))
classDirectories.from(layout.buildDirectory.dir("classes/kotlin/jvm"))
sourceDirectories.from(
multiplatformExtension.sourceSets
.filter { it.name.endsWith("Main") }
.map { it.kotlin.sourceDirectories }
)
executionData(tasks.getByName("jvmTest"))
reports {
html.required.set(true)
}
}
}
}
val javadocJar by project.tasks.registering(Jar::class) {
group = "Documentation"
from(project.provider { tasks.named("dokkaHtml") })
archiveClassifier.set("javadoc")
}
configureIfMavenPublishing {
it.publications {
withType(MavenPublication::class) {
artifact(javadocJar.flatMap { it.archiveFile }) {
classifier = "javadoc"
}
}
}
}
}
tasks.dokkaHtmlMultiModule {
outputDirectory.set(buildDir.resolve("docs/kdoc"))
}
allprojects {
setupBuildDirPublishing()
setupAwsPublishing()
setupMavenArtifactSigning()
setupGitlabPublishing("gitlab")
setupOssSonatypeStagingPublishing()
addMavenPomContent(gradleJosmPluginMetadata())
}