-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
build.gradle.kts
180 lines (153 loc) · 5.07 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
import com.jfrog.bintray.gradle.BintrayExtension
import org.jmailen.gradle.kotlinter.support.ReporterType
plugins {
kotlin("jvm") version "1.4.0"
id("org.jmailen.kotlinter") version "3.0.2"
jacoco
`maven-publish`
id("com.jfrog.bintray") version "1.8.4"
}
allprojects {
repositories {
google()
mavenCentral()
jcenter()
}
}
subprojects {
apply {
plugin("kotlin")
plugin("org.jmailen.kotlinter")
plugin("jacoco")
plugin("maven-publish")
plugin("com.jfrog.bintray")
}
sourceSets {
getByName("main").java.srcDirs("src/main/kotlin")
getByName("test").java.srcDirs("src/main/kotlin")
}
jacoco {
val jacocoVersion: String by project
toolVersion = jacocoVersion
}
tasks.withType<JacocoReport> {
reports {
html.isEnabled = false
xml.isEnabled = true
csv.isEnabled = false
}
}
kotlinter {
reporters = arrayOf(ReporterType.plain.name, ReporterType.checkstyle.name)
}
val artifactRepo: String by project
val artifactName: String by project
val artifactDesc: String by project
val artifactUserOrg: String by project
val artifactUrl: String by project
val artifactScm: String by project
val artifactLicenseName: String by project
val artifactLicenseUrl: String by project
val artifactPublish: String by project
val artifactGroupId: String by project
version = artifactPublish
group = artifactGroupId
//publishing
configure<PublishingExtension> {
val sourceSets = project.the<SourceSetContainer>()
val sourcesJar by tasks.registering(Jar::class) {
from(sourceSets["main"].allSource)
classifier = "sources"
}
val javadocJar by tasks.creating(Jar::class) {
val doc by tasks.creating(Javadoc::class) {
isFailOnError = false
source = sourceSets["main"].allJava
}
dependsOn(doc)
from(doc)
classifier = "javadoc"
}
publications {
register(project.name, MavenPublication::class) {
from(components["java"])
artifact(sourcesJar.get())
artifact(javadocJar)
groupId = artifactGroupId
artifactId = project.name
version = artifactPublish
pom {
name.set(project.name)
description.set(artifactDesc)
packaging = "jar"
url.set(artifactUrl)
licenses {
license {
name.set("MIT License")
url.set("http://www.opensource.org/licenses/mit-license.php")
}
}
developers {
developer {
name.set("kittinunf")
}
developer {
name.set("babedev")
}
developer {
name.set("janjaali")
}
}
contributors {
// https://github.com/kittinunf/Result/graphs/contributors
contributor {
name.set("pgreze")
}
}
scm {
url.set(artifactUrl)
connection.set(artifactScm)
developerConnection.set(artifactScm)
}
}
}
}
}
// bintray
configure<BintrayExtension> {
user = findProperty("BINTRAY_USER") as? String
key = findProperty("BINTRAY_KEY") as? String
setPublications(project.name)
publish = true
pkg.apply {
repo = artifactRepo
name = artifactName
desc = artifactDesc
userOrg = artifactUserOrg
websiteUrl = artifactUrl
vcsUrl = artifactUrl
setLicenses(artifactLicenseName)
version.apply {
name = artifactPublish
gpg(delegateClosureOf<BintrayExtension.GpgConfig> {
sign = true
passphrase = System.getenv("GPG_PASSPHRASE") ?: ""
})
}
}
}
// jacoco
configure<JacocoPluginExtension> {
toolVersion = extra.get("jacoco") as String
}
tasks.withType<JacocoReport> {
reports {
html.isEnabled = true
xml.isEnabled = true
csv.isEnabled = false
}
}
}
fun <T> NamedDomainObjectContainer<T>.release(configure: T.() -> Unit) = getByName("release", configure)
fun <T> NamedDomainObjectContainer<T>.debug(configure: T.() -> Unit) = getByName("debug", configure)
fun <T> NamedDomainObjectContainer<T>.all(configure: T.() -> Unit) = getByName("all", configure)