forked from JetBrains/markdown
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
234 lines (206 loc) · 6.47 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
222
223
224
225
226
227
228
229
230
231
232
233
234
import java.io.ByteArrayOutputStream
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.jetbrains.configureBintrayPublicationIfNecessary
import org.jetbrains.configureSonatypePublicationIfNecessary
import org.jetbrains.registerPublicationFromKotlinPlugin
import org.jetbrains.signPublicationsIfNecessary
plugins {
kotlin("multiplatform") version "1.5.0"
id("org.jetbrains.dokka") version "1.4.32"
`maven-publish`
signing
}
group = "org.jetbrains"
val baseVersion = project.property("version").toString()
version = if (project.property("snapshot")?.toString()?.toBoolean() != false) {
baseVersion.substringBefore("-").split('.').let { (major, minor, patch) ->
"$major.$minor.${patch.toInt() + 1}-SNAPSHOT"
}
} else {
baseVersion
}
repositories {
mavenCentral()
}
kotlin {
jvm {
compilations {
all {
kotlinOptions.jvmTarget = "1.6"
}
val main by getting
val test by getting
}
testRuns["test"].executionTask.configure {
useJUnit {
excludeCategories("org.intellij.markdown.ParserPerformanceTest")
}
}
}
js(BOTH) {
nodejs {}
}
linuxX64()
mingwX64()
macosX64()
ios()
sourceSets {
val commonMain by getting {
}
val commonTest by getting {
dependencies {
implementation(kotlin("test-common"))
implementation(kotlin("test-annotations-common"))
}
}
val fileBasedTest by creating {
dependsOn(commonTest)
}
val jvmMain by getting {
}
val jvmTest by getting {
dependsOn(fileBasedTest)
dependencies {
implementation(kotlin("test-junit"))
}
}
val jsMain by getting {
}
val jsTest by getting {
dependsOn(fileBasedTest)
dependencies {
implementation(kotlin("test-js"))
}
}
val nativeMain by creating {
dependsOn(commonMain)
}
val linuxX64Main by getting {
dependsOn(nativeMain)
}
val mingwX64Main by getting {
dependsOn(nativeMain)
}
val macosX64Main by getting {
dependsOn(nativeMain)
}
val iosMain by getting {
dependsOn(nativeMain)
}
val nativeTest by creating {
dependsOn(commonTest)
}
val linuxX64Test by getting {
dependsOn(nativeTest)
dependsOn(fileBasedTest)
}
val mingwX64Test by getting {
dependsOn(nativeTest)
dependsOn(fileBasedTest)
}
val macosX64Test by getting {
dependsOn(nativeTest)
dependsOn(fileBasedTest)
}
val iosTest by getting {
}
}
}
tasks {
register<Test>("performanceTest") {
val testCompilation = kotlin.jvm().compilations["test"]
group = "verification"
testClassesDirs = testCompilation.output.classesDirs
classpath = testCompilation.runtimeDependencyFiles
dependsOn("compileTestKotlinJvm")
useJUnit {
includeCategories("org.intellij.markdown.ParserPerformanceTest")
}
testLogging {
exceptionFormat = TestExceptionFormat.FULL
}
}
task("downloadCommonmark", type = Exec::class) {
group = "Code Generation"
description = "Clone the CommonMark repo locally"
onlyIf { !File("commonmark-spec").exists() }
executable("git")
args("clone", "https://github.com/commonmark/commonmark-spec")
}
task("downloadGfm", type = Exec::class) {
group = "Code Generation"
description = "Clone the GFM repo locally"
onlyIf { !File("cmark-gfm").exists() }
executable("git")
args("clone", "https://github.com/github/cmark-gfm")
}
task("generateCommonMarkTest", type = Exec::class) {
group = "Code Generation"
description = "Generate unit tests for the CommonMark spec"
dependsOn("downloadCommonmark")
executable("python")
workingDir("commonmark-spec")
args("test/spec_tests.py", "--dump-tests")
val output = ByteArrayOutputStream()
standardOutput = output
doLast {
val tests = String(output.toByteArray())
generateSpecTest(
tests,
"CommonMarkSpecTest",
"org.intellij.markdown.flavours.commonmark.CommonMarkFlavourDescriptor"
)
}
}
task("generateGfmTest", type = Exec::class) {
group = "Code Generation"
description = "Generate unit tests for the GFM spec"
dependsOn("downloadGfm")
executable("python")
workingDir("cmark-gfm/test")
args("spec_tests.py", "--dump-tests")
val output = ByteArrayOutputStream()
standardOutput = output
doLast {
val tests = String(output.toByteArray())
generateSpecTest(
tests,
"GfmSpecTest",
"org.intellij.markdown.flavours.gfm.GFMFlavourDescriptor"
)
}
}
task("generateAllTests") {
group = "Code Generation"
description = "Generate unit tests for the all markdown specs"
dependsOn("generateCommonMarkTest", "generateGfmTest")
}
}
val dokkaOutputDir = project.buildDir.resolve("dokkaHtml")
subprojects {
tasks.withType<org.jetbrains.dokka.gradle.DokkaTask> {
outputDirectory.set(dokkaOutputDir)
}
}
tasks.register<Jar>("javadocJar") {
dependsOn(":docs:dokkaHtml")
archiveClassifier.set("javadoc")
from(dokkaOutputDir)
}
val publicationsToArtifacts = mapOf(
"kotlinMultiplatform" to "markdown",
"jvm" to "markdown-jvm",
"js" to "markdown-js",
"linuxX64" to "markdown-linuxx64",
"mingwX64" to "markdown-mingwx64",
"macosX64" to "markdown-macosx64",
"iosX64" to "markdown-iosx64",
"iosArm64" to "markdown-iosarm64",
"metadata" to "markdown-metadata"
)
publicationsToArtifacts.forEach { publicationName, artifactId ->
registerPublicationFromKotlinPlugin(publicationName, artifactId)
}
signPublicationsIfNecessary(*publicationsToArtifacts.keys.toTypedArray())
configureSonatypePublicationIfNecessary()
configureBintrayPublicationIfNecessary()