Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 2 additions & 18 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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")
Expand All @@ -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
Expand Down
17 changes: 17 additions & 0 deletions buildSrc/src/main/groovy/DownloadTask.groovy
Original file line number Diff line number Diff line change
@@ -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)
}
}
22 changes: 8 additions & 14 deletions common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 <https://github.com/DumbDogDiner/mc-font-extractor>.
*/
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down