forked from ProtocolSupport/ProtocolSupportPocketStuff
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
157 lines (128 loc) · 3.59 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
buildscript {
dependencies {
classpath 'org.jdom:jdom2:2.0.6'
classpath 'org.ow2.asm:asm:5.1'
classpath 'org.ow2.asm:asm-commons:5.1'
classpath 'commons-io:commons-io:2.5'
classpath 'org.apache.ant:ant:1.9.7'
classpath 'org.codehaus.plexus:plexus-utils:3.0.24'
classpath 'org.vafer:jdependency:1.1'
classpath files('gradle/plugins/shadowPlugin.jar')
}
repositories {
mavenCentral()
}
}
plugins {
id 'java'
}
apply plugin: com.github.jengelman.gradle.plugins.shadow.ShadowPlugin
tasks.withType(AbstractCompile) {
classpath += configurations.shadow
}
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
group 'protocolsupportpocketstuff'
version '1.0'
sourceCompatibility = JavaVersion.VERSION_1_8
import java.text.MessageFormat
File dlDepsDirC = new File('dllibsc')
dlDepsDirC.mkdirs()
File dlDepsDirS = new File('dllibss')
dlDepsDirS.mkdirs()
//TODO: Add ProtocolSupport to dlLibsC (Obviously we're in beta and cannot download yet so compilation will have to be done for now)
def dlDepsC = [
new Tuple(
'https://mcmirror.io/files/Spigot/Spigot-1.13.2-a1f2566-20181123-1027.jar',
'spigot-1.13.2.jar'
),
// new Tuple(
// 'https://github.com/GlowstoneMC/Glowstone/releases/download/2018.2.0/glowstone.jar',
// 'glowstone-1.12.2-1.jar'
// ),
new Tuple(
'Hah. You need to compile this yourself!',
'ProtocolSupport.jar'
)
]
def dlDepsS = [ ]
void dlDeps(def dlDeps, File dlDepsDir) {
def dlDepsNames = new HashSet<String>()
dlDeps.each({
String dlDepUrl = it[0]
File dlDepFile = new File(dlDepsDir, it[1])
dlDepsNames.add(dlDepFile.getName())
if (!dlDepFile.exists()) {
if (dlDepFile.getName().equals("ProtocolSupport.jar")) {
throw new GradleException('You still need to compile ProtocolSupport (pocket branch) and put it in dllibsc!')
} else {
logger.lifecycle(MessageFormat.format("Downloading {0} from {1}", dlDepFile.getName(), dlDepUrl))
ant.get(src: dlDepUrl, dest: dlDepFile)
}
} else {
logger.lifecycle(MessageFormat.format("Skipping download of {0} because it already exists", dlDepFile.getName()))
}
})
dlDepsDir.listFiles().findAll({ !dlDepsNames.contains(it.getName()) }).each({
logger.lifecycle(MessageFormat.format("Deleting old dllib {0}", it.getName()))
it.delete()
})
}
task updateLibs(type: DefaultTask) {doLast{
dlDeps(dlDepsC, dlDepsDirC)
dlDeps(dlDepsS, dlDepsDirS)
}}
sourceSets {
main {
java {
srcDirs = ['src']
}
resources {
srcDirs = ['resources']
}
}
test {
java {
srcDirs = ['tests']
}
}
}
repositories {
mavenCentral()
}
dependencies {
shadow files('buildprocessor/BuildProcessor.jar')
shadow fileTree(dir: dlDepsDirC, include: '*.jar')
compile fileTree(dir: dlDepsDirS, include: '*.jar')
testCompile group: 'junit', name: 'junit', version: '4.12'
}
File genDir = new File('gen')
genDir.deleteDir()
genDir.mkdirs()
task copyFinalJarToTarget(type: Copy) {
// JitPack searches for the output jar at the standard Gradle output directory (jar.archivePath)
// By copying it from there to our target destination JitPack can archive it in a Maven repository
from jar.archivePath.getPath()
into 'target'
//remove version suffix
rename (jar.archiveName, jar.baseName + '.jar')
}
shadowJar {
doFirst {
new File(destinationDir, archiveName).delete()
}
from sourceSets.main.java.srcDirs
from 'LICENSE'
from genDir
//remove the -all suffix
archiveName = jar.archiveName
minimizeJar = true
exclude 'META-INF/**'
}
compileJava.dependsOn(clean)
compileJava.dependsOn(updateLibs)
compileJava.finalizedBy(test)
jar.enabled = false
jar.finalizedBy(shadowJar)
shadowJar.finalizedBy(copyFinalJarToTarget)