-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.gradle
229 lines (181 loc) · 6.85 KB
/
build.gradle
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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
plugins{
id 'java'
id 'java-library'
id 'idea'
id 'maven-publish'
id 'maven'
id 'com.github.johnrengelman.shadow' version '5.2.0'
}
def ver = new Version(major: 6, minor: 7, patch: 4)
allprojects {
apply plugin: 'maven-publish'
apply plugin: 'java-library'
apply plugin: 'com.github.johnrengelman.shadow'
group = "org.botblock"
version = "$ver"
ext {
dependencies {
api group: 'org.json', name: 'json', version: '20210307'
api group: 'com.github.ben-manes.caffeine', name: 'caffeine', version: '3.0.2'
api group: 'com.google.code.findbugs', name: 'jsr305', version: '3.0.2'
api group: 'org.slf4j', name: 'slf4j-api', version: '1.7.30'
artifactId = (rootProject == project? project.name : "$rootProject.name-$project.name").toLowerCase()
moduleName = "${group}.javabotblockapi${rootProject == project? "" : ".${project.name.toLowerCase()}"}"
}
configureJar = { Object jarConfig, String classifier = '' ->
jarConfig.baseName = "$project.artifactId"
jarConfig.version = "$project.version"
jarConfig.classifier = classifier
jarConfig.extension = 'jar'
jarConfig.manifest {
it.attributes(
'Implementation-Title': project.artifactId,
'Implementation-Version': project.version,
'Automatic-Module-Name': "${project.moduleName}"
)
}
}
configureJavadoc = { Object jDocConfig ->
jDocConfig.options {
it.author()
it.encoding = 'UTF-8'
it.memberLevel = JavadocMemberLevel.PUBLIC
if (it instanceof StandardJavadocDocletOptions) {
def opt = it as StandardJavadocDocletOptions
opt.links(
// JSON Lib
"https://stleary.github.io/JSON-java/",
// Discord Libs
"https://ci.dv8tion.net/job/JDA/javadoc/",
// Java 8
"https://docs.oracle.com/javase/8/docs/api/",
// BotBlock Docs
"https://docs.botblock.org/JavaBotBlockAPI/core/",
"https://docs.botblock.org/JavaBotBlockAPI/jda/",
//"https://docs.botblock.org/JavaBotBlockAPI/javacord/",
"https://docs.botblock.org/JavaBotBlockAPI/request/"
)
if (JavaVersion.current().isJava9Compatible()) {
opt.addBooleanOption("html5", true)
opt.addStringOption("-release", "8")
}
if (JavaVersion.current().isJava11Compatible()) {
opt.addBooleanOption("-no-module-directories", true)
}
}
}
}
}
repositories {
mavenCentral()
jcenter()
maven { url = 'https://m2.dv8tion.net/releases' }
}
build {
dependsOn { jar }
dependsOn { javadocJar }
dependsOn { sourcesJar }
dependsOn { shadowJar }
}
}
subprojects {
apply plugin: 'java'
ext {
includeInParent = true
}
compileJava {
source = sourceSets.main.allJava
classpath = sourceSets.main.compileClasspath
}
javadoc {
destinationDir = file("$rootDir/docs/$project.name/")
configureJavadoc(it)
}
jar {
destinationDirectory = file("$rootDir/build/libs/")
configureJar(it)
}
shadowJar {
destinationDirectory = file("$rootDir/build/libs/")
configureJar(it, 'all')
}
task javadocJar(type: Jar) {
group = 'build'
dependsOn javadoc
from javadoc.destinationDir
configureJar(it, 'javadoc')
destinationDirectory = file("$rootDir/build/libs/")
}
task sourceJar(type: Jar) {
group = 'build'
dependsOn classes
from sourceSets.main.allSource
configureJar(it, 'sources')
destinationDirectory = file("$rootDir/build/libs/")
}
afterEvaluate {
if(project.includeInParent) {
rootProject.dependencies.compile project
}
}
publishing {
publications {
mavenJava(MavenPublication) {
groupId = rootProject.group
artifactId = "javabotblockapi-"+project.name
version = rootProject.version
from components.java
artifact javadocJar
artifact sourceJar
}
}
repositories {
maven {
url = "https://repo.codemc.io/repository/maven-releases/"
def mavenUsername = System.getenv("ORG_GRADLE_PROJECT_mavenUsername") ? System.getenv("ORG_GRADLE_PROJECT_mavenUsername") :
System.getProperty("ORG_GRADLE_PROJECT_mavenUsername") ? System.getProperty("ORG_GRADLE_PROJECT_mavenUsername") : null
def mavenPassword = System.getenv("ORG_GRADLE_PROJECT_mavenPassword") ? System.getenv("ORG_GRADLE_PROJECT_mavenPassword") :
System.getProperty("ORG_GRADLE_PROJECT_mavenPassword") ? System.getProperty("ORG_GRADLE_PROJECT_mavenPassword") : null
if(mavenUsername != null && mavenPassword != null) {
credentials {
username = mavenUsername
password = mavenPassword
}
}
}
}
}
}
configurations {
compile {
description = 'compile'
transitive = true
}
}
shadowJar{
configureJar(it, 'all')
from { subprojects*.jar }
destinationDirectory = file("$rootDir/build/libs/")
}
task javadocJar(type: Jar, dependsOn: javadoc){
configureJar(it, 'javadoc')
from { javadoc.destinationDir }
destinationDirectory = file("$rootDir/build/libs/")
}
task sourcesJar(type: Jar, dependsOn: classes){
group = 'build'
dependsOn { rootProject.getTasksByName('classes', true) }
configureJar(it, 'sources')
from { subprojects*.sourceSets.main.allSource }
destinationDirectory = file("$rootDir/build/libs/")
}
class Version{
String major, minor, patch
static String getBuild(){
System.getenv("BUILD_NUMBER") ? "_" + System.getenv("BUILD_NUMBER") :
System.getProperty("BUILD_NUMBER") ? "_" + System.getProperty("BUILD_NUMBER") : ""
}
String toString(){
"$major.$minor.${patch}$build"
}
}