| 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 from: 'helper.gradle' |
| apply plugin: com.github.jengelman.gradle.plugins.shadow.ShadowPlugin |
| |
| |
| tasks.withType(AbstractCompile) { |
| classpath += configurations.shadow |
| } |
| |
| tasks.withType(JavaCompile) { |
| options.encoding = 'UTF-8' |
| } |
| |
| |
| group 'protocolsupport' |
| version '4.29-dev' |
| sourceCompatibility = JavaVersion.VERSION_1_8 |
| |
| |
| File librariesRuntimeDirectory = new File("libraries_runtime") |
| librariesRuntimeDirectory.mkdirs() |
| |
| File librariesShadeDirectory = new File("libraries_shade") |
| librariesShadeDirectory.mkdirs() |
| |
| task updateSpigot(type: BuildLibraryTask) { |
| targetDirectory = librariesRuntimeDirectory |
| targetLibraryName = "spigot-1.13.2-3.jar" |
| builderUrl = "https://papermc.io/ci/job/Paper-1.13/488/artifact/paperclip-488.jar" |
| buildCommand = "java -Dpaperclip.patchonly=true -jar {BUILDER}" |
| builtLibraryName = "cache/patched_1.13.2.jar" |
| } |
| |
| task updateRuntimeLibraries(type: UpdateLibrariesTask) { |
| directory = librariesRuntimeDirectory |
| libraries = [] |
| manualLibraries = new HashSet<>(Arrays.asList(updateSpigot.targetLibraryName)) |
| } |
| |
| task updateShadeLibraries(type: UpdateLibrariesTask) { |
| directory = librariesShadeDirectory |
| libraries = [] |
| } |
| |
| |
| sourceSets { |
| main { |
| java { |
| srcDirs = ['src'] |
| } |
| resources { |
| srcDirs = ['resources'] |
| } |
| } |
| test { |
| java { |
| srcDirs = ['tests'] |
| } |
| } |
| } |
| |
| repositories { |
| mavenCentral() |
| jcenter() |
| } |
| |
| dependencies { |
| shadow fileTree(dir: librariesRuntimeDirectory, include: '*.jar') |
| compile fileTree(dir: librariesShadeDirectory, include: '*.jar') |
| compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.8.1' |
| compile group: 'it.unimi.dsi', name: 'fastutil', version: '8.2.2' |
| compile group: 'com.google.code.gson', name: 'gson', version: '2.8.5' |
| testCompile fileTree(dir: librariesRuntimeDirectory, include: '*.jar') |
| testCompile fileTree(dir: librariesShadeDirectory, include: '*.jar') |
| testCompile 'org.junit.jupiter:junit-jupiter-api:5.2.0' |
| testRuntime 'org.junit.jupiter:junit-jupiter-engine:5.2.0' |
| } |
| |
| test { |
| useJUnitPlatform() |
| } |
| |
| |
| File genDir = new File('gen') |
| genDir.deleteDir() |
| genDir.mkdirs() |
| |
| task generateLocaleList(type: DefaultTask) {doLast{ |
| File langsListFile = new File(genDir, "resources/i18n/languages") |
| langsListFile.getParentFile().mkdirs() |
| langsListFile.createNewFile() |
| new PrintWriter(langsListFile).withCloseable({ |
| writer -> |
| new File(sourceSets.main.resources.srcDirs.iterator().next(), "resources/i18n").list() |
| .each({ |
| String[] split = it.split("[.]"); |
| if (split.length == 2 && split[1].equals("json")) { |
| writer.println(split[0]) |
| } |
| }) |
| }) |
| }} |
| |
| 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 buildInfoFile = new File(genDir, "resources/buildinfo") |
| buildInfoFile.getParentFile().mkdirs() |
| buildInfoFile.createNewFile() |
| new FileOutputStream(buildInfoFile).withCloseable({ properties.store(it, "Build info") }) |
| }} |
| |
| shadowJar { |
| doFirst { |
| new File(destinationDir, archiveName).delete() |
| } |
| |
| from sourceSets.main.java.srcDirs |
| from 'LICENSE' |
| from genDir |
| |
| archiveName = jar.archiveName |
| minimizeJar = true |
| |
| exclude 'META-INF/**' |
| relocate 'org.apache', 'protocolsupport.libs.org.apache' |
| relocate 'it.unimi.dsi.fastutil', 'protocolsupport.libs.it.unimi.dsi.fastutil' |
| relocate 'com.google.gson', 'protocolsupport.libs.com.google.gson' |
| } |
| |
| task copyFinalJarToTarget(type: Copy) { |
| from jar.archivePath.getPath() |
| into 'target' |
| |
| rename (jar.archiveName, jar.baseName + '.jar') |
| } |
| |
| compileJava.dependsOn(clean) |
| compileJava.dependsOn(updateSpigot) |
| compileJava.dependsOn(updateRuntimeLibraries) |
| compileJava.dependsOn(updateShadeLibraries) |
| compileJava.finalizedBy(test) |
| jar.enabled = false |
| jar.finalizedBy(shadowJar) |
| shadowJar.dependsOn(generateInfo) |
| shadowJar.dependsOn(generateLocaleList) |
| shadowJar.finalizedBy(copyFinalJarToTarget) |