generated from EraTiem-Network/Kotlin-Plugin-Template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
135 lines (111 loc) · 2.71 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
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import org.gradle.kotlin.dsl.support.uppercaseFirstChar
import java.lang.System.getProperty
import java.net.URI
group = "net.eratiem"
version = libs.versions.kotlin.get()
plugins {
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.kotlin.kapt) apply false
alias(libs.plugins.shadow) apply false
idea
`maven-publish`
}
// ###############
// # Subprojects #
// ###############
subprojects {
group = rootProject.group
version = rootProject.version
apply {
plugin(rootProject.libs.plugins.kotlin.jvm.get().pluginId)
plugin(rootProject.libs.plugins.shadow.get().pluginId)
plugin("maven-publish")
}
tasks {
named<ShadowJar>("shadowJar") {
archiveBaseName = rootProject.name
archiveClassifier = [email protected] { it != "util" } ?: ""
}
}
}
// ##############
// # Publishing #
// ##############
publishing {
repositories {
val repoNames = System.getProperties().filterKeys { (it as String).startsWith("project.publish", true) }
.map { (it.key as String).removePrefix("project.publish.").substringBefore(".") }.toSet()
repoNames.forEach {
maven {
name = it.uppercaseFirstChar()
url = uri(getProperty("project.publish.$it.url"))
getProperty("project.publish.$it.auth-type")?.let { authType ->
when (authType) {
else -> {
credentials {
username = "${properties["project.publish.$it.username"]}"
password = "${properties["project.publish.$it.access-token"]}"
}
}
}
}
}
}
}
}
// ################
// # All Projects #
// ################
allprojects {
apply {
plugin("org.gradle.idea")
}
repositories {
maven {
name = "Bit-Build | Artifactory"
url = URI("https://artifactory.bit-build.de/artifactory/public")
}
}
tasks {
idea {
module {
isDownloadSources = true
isDownloadJavadoc = true
}
}
jar {
enabled = false
}
}
kotlin {
jvmToolchain(21)
}
}
// ###############
// # Source-Sets #
// ###############
sourceSets {
main {
java.setSrcDirs(listOf<String>())
kotlin.setSrcDirs(emptyList<String>())
resources.setSrcDirs(emptyList<String>())
}
test {
java.setSrcDirs(listOf<String>())
kotlin.setSrcDirs(emptyList<String>())
resources.setSrcDirs(emptyList<String>())
}
}
fun <T> getPropertyOrNull(key: String, castFun: String.() -> T) = try {
getProperty(key).castFun()
} catch (ex: Exception) {
println(ex)
null
}
fun <T> T.applyIf(condition: Boolean, block: T.() -> Unit) =
if (condition) {
apply { block() }
} else {
this
}