This repository has been archived by the owner on Mar 15, 2024. It is now read-only.
forked from commonmark/commonmark-java
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
167 lines (148 loc) · 4.33 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
// Copyright (c) 2020-2021 Yinsen (Tesla) Zhang.
// Use of this source code is governed by the MIT license that can be found in the LICENSE file.
import org.apache.tools.ant.taskdefs.condition.Os
plugins {
java
`java-library`
`maven-publish`
signing
}
allprojects {
group = "org.aya-prover"
version = "0.21.1"
}
@Suppress("unsupported")
subprojects {
apply {
plugin("java")
plugin("maven-publish")
plugin("java-library")
plugin("signing")
}
java {
withSourcesJar()
withJavadocJar()
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
toolchain {
languageVersion.set(JavaLanguageVersion.of(11))
}
}
sourceSets.test.configure {
java { this.srcDirs.clear() }
}
tasks.withType<JavaCompile>().configureEach {
modularity.inferModulePath.set(true)
options.apply {
encoding = "UTF-8"
isDeprecation = true
release.set(11)
compilerArgs.addAll(listOf("-Xlint:unchecked"))
}
}
tasks.withType<Javadoc>().configureEach {
val options = options as StandardJavadocDocletOptions
options.modulePath = tasks.compileJava.get().classpath.toList()
options.addStringOption("source", "11")
options.addStringOption("Xdoclint:none", "-quiet")
options.encoding("UTF-8")
options.tags(
"apiNote:a:API Note:",
"implSpec:a:Implementation Requirements:",
"implNote:a:Implementation Note:",
)
}
artifacts {
add("archives", tasks["sourcesJar"])
add("archives", tasks["javadocJar"])
}
tasks.withType<Test>().configureEach {
useJUnitPlatform()
enableAssertions = true
reports.junitXml.mergeReruns.set(true)
}
tasks.withType<JavaExec>().configureEach {
enableAssertions = true
}
if (hasProperty("ossrhUsername")) publishing.repositories {
maven("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2") {
name = "MavenCentral"
credentials {
username = property("ossrhUsername").toString()
password = property("ossrhPassword").toString()
}
}
}
val proj = this@subprojects
publishing.publications {
create<MavenPublication>("maven") {
val githubUrl = "https://github.com/aya-prover/commonmark-java"
groupId = proj.group.toString()
version = proj.version.toString()
artifactId = proj.name
from(components["java"])
pom {
description.set("Commonmark-java with JPMS support")
name.set(proj.name)
url.set("https://www.aya-prover.org")
licenses {
license {
name.set("BSD 2-Clause License")
url.set("$githubUrl/blob/master/LICENSE")
}
}
developers {
developer {
id.set("rstocker")
name.set("Robin Stocker")
email.set("rstocker@atlassian.com")
}
developer {
id.set("ice1000")
name.set("Tesla Zhang")
email.set("ice1000kotlin@foxmail.com")
}
}
scm {
connection.set("scm:git:$githubUrl")
url.set(githubUrl)
}
}
}
}
if (hasProperty("signing.keyId")) signing {
sign(publishing.publications["maven"])
}
}
val mergeJacocoReports = tasks.register<JacocoReport>("mergeJacocoReports") {
group = "verification"
subprojects.forEach { subproject ->
subproject.plugins.withType<JacocoPlugin>().configureEach {
subproject.tasks.matching { it.extensions.findByType<JacocoTaskExtension>() != null }.configureEach {
sourceSets(subproject.sourceSets.main.get())
executionData(this)
}
subproject.tasks.matching { it.extensions.findByType<JacocoTaskExtension>() != null }.forEach {
dependsOn(it)
}
}
}
reports { configureReports(true) }
doLast {
if (Os.isFamily(Os.FAMILY_WINDOWS) && System.getenv("CI") != "true") exec {
commandLine("explorer.exe", ".\\build\\reports\\jacoco\\mergeJacocoReports\\html\\index.html")
}
}
}
tasks.register("githubActions") {
group = "verification"
dependsOn(mergeJacocoReports, tasks.findByPath(":lsp:jlink"))
}
tasks.withType<Sync>().configureEach {
dependsOn(tasks.findByPath(":buildSrc:copyModuleInfo"))
}
fun JacocoReportsContainer.configureReports(merger: Boolean) {
xml.required.set(true)
csv.required.set(false)
html.required.set(merger)
}