-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathbuild.gradle.kts
158 lines (143 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
plugins {
alias(libs.plugins.dokka) apply false
alias(libs.plugins.kotlin.multiplatform) apply false
alias(libs.plugins.kotlin.jvm) apply false
alias(libs.plugins.spotless)
`maven-publish`
signing
}
repositories {
mavenCentral()
}
val dokkaId = libs.plugins.dokka.get().pluginId
val spotlessId = libs.plugins.spotless.get().pluginId
subprojects {
apply(plugin = "maven-publish")
apply(plugin = "signing")
apply(plugin = dokkaId)
apply(plugin = spotlessId)
signing {
setRequired { System.getenv("GPG_PRIVATE_KEY") != null }
useInMemoryPgpKeys(
System.getenv("GPG_PRIVATE_KEY"),
System.getenv("GPG_PASSPHRASE")
)
sign(publishing.publications)
}
spotless {
val exclude = listOf(
"**/.github/**",
"**/.gradle/**",
"**/.idea/**",
"**/.intellijPlatform/**",
"**/.kotlin/**",
"**/build/**",
"**/vscode/**",
"**/docs/**",
"**/playground/**",
"**/tmp/**",
"**/generated/**",
"**/resources/**",
"**/node_modules/**",
"**/*.lock",
"**/*Emitter.kt",
).toTypedArray()
format("misc") {
target("**/*.md")
targetExclude(*exclude)
endWithNewline()
}
format("wirespec") {
target("**/*.ws")
targetExclude(*exclude)
endWithNewline()
// nativeCmd("wirespec", "/usr/local/bin/wirespec", listOf("fmt", "-")) // name, path to binary, additional arguments
}
kotlin {
target("**/*.kt", "**/*.kts")
targetExclude(*exclude, "**/*Emitter.kt",)
ktlint().editorConfigOverride(
mapOf("ktlint_code_style" to "intellij_idea"),
)
suppressLintsFor {
step = "ktlint"
shortCode = "standard:enum-entry-name-case"
}
}
}
publishing {
publications {
repositories {
maven {
name = "oss"
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 (version.toString().endsWith("SNAPSHOT")) snapshotsRepoUrl else releasesRepoUrl
credentials {
username = System.getenv("SONATYPE_USERNAME")
password = System.getenv("SONATYPE_PASSWORD")
}
}
}
withType<MavenPublication> {
// Stub javadoc.jar artifact
artifact(tasks.register("${name}JavadocJar", Jar::class) {
archiveClassifier.set("javadoc")
archiveAppendix.set([email protected])
})
pom {
name.set("Wirespec")
description.set("Type safe wires made easy")
licenses {
license {
name.set("Apache-2.0")
url.set("https://opensource.org/license/apache-2-0")
}
}
url.set("https://flock.community")
issueManagement {
system.set("Github")
url.set("https://github.com/flock-community/wirespec/issues")
}
scm {
connection.set("https://github.com/flock-community/wirespec.git")
url.set("https://github.com/flock-community/wirespec")
}
developers {
developer {
name.set("Jerre van Veluw")
email.set("[email protected]")
}
developer {
name.set("Willem Veelenturf")
email.set("[email protected]")
}
}
}
}
}
}
// We're using kotlinx.io in tests as well. For (node)js test, test-resources aren't readily available.
// With this additional config of adding two copy tasks, and setting an explicit dependency on the
// test tasks ensures the test-resources are readily available within every sub-project
//
// https://github.com/Kotlin/kotlinx-io/issues/265
// https://gist.github.com/dellisd/a1df42787d42b41cd3ce16f573984674
afterEvaluate {
val copyTestResourcesForJs by tasks.registering(Copy::class) {
group = "nodejs"
description = "Copy js specific test-resources for nodejs test task (located at src/*Test/resources)"
logger.info("Copying test resources for ${project.path}")
val projectFullName = project.path.replace(Project.PATH_SEPARATOR, "-")
val buildDir = rootProject.layout.buildDirectory.get()
from("$projectDir/src")
include("*Test/resources/**/*")
into("$buildDir/js/packages/${rootProject.name}$projectFullName-test/src")
}
if (project.tasks.findByName("jsNodeTest") != null) {
project.tasks.named("jsNodeTest").configure {
dependsOn(copyTestResourcesForJs)
}
}
}
}