-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
132 lines (109 loc) · 3.62 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
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: 1, minor: 3, revision: 1)
group = 'net.discordservices'
version = "$ver"
java{
sourceCompatibility = targetCompatibility = JavaVersion.VERSION_1_8
}
repositories{
mavenCentral()
}
jar{
getArchiveFileName().set("DServices4J.jar")
}
dependencies{
api group: 'com.squareup.okhttp3', name: 'okhttp', version: '4.5.0'
api group: 'org.json', name: 'json', version: '20190722'
api group: 'org.jetbrains', name: 'annotations', version: '19.0.0'
api group: 'com.github.ben-manes.caffeine', name: 'caffeine', version: '2.8.0'
api group: 'org.slf4j', name: 'slf4j-api', version: '1.7.30'
}
task sourcesJar(type: Jar, dependsOn: classes){
getArchiveClassifier().set("sources")
from(sourceSets.main.allSource)
}
task javadocJar(type: Jar, dependsOn: javadoc){
getArchiveClassifier().set("javadoc")
from(javadoc.destinationDir)
}
artifacts{
archives jar
archives sourcesJar
archives javadocJar
archives shadowJar
}
javadoc{
source = sourceSets.main.allJava
destinationDir = file("$projectDir/docs")
options.encoding = 'UTF-8'
options.memberLevel = JavadocMemberLevel.PROTECTED
if(options instanceof StandardJavadocDocletOptions){
def opt = options as StandardJavadocDocletOptions
opt.links(
"https://stleary.github.io/JSON-java/",
"https://docs.oracle.com/javase/8/docs/api/"
)
if(JavaVersion.current().isJava9Compatible()){
opt.addBooleanOption("html5", true)
opt.addStringOption("-release", "8")
}
if(JavaVersion.current().isJava11Compatible()){
opt.addBooleanOption("-no-module-directories", true)
}
}
exclude(
"net/discordservices/dservices4j/Checks.java",
"net/discordservices/dservices4j/requests"
)
}
build{
dependsOn(jar)
dependsOn(javadocJar)
dependsOn(sourcesJar)
dependsOn(shadowJar)
}
publishing {
publications {
mavenJava(MavenPublication) {
groupId = group
artifactId = "dservices4j"
version version
from components.java
artifact shadowJar
artifact javadocJar
artifact sourcesJar
}
}
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 {
it.username(mavenUsername)
it.password(mavenPassword)
}
}
}
}
}
class Version{
String major, minor, revision
static String getBuild(){
System.getenv("BUILD_NUMBER") ? "_" + System.getenv("BUILD_NUMBER") :
System.getProperty("BUILD_NUMBER") ? "_" + System.getProperty("BUILD_NUMBER") : ""
}
String toString(){
"$major.$minor.${revision}$build"
}
}