From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Kyle Wood Date: Thu, 10 Dec 2020 20:54:19 -0800 Subject: [PATCH] Setup Gradle project diff --git a/.gitignore b/.gitignore index 67fb370cad6924895a6b27052dbd5c1767e3f0c9..3e05459f27c4c5697ae65da504d67a6a2f617b57 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ +.gradle/ +build/ + # Eclipse stuff /.classpath /.project diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 0000000000000000000000000000000000000000..fddf2f440356425d948f40dcf9d9853a374ddc8e --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,72 @@ +import com.github.jengelman.gradle.plugins.shadow.transformers.AppendingTransformer +import java.time.Instant + +plugins { + java + id("com.github.johnrengelman.shadow") +} + +val packageVersion = providers.gradleProperty("packageVersion").forUseAtConfigurationTime().get() + +repositories { + maven("https://libraries.minecraft.net/") +} + +dependencies { + implementation(project(":Paper-API")) + implementation("jline:jline:2.12.1") + implementation("org.apache.logging.log4j:log4j-iostreams:2.14.1") { + exclude(group = "org.apache.logging.log4j", module = "log4j-api") + } + implementation("org.ow2.asm:asm:9.1") + implementation("com.googlecode.json-simple:json-simple:1.1.1") { + // This includes junit transitively for whatever reason + isTransitive = false + } + runtimeOnly("org.xerial:sqlite-jdbc:3.34.0") + runtimeOnly("mysql:mysql-connector-java:5.1.49") + + runtimeOnly("org.apache.maven:maven-resolver-provider:3.8.1") + runtimeOnly("org.apache.maven.resolver:maven-resolver-connector-basic:1.7.0") + runtimeOnly("org.apache.maven.resolver:maven-resolver-transport-http:1.7.0") + + testImplementation("junit:junit:4.13.1") + testImplementation("org.hamcrest:hamcrest-library:1.3") +} + +tasks.jar { + manifest { + attributes(mapOf( + "Main-Class" to "org.bukkit.craftbukkit.Main", + "Implementation-Title" to "CraftBukkit", + "Implementation-Vendor" to Instant.now().epochSecond, + "Specification-Title" to "Bukkit", + "Specification-Version" to project.version, + "Specification-Vendor" to "Bukkit Team" + )) + for (tld in listOf("net", "com", "org")) { + attributes(mapOf( + "Sealed" to "true" + ), "$tld/bukkit") + } + } +} + +tasks.shadowJar { + listOf( + "jline", "it.unimi", "org.apache.commons.codec", "org.apache.commons.io", + "org.apache.commons.lang3", "org.objectweb.asm" + ).forEach { pack -> + relocate(pack, "org.bukkit.craftbukkit.libs.$pack") + } + relocate("org.bukkit.craftbukkit", "org.bukkit.craftbukkit.v$packageVersion") { + exclude("org.bukkit.craftbukkit.Main*") + } + transform(AppendingTransformer::class.java) { + resource = "META-INF/services/java.sql.Driver" + } +} + +tasks.test { + exclude("org/bukkit/craftbukkit/inventory/ItemStack*Test.class") +}