diff --git a/build.gradle b/build.gradle index d492510c..5638c284 100644 --- a/build.gradle +++ b/build.gradle @@ -163,28 +163,12 @@ subprojects { jaxDoclet // give test dependencies access to compileOnly dependencies to emulate providedCompile testImplementation.extendsFrom compileOnly - - dddResource // custom configuration for our ivy resources (eg. font info) - dddResource.description = "Resources (eg. yml or json data) to be included in jar builds" } repositories { // Maven Central is defined in allprojects (for JaCoCo) maven { url "https://oss.sonatype.org/content/repositories/snapshots" } maven { url "https://papermc.io/repo/repository/maven-public/" } - - // Note: Subprojects can't have repo overrides to we have to put it here - // Define a Ivy repo for the font width data (that way we don't need another plugin!) - def dddResources = ivy { - url "https://dumbdogdiner.github.io/" - patternLayout { artifact "/[module]/[revision]/[classifier].[ext]"} - metadataSources { artifact() } - } - // Only use the Ivy repo for font width data - speeds up dependency resolution - exclusiveContent { - forRepositories(dddResources) - filter { includeGroup("dumbdogdiner") } - } } dependencies { @@ -271,7 +255,7 @@ dependencies { // Root build: create uber sources from subproject sources task rootSources(type: Jar, dependsOn: subprojects.classes) { // Gradle 7 implicit dependency fix: depend on special common tasks - dependsOn(":common:copyMCFontExtractor") + dependsOn(":common:downloadWidthData") dependsOn(":common:commonSources") archiveClassifier.set("sources") @@ -291,7 +275,7 @@ task rootTestReport(type: TestReport) { // Create a libs/modules folder with submodule jars task copySubprojectJars(type: Copy, dependsOn: subprojects.jar) { // Gradle 7 implicit dependency fix: depend on special common tasks - dependsOn(":common:copyMCFontExtractor") + dependsOn(":common:downloadWidthData") dependsOn(":common:commonSources") // Copy subproject jar and sources diff --git a/buildSrc/src/main/groovy/DownloadTask.groovy b/buildSrc/src/main/groovy/DownloadTask.groovy new file mode 100644 index 00000000..80dada03 --- /dev/null +++ b/buildSrc/src/main/groovy/DownloadTask.groovy @@ -0,0 +1,17 @@ +import org.gradle.api.DefaultTask +import org.gradle.api.tasks.Input +import org.gradle.api.tasks.OutputFile +import org.gradle.api.tasks.TaskAction + +class DownloadTask extends DefaultTask { + @Input + String from + + @OutputFile + File destination + + @TaskAction + void download() { + ant.get(src: from, dest: destination) + } +} \ No newline at end of file diff --git a/common/build.gradle b/common/build.gradle index 6a5d3468..8d83aa3c 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -15,9 +15,6 @@ dependencies { // testRuntimeOnly = only accessible during the test job testRuntimeOnly "org.yaml:snakeyaml:1.27" - // Font width data (see above) - dddResource "dumbdogdiner:mc-font-extractor:main:mojangles_width_data@json" - implementation "com.google.code.gson:gson:2.8.7" // Dependencies available in both bukkit and bungee @@ -88,21 +85,18 @@ compileJava.source = processSourceTokens.outputs This task serves to copy width data from the default Minecraft font into the final jar. This data is generated by . */ +task downloadWidthData(type: DownloadTask) { + from "https://dumbdogdiner.github.io/mc-font-extractor/main/mojangles_width_data.json" + destination file("build/gen-src/generated/mojangles_width_data.json") +} -// Font Width Info -task copyMCFontExtractor(type: Copy) { - def path = project.configurations.dddResource.find {it.name.startsWith("mc-font-extractor") } - println("common: Found font data at: " + path) - from file(path) - // into file("src/main/resources") - // - Please keep this comment for future reference. - // - This is how we would do this if we weren't also adding build info (see processSourceTokens, above comments) - destinationDir file("src/main/resources/generated/") - rename "mc-font-extractor-main-mojangles_width_data.json", "mojangles_width_data.json" +// Font Width Info: Switch resources folder +processResources { + from("build/gen-src") } // Run the font data copier -tasks.processResources.dependsOn copyMCFontExtractor +tasks.processResources.dependsOn downloadWidthData // Common build: create a jar from the :common & :common:serverversion projects diff --git a/common/src/main/java/com/dumbdogdiner/stickyapi/common/util/TextUtil.java b/common/src/main/java/com/dumbdogdiner/stickyapi/common/util/TextUtil.java index 1ca0d78a..4101d314 100644 --- a/common/src/main/java/com/dumbdogdiner/stickyapi/common/util/TextUtil.java +++ b/common/src/main/java/com/dumbdogdiner/stickyapi/common/util/TextUtil.java @@ -64,7 +64,7 @@ private static class WidthEntry { static { Gson gson = new Gson(); - try (InputStream input = ClassLoader.getSystemResource("generated/mojangles_width_data.json").openStream()) { + try (InputStream input = TextUtil.class.getResourceAsStream("/generated/mojangles_width_data.json")) { WidthEntry[] entries = gson.fromJson(new InputStreamReader(input), WidthEntry[].class); for (WidthEntry entry : entries) { if (entry.getId() == null) entry.setId(0);