-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
152 lines (130 loc) · 4.62 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
import java.net.URI
import java.util.Properties
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
version = "0.6.0"
description = "(De)serialization of SpaceAPI types for Kotlin and Java."
group = "io.github.spaceapi-community"
plugins {
// Apply the Kotlin JVM plugin to add support for Kotlin.
kotlin("jvm") version "1.8.10"
// Apply the java-library plugin for API and implementation separation.
`java-library`
// Use Kotlin serialization library
kotlin("plugin.serialization") version "1.8.10"
// Publishing via Maven Central
`maven-publish`
signing
}
repositories {
mavenCentral()
}
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
withSourcesJar()
withJavadocJar()
}
tasks.withType<KotlinCompile> {
kotlinOptions {
jvmTarget = "1.8"
}
}
dependencies {
// Align versions of all Kotlin components
implementation(platform("org.jetbrains.kotlin:kotlin-bom"))
// Use the Kotlin JDK 8 standard library.
implementation("org.jetbrains.kotlin:kotlin-stdlib")
// Use serialization library
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.0")
// Kotlin helper libraries
testImplementation("org.jetbrains.kotlin:kotlin-test")
testImplementation("org.jetbrains.kotlin:kotlin-test-junit")
// HTTP client for DirectoryParser
testImplementation("com.github.kittinunf.fuel:fuel:2.3.1")
}
tasks.test {
useJUnit()
testLogging {
exceptionFormat = TestExceptionFormat.FULL
showCauses = true
showExceptions = true
showStackTraces = true
showStandardStreams = true
events("passed", "skipped", "failed", "standardOut", "standardError")
}
}
tasks.jar {
manifest {
attributes(mapOf(
"Implementation-Title" to project.name,
"Implementation-Version" to project.version
))
}
}
// A task that writes a `project.properties` file, so that code can determine its own version and other information.
tasks.create("createProperties") {
dependsOn("processResources")
doLast {
val file = File("$buildDir/resources/main/project.properties")
file.parentFile.mkdirs()
file.writer().use {
w ->
val p = Properties()
p["projectName"] = project.name
p["projectVersion"] = project.version.toString()
p.store(w, "Project information generated by gradle `createProperties` task")
}
}
}
tasks.named("classes") {
dependsOn("createProperties")
}
val githubUrl = "https://github.com/spaceapi-community/spaceapi-kt"
val licenseIdentifier = "GPL-3.0-or-later"
publishing {
publications {
create<MavenPublication>(project.name) {
groupId = project.group.toString()
artifactId = project.name
version = project.version.toString()
from(components["java"])
pom.withXml {
asNode().apply {
appendNode("description", githubUrl)
appendNode("name", rootProject.name)
appendNode("url", githubUrl)
appendNode("licenses").appendNode("license").apply {
appendNode("name", licenseIdentifier)
appendNode("url", "https://opensource.org/licenses/GPL-3.0")
appendNode("distribution", "repo")
}
appendNode("developers").appendNode("developer").apply {
appendNode("id", "dbrgn")
appendNode("name", "Danilo Bargen")
}
appendNode("scm").apply {
appendNode("url", githubUrl)
}
}
}
}
}
repositories {
maven {
val releasesRepoUrl = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
val snapshotsRepoUrl = "https://s01.oss.sonatype.org/content/repositories/snapshots"
url = URI(if (version.toString().endsWith("SNAPSHOT")) snapshotsRepoUrl else releasesRepoUrl)
if (project.hasProperty("ossrhUsername") && project.hasProperty("ossrhPassword")) {
credentials {
username = project.property("ossrhUsername") as String?
password = project.property("ossrhPassword") as String?
}
}
}
}
}
signing {
useGpgCmd()
sign(publishing.publications[project.name])
}