forked from StratusNetwork/ProtocolSupport
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle
More file actions
138 lines (115 loc) · 3.6 KB
/
build.gradle
File metadata and controls
138 lines (115 loc) · 3.6 KB
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
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')
}
}
plugins {
id 'java'
id 'de.undercouch.download' version '3.1.1'
}
apply plugin: com.github.jengelman.gradle.plugins.shadow.ShadowPlugin
tasks.withType(AbstractCompile) {
classpath += configurations.shadow
}
group 'protocolsupport'
version '4.29-dev'
sourceCompatibility = 1.8
import de.undercouch.gradle.tasks.download.Download
File dllibs = new File('dllibs')
dllibs.mkdirs()
File gen = new File('gen')
gen.deleteDir();
gen.mkdirs();
task updateLibs(type: Download) {
src([
'https://yivesmirror.com/files/spigot/spigot-1.12.2-R0.1-SNAPSHOT-b1408.jar',
'https://repo.glowstone.net/repository/snapshots/net/glowstone/glowstone/2018.0.0-SNAPSHOT/glowstone-2018.0.0-20171205.014003-7.jar'
])
dest dllibs
onlyIfNewer true
overwrite true
}
compileJava.dependsOn(clean)
compileJava.dependsOn(updateLibs)
compileJava.finalizedBy(test)
sourceSets {
main {
java {
srcDirs = ['src']
}
resources {
srcDirs = ['resources']
}
}
test {
java {
srcDirs = ['tests']
}
}
}
task generateLocaleList(type: DefaultTask) {doLast{
ArrayList<String> locales = new ArrayList<String>();
for (String filename : new File(sourceSets.main.resources.srcDirs.iterator().next(), "resources/i18n").list()) {
String[] split = filename.split("[.]");
if (split.length == 2 && split[1].equals("lang")) {
locales.add(split[0]);
}
}
File languageslist = new File(gen, "resources/i18n/languages");
languageslist.getParentFile().mkdirs();
languageslist.createNewFile();
PrintWriter writer = new PrintWriter(languageslist);
for (String locale : locales) {
writer.println(locale);
}
writer.close();
}}
task generateInfo(type: DefaultTask) {doLast{
Properties properties = new Properties();
properties.setProperty("buildtime", new Date().format("yyyy.MM.dd 'at' HH:mm:ss z"));
properties.setProperty("buildhost", System.getProperty("protocolsupport.buildhost", "unknown"));
properties.setProperty("buildnumber", System.getProperty("protocolsupport.buildnumber", "unknown"));
File buildinfo = new File(gen, "resources/buildinfo");
buildinfo.getParentFile().mkdirs();
buildinfo.createNewFile();
properties.store(new FileOutputStream(buildinfo), "Build info");
}}
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
shadow files('buildprocessor/BuildProcessor.jar', new File(dllibs, 'glowstone-2018.0.0-20171205.014003-7.jar'))
compile 'tc.oc:sportbukkit-api:1.12.2-R0.1-SNAPSHOT'
compile 'tc.oc:sportbukkit:1.12.2-R0.1-SNAPSHOT'
compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.0'
compile group: 'net.sf.trove4j', name: 'trove4j', version: '3.0.3'
compile group: 'com.google.code.gson', name: 'gson', version: '2.8.0'
testCompile group: 'junit', name: 'junit', version: '4.12'
}
shadowJar {
doFirst {
new File(destinationDir, archiveName).delete()
}
from sourceSets.main.java.srcDirs
from 'LICENSE'
from gen
minimizeJar = true
destinationDir = file('target')
archiveName = 'ProtocolSupport.jar'
exclude 'META-INF/**'
relocate 'org.apache', 'protocolsupport.libs.org.apache'
relocate 'gnu.trove', 'protocolsupport.libs.gnu.trove'
relocate 'com.google.gson', 'protocolsupport.libs.com.google.gson'
}
shadowJar.dependsOn(generateInfo)
shadowJar.dependsOn(generateLocaleList)
jar.enabled = false
jar.finalizedBy(shadowJar)