forked from DV8FromTheWorld/JDA-Player
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
189 lines (159 loc) · 4.7 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
//use: gradlew clean build fatJar signArchives install bintrayUpload
import org.apache.tools.ant.filters.ReplaceTokens
plugins {
id "com.jfrog.bintray" version "1.6"
}
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'signing'
apply plugin: 'eclipse'
def versionObj = new Version(major: 0, minor: 2, revision: 1)
group = "net.dv8tion"
archivesBaseName = "jda-player"
version = "$versionObj"
sourceCompatibility = 1.8
targetCompatibility = 1.8
tasks.eclipse.dependsOn(cleanEclipse)
def filteredSourceDir = file("$buildDir/filtered")
// This is to fix eclipse's stupidity when first setting up the project.
// It thinks that "filtered" should be a development source folder and cries when it doesn't exist (gradlew clean)
eclipse {
classpath {
file {
withXml {
def sb = it.asString()
sb.replace(0, sb.length(), sb.toString().replace("\n\t<classpathentry kind=\"src\" path=\"build/filtered\"/>", ""));
}
}
}
}
sourceSets {
// This source set will contain all sources that we filter
filtered {
java {
srcDirs = [
filteredSourceDir,
"src/test/java",
]
}
}
}
javadoc {
failOnError = false
}
// copy the main sources and filter any '@buildVersion@' occurences.
task processVersion (type: Copy) {
from sourceSets.main.java
into filteredSourceDir
filter(ReplaceTokens, tokens: [
versionMajor: versionObj.major.toString(),
versionMinor: versionObj.minor.toString(),
versionRevision: versionObj.revision.toString(),
versionBuild: versionObj.build.toString()
])
}
jar {
baseName = project.name
manifest {
attributes 'Implementation-Version': version
}
include "net/dv8tion/jda/**"
}
task javadocJar(type: Jar) {
classifier = 'javadoc'
from javadoc
}
task sourcesJar(type: Jar) {
classifier = 'sources'
from sourceSets.filtered.java
include "net/dv8tion/jda/**"
}
// create a single Jar with all dependencies
task fatJar(type: Jar) {
manifest {
attributes 'Implementation-Version': version
}
baseName = project.name + '-withDependencies'
from {
configurations.compile.collect {
dependency ->
if (dependency.directory) { // If it is a folder, just include the folder in its entirety
return dependency
} else { // If it isn't a folder, put it in a zipTree. if it is a zip or jar the contents will be extracted.
return zipTree(dependency)
}
}
}
with jar
}
artifacts {
archives javadocJar, sourcesJar
}
signing {
sign configurations.archives
}
repositories {
jcenter()
}
dependencies {
compile 'net.dv8tion:JDA:2.0.0_251'
}
class Version {
int major, minor, revision
String getBuild() {
System.getenv("BUILD_NUMBER") ?: System.getProperty("BUILD_NUMBER") ?: "DEV"
}
String toString() {
"${major}.${minor}.${revision}_$build"
}
}
bintray {
user = bintrayUsername
key = bintrayApiKey
pkg {
repo = 'maven'
name = 'JDA-Player'
licenses = ['Apache-2.0']
vcsUrl = 'https://github.com/DV8FromTheWorld/JDA-Player.git'
filesSpec {
from ('build/libs') {
exclude "**withDependencies**"
}
from 'build/poms'
into "${project.group.replace(".", "/")}/${archivesBaseName}/${project.version}"
rename { String fileName ->
fileName.replace("pom-default.xml", "${archivesBaseName}-${project.version}.pom")
}
}
publish = true
version {
name = project.version
released = new Date()
}
}
}
bintrayUpload {
onlyIf {
System.getenv("BUILD_NUMBER")
}
}
String getProjectProperty(String propertyName)
{
String property = ""
if (hasProperty(propertyName))
{
property = this.properties[propertyName]
}
return property
}
// tell the compileJava task to compile the filtered source
compileJava.source = sourceSets.filtered.java
compileJava.dependsOn processVersion
//use: gradlew clean build fatJar signArchives install bintrayUpload
// If we don't have the username and password for uploading, we probably also
// can't sign the archives, so skip these tasks.
signArchives.onlyIf {(!getProjectProperty("signing.keyId").empty
&& !getProjectProperty("signing.password").empty
&& !getProjectProperty("signing.secretKeyRingFile").empty) }
bintrayUpload.onlyIf { (!getProjectProperty("bintrayUsername").empty
&& !getProjectProperty("bintrayApiKey").empty) }