forked from discord-jda/JDA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
169 lines (141 loc) · 4.15 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
import org.apache.tools.ant.filters.ReplaceTokens
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'signing'
def versionObj = new Version(major: 1, minor: 1, revision: 0)
group = "net.dv8tion"
archivesBaseName = "JDA"
version = "${versionObj.toString()}"
sourceCompatibility = 1.8
targetCompatibility = 1.8
def filteredSourceDir = file("${buildDir}/filtered")
sourceSets {
// This source set will contain all sources that we filter
filtered {
java {
srcDirs = [
filteredSourceDir,
"src/test/java",
"src/examples/java"
]
}
}
}
// copy the main sources and filter any '@buildVersion@' occurences.
task processVersion (type: Copy) {
from sourceSets.main.java
into filteredSourceDir
filter(ReplaceTokens, tokens: [
versionMajor: versionObj.getMajor(),
versionMinor: versionObj.getMinor(),
versionRevision: versionObj.getRevision(),
versionBuild: versionObj.getBuild()
])
}
jar {
baseName = project.name
manifest {
attributes 'Implementation-Version': version
}
}
task javadocJar(type: Jar) {
classifier = 'javadoc'
from javadoc
}
task sourcesJar(type: Jar) {
classifier = 'sources'
from sourceSets.filtered.java
}
//create a single Jar with all dependencies
task fatJar(type: Jar) {
manifest {
attributes 'Implementation-Version': version
}
baseName = project.name + '-withDependencies'
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
with jar
}
artifacts {
archives javadocJar, sourcesJar
}
signing {
sign configurations.archives
}
repositories {
mavenCentral()
}
dependencies {
compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.4'
compile group: 'org.json', name: 'json', version: '20150729'
compile 'com.neovisionaries:nv-websocket-client:1.16'
compile group: 'com.mashape.unirest', name: 'unirest-java', version: '1.4.7'
}
class Version {
int major, minor, revision
String getMajor() {
"${major}"
}
String getMinor() {
"${minor}"
}
String getRevision() {
"${revision}"
}
String getBuild() {
System.getenv("BUILD_NUMBER") ? System.getenv("BUILD_NUMBER") : "TEST"
}
String toString() {
"${getMajor()}.${getMinor()}.${getRevision()}_${getBuild()}"
}
}
uploadArchives {
onlyIf {
System.getenv("BUILD_NUMBER")
}
repositories {
mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
authentication(userName: ossrhUsername, password: ossrhPassword)
}
snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
authentication(userName: ossrhUsername, password: ossrhPassword)
}
pom.project {
name 'JDA'
packaging 'jar'
// optionally artifactId can be defined here
description 'A wrapping of the Discord REST api and its Websocket-Events for Java.'
url 'https://github.com/DV8FromTheWorld/JDA'
scm {
connection 'scm:git:[email protected]:DV8FromTheWorld/JDA.git'
developerConnection 'scm:git:[email protected]:DV8FromTheWorld/JDA.git'
url 'scm:git:[email protected]:DV8FromTheWorld/JDA.git'
}
licenses {
license {
name 'The Apache License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
id 'DV8FromTheWorld'
name 'Austin Keener'
email '[email protected]'
}
developer {
id 'Kantekugel'
name 'Michael Ritter'
email '[email protected]'
}
}
}
}
}
}
// tell the compileJava task to compile the filtered source
compileJava.source = sourceSets.filtered.java
compileJava.dependsOn processVersion
//Creates the w/ dependencies jar.
uploadArchives.dependsOn fatJar