-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
133 lines (112 loc) · 3.74 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
import org.gradle.api.publish.maven.MavenPom
group = "dev.tsune"
version = "0.1.0"
plugins {
// Apply the Kotlin JVM plugin to add support for Kotlin.
id("org.jetbrains.kotlin.jvm") version "2.1.0"
// Apply plugin for document generation
id("org.jetbrains.dokka") version "2.0.0"
// Apply the java-library plugin for API and implementation separation.
id("java-library")
// Apply library publish plugin
id("maven-publish")
}
repositories {
// Use mavenCentral for resolving dependencies.
// You can declare any Maven/Ivy/file repository here.
mavenCentral()
}
dependencies {
// Align versions of all Kotlin components
implementation(platform("org.jetbrains.kotlin:kotlin-bom"))
// Use the Kotlin test library.
testImplementation("org.jetbrains.kotlin:kotlin-test")
// Use the Kotlin JUnit integration.
testImplementation("org.jetbrains.kotlin:kotlin-test-junit")
}
kotlin {
explicitApiWarning()
}
//sources
val sourcesJar by tasks.creating(Jar::class) {
from(sourceSets.main.get().allSource)
archiveClassifier.set("sources")
}
tasks.dokkaHtml.configure {
doLast {
val outputDir = outputDirectory.get().asFile.absolutePath
File("$outputDir/index.html").apply {
writeText("""
<html><script>document.location = "./${project.name.map {
if (it.isUpperCase()) "-" + it.lowercaseChar()
else it
}.joinToString(separator = "")}"</script></html>
""".trimIndent()
)
}
}
}
// Create dokka Jar task from dokka task output
val dokkaJar by tasks.creating(Jar::class) {
group = JavaBasePlugin.DOCUMENTATION_GROUP
description = "Assembles Kotlin docs with Dokka"
archiveClassifier.set("javadoc")
// dependsOn(tasks.dokka) not needed; dependency automatically inferred by from(tasks.dokka)
from(tasks.dokkaHtml)
}
publishing {
fun getProperty(propertyName: String, envName: String): String? {
return findProperty(propertyName) as? String ?: System.getenv(envName)
}
fun getBintrayUser(): String? {
return getProperty("bintray_user", "BINTRAY_USER")
}
fun getBintrayKey(): String? {
return getProperty("bintray_key", "BINTRAY_KEY")
}
fun MavenPom.initPom() {
name.set("ktPyString")
description.set("Python like String method in Kotlin")
url.set("https://github.com/ChanTsune/ktPyString")
licenses {
license {
name.set("MIT")
url.set("https://github.com/ChanTsune/ktPyString/blob/master/LICENSE")
}
}
scm {
url.set("https://github.com/ChanTsune/ktPyString.git")
}
}
publications {
create<MavenPublication>("snapshot") {
from(components["java"])
artifact(dokkaJar)
artifact(sourcesJar)
artifactId = "ktPyString"
version = "${project.version}-SNAPSHOT"
pom.initPom()
}
create<MavenPublication>("release") {
from(components["java"])
artifact(dokkaJar)
artifact(sourcesJar)
artifactId = "ktPyString"
version = "${project.version}"
pom.initPom()
}
}
repositories {
maven {
name = "bintray"
val bintrayUsername = "chantsune"
val bintrayRepoName = "ktPyString"
val bintrayPackageName = "ktPyString"
setUrl("https://api.bintray.com/content/$bintrayUsername/$bintrayRepoName/$bintrayPackageName/${project.version};publish=1;override=1")
credentials {
username = getBintrayUser()
password = getBintrayKey()
}
}
}
}