From 001dd9ac74a77f39947f98f7bb6af77aa72f672c Mon Sep 17 00:00:00 2001 From: modmuss50 Date: Fri, 1 Mar 2019 21:24:26 +0000 Subject: [PATCH] Basic work on the genResources task --- build.gradle | 5 +++ .../build/GenerateResourcesTask.java | 31 ++++++++++++++ .../techreborn/build/model/ModelBuilder.java | 40 +++++++++++++++++++ 3 files changed, 76 insertions(+) create mode 100644 buildSrc/src/main/java/techreborn/build/GenerateResourcesTask.java create mode 100644 buildSrc/src/main/java/techreborn/build/model/ModelBuilder.java diff --git a/build.gradle b/build.gradle index f8cf7fdcd..ebf318ed3 100644 --- a/build.gradle +++ b/build.gradle @@ -196,6 +196,11 @@ task renameCrowdin(type: Copy, dependsOn: ['crowdin', 'cleanCrowdin']){ } } +import techreborn.build.GenerateResourcesTask +task genResources(type: GenerateResourcesTask){ + outputDir = file("src/main/resources") +} + publishing { publications { maven(MavenPublication) { diff --git a/buildSrc/src/main/java/techreborn/build/GenerateResourcesTask.java b/buildSrc/src/main/java/techreborn/build/GenerateResourcesTask.java new file mode 100644 index 000000000..be8a494c8 --- /dev/null +++ b/buildSrc/src/main/java/techreborn/build/GenerateResourcesTask.java @@ -0,0 +1,31 @@ +package techreborn.build; + +import org.gradle.api.DefaultTask; +import org.gradle.api.tasks.TaskAction; +import techreborn.build.model.ModelBuilder; + +import java.io.File; + +public class GenerateResourcesTask extends DefaultTask { + + private File outputDir; + + @TaskAction + public void run(){ + System.out.println("Generating Resources for " + getProject().getName()); + ModelBuilder modelBuilder = new ModelBuilder(outputDir) + + .model("techreborn:grdiner") + .build() + + .generate(); + } + + public File getOutputDir() { + return outputDir; + } + + public void setOutputDir(File outputDir) { + this.outputDir = outputDir; + } +} diff --git a/buildSrc/src/main/java/techreborn/build/model/ModelBuilder.java b/buildSrc/src/main/java/techreborn/build/model/ModelBuilder.java new file mode 100644 index 000000000..5606c5a35 --- /dev/null +++ b/buildSrc/src/main/java/techreborn/build/model/ModelBuilder.java @@ -0,0 +1,40 @@ +package techreborn.build.model; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +public class ModelBuilder { + + File outputDir; + private List models = new ArrayList<>(); + + public ModelBuilder(File outputDir) { + this.outputDir = outputDir; + } + + public ModelBuilder generate(){ + //TODO write out all the files + return this; + } + + public Model model(String name){ + Model model = new Model(name, this); + models.add(model); + return model; + } + + public static class Model { + String name; + ModelBuilder modelBuilder; + + private Model(String name, ModelBuilder modelBuilder) { + this.name = name; + this.modelBuilder = modelBuilder; + } + + public ModelBuilder build(){ + return modelBuilder; + } + } +}