forked from aya-prover/aya-dev
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
221 lines (193 loc) · 6.21 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
// Copyright (c) 2020-2022 Tesla (Yinsen) Zhang.
// Use of this source code is governed by the MIT license that can be found in the LICENSE.md file.
import org.apache.tools.ant.taskdefs.condition.Os
import org.aya.gradle.BuildUtil
import java.util.*
plugins {
java
`jacoco-report-aggregation`
idea
`java-library`
`maven-publish`
signing
id("org.beryx.jlink") version "2.25.0" apply false
}
var deps: Properties by rootProject.ext
deps = Properties()
file("gradle/deps.properties").reader().use(deps::load)
allprojects {
group = "org.aya-prover"
version = deps.getProperty("version.project")
}
@Suppress("unsupported")
val useJacoco = ["base", "pretty", "cli"]
/** gradle.properties or environmental variables */
fun propOrEnv(name: String): String =
if (hasProperty(name)) property(name).toString()
else (System.getenv(name) ?: "")
subprojects {
val proj = this@subprojects
val isSnapshot = proj.version.toString().endsWith("SNAPSHOT")
val isRelease = !isSnapshot
apply {
plugin("java")
plugin("idea")
if (name in useJacoco) plugin("jacoco")
plugin("maven-publish")
plugin("java-library")
plugin("signing")
}
val javaVersion = 19
java {
withSourcesJar()
if (isRelease) withJavadocJar()
JavaVersion.toVersion(javaVersion).let {
sourceCompatibility = it
targetCompatibility = it
}
toolchain {
languageVersion.set(JavaLanguageVersion.of(javaVersion))
}
}
if (name in useJacoco) jacoco {
toolVersion = deps.getProperty("version.jacoco")
}
idea.module {
outputDir = file("out/production")
testOutputDir = file("out/test")
}
tasks.withType<JavaCompile>().configureEach {
modularity.inferModulePath.set(true)
options.apply {
encoding = "UTF-8"
isDeprecation = true
release.set(javaVersion)
compilerArgs.addAll(listOf("-Xlint:unchecked", "--enable-preview"))
}
doLast {
val root = destinationDirectory.asFile.get()
// skip for test sources
if (root.endsWith("test")) return@doLast
val tree = fileTree(root)
tree.include("**/*.class")
tree.include("module-info.class")
tree.forEach {
BuildUtil.stripPreview(
root.toPath(), it.toPath(),
true, false,
"java/lang/RuntimeException",
)
}
}
}
tasks.withType<Javadoc>().configureEach {
val options = options as StandardJavadocDocletOptions
options.modulePath = tasks.compileJava.get().classpath.toList()
options.addBooleanOption("-enable-preview", true)
options.addStringOption("-source", javaVersion.toString())
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.named("sourcesJar"))
if (isRelease) add("archives", tasks.named("javadocJar"))
}
if (name in useJacoco) tasks.jacocoTestReport {
dependsOn(tasks.test)
reports {
xml.required.set(true)
csv.required.set(false)
html.required.set(false)
}
}
tasks.withType<Test>().configureEach {
jvmArgs = listOf("--enable-preview")
useJUnitPlatform()
enableAssertions = true
reports.junitXml.mergeReruns.set(true)
}
tasks.withType<JavaExec>().configureEach {
jvmArgs = listOf("--enable-preview")
enableAssertions = true
}
val ossrhUsername = propOrEnv("ossrhUsername")
val ossrhPassword = propOrEnv("ossrhPassword")
if (ossrhUsername.isNotEmpty()) publishing.repositories {
maven {
val releasesRepoUrl = uri("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2")
val snapshotsRepoUrl = uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")
url = if (isRelease) releasesRepoUrl else snapshotsRepoUrl
name = "MavenCentral"
credentials {
username = ossrhUsername
password = ossrhPassword
}
}
}
// Gradle module metadata contains Gradle JVM version, disable it
tasks.withType<GenerateModuleMetadata>().configureEach {
enabled = false
}
publishing.publications {
create<MavenPublication>("maven") {
val githubUrl = "https://github.com/aya-prover/aya-dev"
groupId = proj.group.toString()
version = proj.version.toString()
artifactId = proj.name
from(components["java"])
pom {
description.set("The Aya proof assistant")
name.set(proj.name)
url.set("https://www.aya-prover.org")
licenses {
license {
name.set("MIT")
url.set("$githubUrl/blob/master/LICENSE")
}
}
developers {
fun dev(i: String, n: String, u: String) = developer {
id.set(i)
name.set(n)
email.set(u)
}
dev("ice1000", "Tesla (Yinsen) Zhang", "ice1000kotlin@foxmail.com")
dev("imkiva", "Kiva Oyama", "imkiva@islovely.icu")
dev("re-xyr", "Xy Ren", "xy.r@outlook.com")
dev("dark-flames", "Darkflames", "dark_flames@outlook.com")
dev("tsao-chi", "tsao-chi", "tsao-chi@the-lingo.org")
dev("lunalunaa", "Luna Xin", "luna.xin@outlook.com")
dev("wsx", "Shuxian Wang", "wsx@berkeley.edu")
dev("HoshinoTented", "Hoshino Tented", "limbolrain@gmail.com")
}
scm {
connection.set("scm:git:$githubUrl")
url.set(githubUrl)
}
}
}
}
if (hasProperty("signing.keyId") && isRelease) signing {
if (!hasProperty("signing.useBuiltinGpg")) useGpgCmd()
sign(publishing.publications["maven"])
}
}
apply { plugin("jacoco-report-aggregation") }
dependencies { useJacoco.forEach { jacocoAggregation(project(":$it")) { isTransitive = false } } }
val ccr = tasks["testCodeCoverageReport"]
tasks.register("githubActions") {
group = "verification"
dependsOn(ccr, tasks.findByPath(":lsp:jlink"))
}
if (Os.isFamily(Os.FAMILY_WINDOWS)) tasks.register("showCCR") {
dependsOn(ccr)
doLast { exec { commandLine("cmd", "/c", "explorer", "build\\reports\\jacoco\\testCodeCoverageReport\\html\\index.html") } }
}
tasks.withType<Sync>().configureEach {
dependsOn(tasks.findByPath(":buildSrc:copyModuleInfo"))
}