-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle.kts
199 lines (176 loc) · 6.14 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
import org.jetbrains.dokka.Platform
import java.net.URL
group = "org.patternfly"
version = "0.3.0-SNAPSHOT"
object Meta {
const val desc = "Kotlin MVP implementation based on fritz2"
const val license = "Apache-2.0"
const val githubRepo = "patternfly-kotlin/mvp"
const val release = "https://s01.oss.sonatype.org/service/local/"
const val snapshot = "https://s01.oss.sonatype.org/content/repositories/snapshots/"
}
// ------------------------------------------------------ plugins
// https://youtrack.jetbrains.com/issue/KTIJ-19369#focus=Comments-27-5181027.0-0
@Suppress("DSL_SCOPE_VIOLATION", "UnstableApiUsage")
plugins {
alias(libs.plugins.js)
alias(libs.plugins.dokka)
alias(libs.plugins.ktlint)
alias(libs.plugins.ktlintIdea)
alias(libs.plugins.detekt)
alias(libs.plugins.nexusPublish)
`maven-publish`
signing
}
// ------------------------------------------------------ repositories
val repositories = arrayOf(
"https://oss.sonatype.org/content/repositories/snapshots/",
"https://s01.oss.sonatype.org/content/repositories/snapshots/"
)
repositories {
mavenLocal()
mavenCentral()
repositories.forEach { maven(it) }
}
// ------------------------------------------------------ dependencies
dependencies {
implementation(libs.fritz2.core)
testImplementation(libs.kotlin.test)
testImplementation(kotlin("test-js"))
}
// ------------------------------------------------------ kotlin/js
kotlin {
js(IR) {
explicitApi()
browser {
testTask {
useKarma {
useChromeHeadless()
}
}
}
}
}
// ------------------------------------------------------ source & javadoc
val sourcesJar by tasks.registering(Jar::class) {
archiveClassifier.set("sources")
from(kotlin.sourceSets.main.get().kotlin)
}
val javadocJar by tasks.creating(Jar::class) {
group = JavaBasePlugin.DOCUMENTATION_GROUP
description = "Assembles Javadoc JAR"
archiveClassifier.set("javadoc")
from(tasks.named("dokkaHtml"))
}
// ------------------------------------------------------ ktlint, detekt & dokka
tasks {
ktlint {
filter {
exclude("**/org/patternfly/mvp/sample/**")
}
}
detekt.configure {
exclude("**/org/patternfly/mvp/sample/**")
}
dokkaHtml.configure {
dokkaSourceSets {
named("main") {
includeNonPublic.set(false)
noJdkLink.set(false)
noStdlibLink.set(false)
platform.set(Platform.js)
skipEmptyPackages.set(true)
samples.from("src/main/kotlin/")
pluginsMapConfiguration.set(
mapOf("org.jetbrains.dokka.base.DokkaBase" to """{ "separateInheritedMembers": true}""")
)
sourceLink {
localDirectory.set(file("src/main/kotlin"))
remoteUrl.set(
URL("https://github.com/${Meta.githubRepo}/blob/main/src/main/kotlin/")
)
remoteLineSuffix.set("#L")
}
externalDocumentationLink {
url.set(URL("https://kotlin.github.io/kotlinx.coroutines/"))
}
perPackageOption {
matchingRegex.set("org\\.patternfly\\.mvp\\.sample")
suppress.set(true)
}
}
}
}
}
// ------------------------------------------------------ sign & publish
signing {
val signingKey = providers
.environmentVariable("GPG_SIGNING_KEY")
.forUseAtConfigurationTime()
val signingPassphrase = providers
.environmentVariable("GPG_SIGNING_PASSPHRASE")
.forUseAtConfigurationTime()
if (signingKey.isPresent && signingPassphrase.isPresent) {
useInMemoryPgpKeys(signingKey.get(), signingPassphrase.get())
val extension = extensions
.getByName("publishing") as PublishingExtension
sign(extension.publications)
}
}
publishing {
publications {
create<MavenPublication>("maven") {
groupId = project.group.toString()
artifactId = project.name
version = project.version.toString()
from(components["kotlin"])
artifact(tasks["sourcesJar"])
artifact(tasks["javadocJar"])
pom {
name.set(project.name)
description.set(Meta.desc)
url.set("https://github.com/${Meta.githubRepo}")
licenses {
license {
name.set(Meta.license)
url.set("https://opensource.org/licenses/Apache-2.0")
}
}
developers {
developer {
id.set("hpehl")
name.set("Harald Pehl")
organization.set("Red Hat")
organizationUrl.set("https://developers.redhat.com/")
}
}
scm {
url.set("https://github.com/${Meta.githubRepo}.git")
connection.set("scm:git:git://github.com/${Meta.githubRepo}.git")
developerConnection.set("scm:git:git://github.com/#${Meta.githubRepo}.git")
}
issueManagement {
url.set("https://github.com/${Meta.githubRepo}/issues")
}
}
}
}
}
nexusPublishing {
repositories {
sonatype {
nexusUrl.set(uri(Meta.release))
snapshotRepositoryUrl.set(uri(Meta.snapshot))
val ossrhUsername = providers
.environmentVariable("OSSRH_USERNAME")
.forUseAtConfigurationTime()
val ossrhPassword = providers
.environmentVariable("OSSRH_PASSWORD")
.forUseAtConfigurationTime()
if (ossrhUsername.isPresent && ossrhPassword.isPresent) {
username.set(ossrhUsername.get())
password.set(ossrhPassword.get())
}
}
}
}