| 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.2.0-SNAPSHOT/glowstone-2018.2.0-20180209.231901-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 { |
| mavenCentral() |
| } |
| |
| dependencies { |
| shadow files('buildprocessor/BuildProcessor.jar', new File(dllibs, 'spigot-1.12.2-R0.1-SNAPSHOT-b1408.jar'), new File(dllibs, 'glowstone-2018.2.0-20180209.145144-5.jar')) |
| 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) |