-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.gradle.kts
191 lines (162 loc) · 5.65 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
import org.jetbrains.dokka.base.DokkaBase
import org.jetbrains.dokka.base.DokkaBaseConfiguration
import org.jetbrains.dokka.gradle.AbstractDokkaTask
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
import java.time.Year
plugins {
`java-library`
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.licenser)
alias(libs.plugins.kotlinter)
alias(libs.plugins.kotlin.abi)
// alias(libs.plugins.git.hooks)
alias(libs.plugins.dokka)
`maven-publish`
}
buildscript {
dependencies {
classpath(libs.dokka.base)
}
}
group = "org.polyfrost"
version = properties["version"] as String
val targetKotlinVersion = KotlinVersion.fromVersion(properties["kotlin.target"] as? String ?: "1.9")
val jvmToolchainVersion = (properties["jvm.toolchain"] as? String ?: "8").toInt()
allprojects {
apply(plugin = "java-library")
apply(plugin = rootProject.libs.plugins.kotlin.jvm.get().pluginId)
apply(plugin = rootProject.libs.plugins.licenser.get().pluginId)
apply(plugin = rootProject.libs.plugins.kotlinter.get().pluginId)
apply(plugin = rootProject.libs.plugins.dokka.get().pluginId)
apply(plugin = "maven-publish")
group = rootProject.group
version = rootProject.version
repositories {
mavenCentral()
maven("https://repo.polyfrost.org/releases")
}
dependencies {
implementation(rootProject.libs.bundles.kotlin)
implementation(rootProject.libs.logging.api)
testRuntimeOnly(rootProject.libs.logging.impl)
}
java.withSourcesJar()
kotlin {
compilerOptions {
languageVersion = targetKotlinVersion
apiVersion = targetKotlinVersion
optIn.add("kotlin.experimental.ExperimentalTypeInference")
freeCompilerArgs = listOf(
"-Xcontext-receivers",
"-Xjvm-default=all-compatibility",
"-Xno-call-assertions",
"-Xno-receiver-assertions",
"-Xno-param-assertions",
)
}
jvmToolchain(jvmToolchainVersion)
}
kotlinter {
ignoreFailures = false
reporters = arrayOf("checkstyle", "plain")
}
license {
rule("${rootProject.projectDir}/HEADER")
include("**/*.kt")
}
tasks {
withType<AbstractDokkaTask> {
pluginConfiguration<DokkaBase, DokkaBaseConfiguration> {
val rootPath = "${rootProject.projectDir.absolutePath}/format/dokka"
customStyleSheets = file("$rootPath/styles").listFiles()?.toList() ?: throw IllegalStateException("Please add git submodule https://github.com/Polyfrost/BuildFormat to /format")
customAssets = file("$rootPath/assets").listFiles()!!.toList()
templatesDir = file("$rootPath/templates")
footerMessage = "© ${Year.now().value} PolyUI"
}
doLast {
val scriptsOut = outputDirectory.get().asFile.resolve("scripts")
val scriptsIn = file("${rootProject.projectDir}/format/dokka/scripts")
if (project != rootProject) return@doLast
scriptsIn.listFiles()!!.forEach {
it.copyTo(scriptsOut.resolve(it.name), overwrite = true)
}
}
}
build {
dependsOn("format")
}
register("format") {
group = "formatting"
description = "Formats source code according to project style"
dependsOn(applyLicenses, formatKotlin)
}
create("dokkaJavadocJar", Jar::class.java) {
group = "documentation"
archiveClassifier = "javadoc"
from(dokkaJavadoc)
}
create("dokkaHtmlJar", Jar::class.java) {
group = "documentation"
archiveBaseName = rootProject.name
archiveClassifier = "dokka"
from(dokkaHtml.get().outputDirectory)
duplicatesStrategy = DuplicatesStrategy.FAIL
}
}
}
apiValidation {
ignoredProjects += rootProject.subprojects.map { it.name }
}
subprojects {
dependencies {
api(project.rootProject)
}
tasks.jar {
archiveBaseName = "${rootProject.name}-${project.name}"
}
tasks.named<Jar>("dokkaJavadocJar") {
archiveBaseName = "${rootProject.name}-${project.name}"
}
}
publishing {
publications {
create<MavenPublication>("Maven") {
artifactId = project.name
version = rootProject.version.toString()
artifact(tasks.jar.get().archiveFile)
artifact(tasks.getByName<Jar>("sourcesJar").archiveFile) {
this.classifier = "sources"
}
artifact(tasks.getByName<Jar>("dokkaJavadocJar").archiveFile) {
builtBy(tasks.getByName("dokkaJavadocJar"))
this.classifier = "javadoc"
}
val dokka = rootProject.tasks.getByName<Jar>("dokkaHtmlJar")
artifact(dokka.archiveFile) {
builtBy(dokka)
classifier = "dokka"
}
}
}
repositories {
mavenLocal()
maven {
url = uri("https://repo.polyfrost.org/releases")
name = "releases"
credentials(PasswordCredentials::class)
}
maven {
url = uri("https://repo.polyfrost.org/snapshots")
name = "snapshots"
credentials(PasswordCredentials::class)
}
maven {
url = uri("https://repo.polyfrost.org/private")
name = "private"
credentials(PasswordCredentials::class)
}
}
}
//gitHooks {
// setHooks(mapOf("pre-commit" to "format"))
//}