This repository has been archived by the owner on Jan 23, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
87 lines (68 loc) · 1.88 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
plugins {
id 'java'
id 'com.github.ben-manes.versions' version '0.28.0'
id 'com.github.johnrengelman.shadow' version '5.2.0'
}
group 'com.github.nigthcrawlerx1.jdacommands'
archivesBaseName = "JDA-Commands-API"
def ver = new Version(major: 0, minor: 0, revision: 5)
version ver.toString()
sourceCompatibility = targetCompatibility = 1.8
repositories {
mavenCentral()
maven {
name 'm2-dv8tion'
url 'https://m2.dv8tion.net/releases'
}
}
dependencies {
compile 'net.dv8tion:JDA:4.3.0_310'
compile 'org.reflections:reflections:0.9.12'
testCompile group: 'junit', name: 'junit', version: '4.12'
}
import org.apache.tools.ant.filters.ReplaceTokens
def gitRevision() {
def gitVersion = new ByteArrayOutputStream()
exec {
commandLine("git", "rev-parse", "--short", "HEAD")
standardOutput = gitVersion
}
return gitVersion.toString().trim()
}
task sourcesForRelease(type: Copy) {
from ('src/main/java') {
include '**/JDACommandInfo.java'
filter(ReplaceTokens, tokens: [
version: ver.toString(),
revision: gitRevision().toString()
])
}
into 'build/filteredSrc'
includeEmptyDirs = false
}
task generateJavaSources(type: SourceTask) {
def javaSources = sourceSets.main.allJava.filter {
it.name != 'JDACommandInfo.java'
}
source = javaSources + sourcesForRelease.destinationDir
dependsOn sourcesForRelease
}
compileJava {
source = generateJavaSources.source
classpath = sourceSets.main.compileClasspath
dependsOn generateJavaSources
}
shadowJar {
classifier = "withDependencies"
exclude 'module-info.class'
}
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
options.incremental = true
}
class Version {
String major, minor, revision
String toString() {
"${major}.${minor}.${revision}"
}
}