forked from Javacord/Javacord
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
193 lines (173 loc) · 6.95 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
181
182
183
184
185
186
187
188
189
190
191
192
193
import org.gradle.api.JavaVersion.VERSION_11
import org.gradle.api.JavaVersion.VERSION_13
import org.gradle.api.JavaVersion.VERSION_1_9
plugins {
`java-library`
`maven-publish`
signing
id("com.github.johnrengelman.shadow") version "7.1.2" apply false
id("net.researchgate.release") version "3.0.2" apply false
}
repositories {
mavenCentral()
}
dependencies {
api(project(":javacord-api"))
implementation(project(":javacord-core"))
}
allprojects {
group = "org.javacord"
description = "An easy to use multithreaded library for creating Discord bots in Java"
apply(plugin = "java-library")
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
}
task("generate") // We need to create the task so that the generation files can extend it
val releaseVersion by extra(!version.toString().endsWith("-SNAPSHOT"))
subprojects {
val shortName by extra(name.replace("javacord-", ""))
description = "An easy to use multithreaded library for creating Discord bots in Java ($shortName)"
}
apply(from = "gradle/readme.gradle.kts")
apply(from = "gradle/jars.gradle")
apply(from = "gradle/java9.gradle")
apply(from = "gradle/tests.gradle")
apply(from = "gradle/listener-manager-generation.gradle")
apply(from = "gradle/event-dispatcher-generation.gradle")
apply(from = "gradle/checkstyle.gradle.kts")
apply(from = "gradle/increment-version.gradle.kts")
apply(from = "gradle/generate-changelog.gradle.kts")
configure<PublishingExtension> {
allprojects {
val isReleaseVersion = !version.toString().endsWith("SNAPSHOT")
apply(plugin = "java-library")
apply(plugin = "maven-publish")
apply(plugin = "signing")
publishing {
publications {
create<MavenPublication>("javacord") {
pom {
name.set(rootProject.name.capitalize() + (if (project.parent != null) " (${project.ext.get("shortName")})" else ""))
description.set(project.description)
url.set("https://javacord.org")
issueManagement {
system.set("GitHub")
url.set("https://github.com/Javacord/Javacord/issues")
}
ciManagement {
system.set("GitHub Actions")
}
inceptionYear.set("2015")
developers {
developer {
id.set("Bastian")
name.set("Bastian Oppermann")
email.set("[email protected]")
url.set("https://github.com/Bastian")
timezone.set("Europe/Berlin")
}
}
contributors {
contributor {
name.set("Björn Kautler")
email.set("[email protected]")
url.set("https://github.com/Vampire")
timezone.set("Europe/Berlin")
}
}
licenses {
license {
name.set("Apache License, Version 2.0")
url.set("https://www.apache.org/licenses/LICENSE-2.0.txt")
distribution.set("repo")
comments.set("A business-friendly OSS license")
}
}
scm {
connection.set("scm:git:https://github.com/Javacord/Javacord.git")
developerConnection.set("scm:git:[email protected]:Javacord/Javacord.git")
url.set("https://github.com/Javacord/Javacord")
}
distributionManagement {
downloadUrl.set("https://github.com/Javacord/Javacord/releases")
}
}
}
}
repositories {
maven {
name = "OSSRH"
url = if (isReleaseVersion) {
uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/")
} else {
uri("https://oss.sonatype.org/content/repositories/snapshots/")
}
credentials {
username = System.getenv("MAVEN_USERNAME")
password = System.getenv("MAVEN_PASSWORD")
}
}
}
}
signing {
val isRequired = releaseVersion && (tasks.withType<PublishToMavenRepository>().find {
gradle.taskGraph.hasTask(it)
} != null)
setRequired(isRequired)
val signingKey = System.getenv("SIGNING_KEY")
val signingPassword = System.getenv("SIGNING_PASSWORD")
useInMemoryPgpKeys(signingKey, signingPassword)
sign(publishing.publications["javacord"])
}
}
}
subprojects {
publishing {
publications {
named<MavenPublication>("javacord") {
from(components["java"])
}
}
}
}
publishing {
publications {
named<MavenPublication>("javacord") {
// add the dependencies to the POM
from(components["java"])
// but do not try to publish the JAR
artifacts.removeAll { it.classifier == null && it.extension == "jar" }
}
}
}
subprojects {
tasks.withType<Javadoc>().configureEach {
options {
this as StandardJavadocDocletOptions
locale = "en"
encoding = "UTF-8"
docTitle = "Javacord ${project.version} (${project.property("shortName")})"
windowTitle = "$docTitle Documentation"
links("https://docs.oracle.com/javase/8/docs/api/")
isUse = true
isVersion = true
isAuthor = true
isSplitIndex = true
val toolchain = javadocTool
.map { JavaVersion.toVersion(it.metadata.languageVersion) }
.orElse(provider { JavaVersion.current() })
.get()
if (toolchain.isCompatibleWith(VERSION_1_9)) {
addBooleanOption("html5", true)
addStringOption("-release", java.targetCompatibility.majorVersion)
if (toolchain.isCompatibleWith(VERSION_11) && !toolchain.isCompatibleWith(VERSION_13)) {
addBooleanOption("-no-module-directories", true)
}
} else {
source = java.sourceCompatibility.toString()
}
}
}
}