-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle.kts
148 lines (130 loc) · 4.13 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
import java.util.Base64
plugins {
kotlin("jvm")
`maven-publish`
id("org.jetbrains.dokka")
id("org.jlleitschuh.gradle.ktlint")
id("io.github.gradle-nexus.publish-plugin")
signing
}
val projectGroup: String by project
val projectVersion: String by project
val projectDescription: String by project
group = projectGroup
version = projectVersion
description = projectDescription
repositories {
mavenCentral()
}
val junitVersion: String by project
val grpcVersion: String by project
val mockitoVersion: String by project
val junitTestkitVersion: String by project
dependencies {
implementation(kotlin("stdlib-jdk8"))
implementation(platform("io.grpc:grpc-bom:$grpcVersion"))
implementation(platform("org.junit:junit-bom:$junitVersion"))
implementation("org.junit.jupiter:junit-jupiter-api")
implementation("io.grpc:grpc-api")
testImplementation("org.junit.jupiter:junit-jupiter")
testImplementation("io.grpc:grpc-core")
testImplementation("org.mockito:mockito-core:$mockitoVersion")
testImplementation("org.mockito:mockito-junit-jupiter:$mockitoVersion")
testImplementation("org.junit.platform:junit-platform-testkit:$junitTestkitVersion")
}
plugins.withType<JavaPlugin> {
extensions.configure<JavaPluginExtension> {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
}
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions {
freeCompilerArgs = listOf("-Xjsr305=strict")
jvmTarget = "1.8"
}
}
tasks.dokkaHtml.configure {
outputDirectory.set(buildDir.resolve("javadoc"))
dokkaSourceSets.configureEach {
jdkVersion.set(8)
skipEmptyPackages.set(true)
platform.set(org.jetbrains.dokka.Platform.jvm)
}
}
val sourcesJar by tasks.creating(Jar::class) {
group = JavaBasePlugin.DOCUMENTATION_GROUP
description = "Creates a sources JAR"
archiveClassifier.set("sources")
from(sourceSets.main.get().allSource)
}
val kdocJar by tasks.creating(Jar::class) {
group = JavaBasePlugin.DOCUMENTATION_GROUP
description = "Creates KDoc"
archiveClassifier.set("javadoc")
from(tasks.dokkaHtml)
}
tasks.jar.configure {
finalizedBy(sourcesJar, kdocJar)
}
val licenseName: String by project
val licenseUrl: String by project
val developerName: String by project
val developerEmail: String by project
val gitHubUsername: String by project
val gitHubUrl: String by lazy { "github.com/$gitHubUsername/${project.name}" }
publishing {
publications {
create<MavenPublication>("maven") {
from(components["java"])
artifact(kdocJar)
artifact(sourcesJar)
pom {
name.set("${project.group}:${project.name}")
description.set(project.description)
url.set("https://$gitHubUrl")
licenses {
license {
name.set(licenseName)
url.set(licenseUrl)
}
}
developers {
developer {
name.set(developerName)
email.set(developerEmail)
}
}
scm {
connection.set("scm:git:git://$gitHubUrl.git")
developerConnection.set("scm:git:ssh://github.com:$gitHubUsername/${project.name}.git")
url.set("https://$gitHubUrl")
}
}
}
}
}
fun base64Decode(prop: String): String? {
return project.findProperty(prop)?.let {
String(Base64.getDecoder().decode(it.toString())).trim()
}
}
signing {
useInMemoryPgpKeys(base64Decode("signingKey"), base64Decode("signingPassword"))
sign(*publishing.publications.toTypedArray())
}
nexusPublishing {
repositories {
sonatype {
username.set(base64Decode("sonatypeUsername"))
password.set(base64Decode("sonatypePassword"))
}
}
}
tasks.withType<Test> {
useJUnitPlatform()
testLogging {
showStandardStreams = true
}
exclude("**/ignore/**")
}