-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
138 lines (117 loc) · 5.05 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
import org.jetbrains.dokka.gradle.DokkaTask
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
plugins {
// Kotlin
val kotlinVersion = "1.6.10"
kotlin("jvm") version kotlinVersion apply false
kotlin("multiplatform") version kotlinVersion apply false
kotlin("plugin.spring") version kotlinVersion apply false
kotlin("plugin.jpa") version kotlinVersion apply false
kotlin("plugin.serialization") version kotlinVersion apply false
id("org.jetbrains.dokka") version kotlinVersion
id("de.menkalian.vela.keygen") version "2.0.1" apply false
}
allprojects {
group = "de.menkalian.crater"
version = "1.2.0"
repositories {
mavenCentral()
}
// Configure multiplatform projects
pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform") {
extensions.getByType(KotlinMultiplatformExtension::class).apply {
jvm {
withJava()
}
js {
binaries.library()
useCommonJs()
browser()
nodejs()
}
val hostOs = System.getProperty("os.name")
logger.info("Configuring for build on $hostOs")
val isMingwX64 = hostOs.startsWith("Windows")
val nativeTarget = when {
hostOs == "Mac OS X" -> macosX64("native")
hostOs == "Linux" -> linuxX64("native")
isMingwX64 -> mingwX64("native")
else -> null
}
if (nativeTarget == null) {
logger.error("Native compilation on your OS is not supported.")
}
// Configure targets
nativeTarget?.apply {
binaries {
sharedLib()
}
}
sourceSets {
getByName("commonMain") {
dependencies {
api(kotlin("stdlib-common"))
implementation(kotlin("stdlib-common"))
api(kotlin("reflect"))
implementation(kotlin("reflect"))
// Include coroutines
api("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.0")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.0")
api("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.0")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.0")
// Include serialization if the plugin is there
pluginManager.withPlugin("org.jetbrains.kotlin.plugin.serialization") {
api("org.jetbrains.kotlinx:kotlinx-serialization-core:1.3.2")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-core:1.3.2")
api("org.jetbrains.kotlinx:kotlinx-serialization-json:1.3.2")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.3.2")
}
}
}
getByName("commonTest") {
dependencies {
implementation(kotlin("test"))
implementation(kotlin("test-common"))
implementation(kotlin("test-annotations-common"))
}
}
}
}
}
pluginManager.withPlugin("maven-publish") {
extensions.getByType(PublishingExtension::class.java).apply {
repositories {
maven {
url = uri("https://artifactory.menkalian.de/artifactory/crater")
name = "artifactory-menkalian"
credentials {
username = System.getenv("MAVEN_REPO_USER")
password = System.getenv("MAVEN_REPO_PASS")
}
}
}
}
}
pluginManager.withPlugin("org.jetbrains.dokka") {
val kotlinVersion = "1.6.10"
dependencies.add("dokkaHtmlPlugin", "org.jetbrains.dokka:kotlin-as-java-plugin:$kotlinVersion")
tasks.withType(DokkaTask::class.java).configureEach {
try {
dokkaSourceSets.named("main") {
sourceLink {
localDirectory.set(project.file("src/main/kotlin"))
remoteUrl.set(uri("https://github.com/menkalian/crater/blob/main/${projectDir.relativeTo(rootProject.projectDir)}/src/main/kotlin").toURL())
remoteLineSuffix.set("#L")
}
}
} catch (_: Exception) {
}
}
}
tasks.withType(AbstractCopyTask::class) {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
}
tasks.dokkaHtmlMultiModule.configure {
moduleName.set("Crater Source Documentation")
}