-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle.kts
137 lines (119 loc) · 3.52 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
plugins {
kotlin("jvm")
id("org.jetbrains.dokka")
jacoco
id("org.jlleitschuh.gradle.ktlint")
id("io.gitlab.arturbosch.detekt")
`maven-publish`
signing
id("io.github.gradle-nexus.publish-plugin")
}
val myGroup = "com.github.pgreze"
.also { group = it }
val myArtifactId = "kyper"
val tagVersion = System.getenv("GITHUB_REF")?.split('/')?.last()
val myVersion = (tagVersion?.trimStart('v') ?: "WIP")
.also { version = it }
val myDescription = "Functional Kotlin friendly way to create command line applications."
.also { description = it }
val githubUrl = "https://github.com/pgreze/$myArtifactId"
java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
withSourcesJar()
withJavadocJar()
}
kotlin {
explicitApi()
}
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions.jvmTarget = "11"
}
tasks.withType<Test> {
useJUnitPlatform()
finalizedBy(tasks.jacocoTestReport)
}
configure<org.jlleitschuh.gradle.ktlint.KtlintExtension> {
disabledRules.set(setOf("import-ordering"))
}
jacoco {
toolVersion = "0.8.7"
}
tasks.jacocoTestReport {
reports {
xml.required.set(true)
html.required.set(System.getenv("CI") != "true")
}
}
dependencies {
implementation(Kotlin.stdlib)
implementation(kotlin("reflect"))
implementation(KotlinX.coroutines.core)
testImplementation(Testing.junit.jupiter.engine)
testImplementation(Testing.junit.jupiter.params)
testImplementation("org.jetbrains.kotlin:kotlin-test-junit5")
// https://kotest.io/docs/assertions/assertions.html
testImplementation(Testing.kotest.assertions.core)
}
//
// Publishing
//
val propOrEnv: (String, String) -> String? = { key, envName ->
project.properties.getOrElse(key, defaultValue = { System.getenv(envName) })?.toString()
}
val ossrhUsername = propOrEnv("ossrh.username", "OSSRH_USERNAME")
val ossrhPassword = propOrEnv("ossrh.password", "OSSRH_PASSWORD")
publishing {
publications {
create<MavenPublication>("maven") {
groupId = myGroup
artifactId = myArtifactId
version = myVersion
from(components["java"])
pom {
name.set(myArtifactId)
description.set(myDescription)
url.set(githubUrl)
licenses {
license {
name.set("The Apache License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
}
}
developers {
developer {
id.set("pgreze")
name.set("Pierrick Greze")
}
}
scm {
connection.set("$githubUrl.git")
developerConnection.set("scm:git:ssh://github.com:pgreze/$myArtifactId.git")
url.set(githubUrl)
}
}
}
}
repositories {
maven {
name = "sonatype"
setUrl("https://oss.sonatype.org/service/local/staging/deploy/maven2/")
credentials {
username = ossrhUsername
password = ossrhPassword
}
}
}
}
signing {
sign(publishing.publications)
}
nexusPublishing {
packageGroup.set(myGroup)
repositories {
sonatype {
username.set(ossrhUsername)
password.set(ossrhPassword)
}
}
}