From 44480bf4475c1d8ae9fa2326ca4b35a721fa989a Mon Sep 17 00:00:00 2001 From: zml Date: Sat, 16 Sep 2023 10:22:11 -0700 Subject: [PATCH] feat: Add helper API to make it easier to register custom sets --- .../net/kyori/blossom/BlossomExtension.java | 75 ++++++++++++++++--- 1 file changed, 64 insertions(+), 11 deletions(-) diff --git a/src/main/java/net/kyori/blossom/BlossomExtension.java b/src/main/java/net/kyori/blossom/BlossomExtension.java index c2c4d65..a94d4cb 100644 --- a/src/main/java/net/kyori/blossom/BlossomExtension.java +++ b/src/main/java/net/kyori/blossom/BlossomExtension.java @@ -20,13 +20,14 @@ */ package net.kyori.blossom; -import java.util.Objects; import net.kyori.mammoth.Configurable; import org.gradle.api.Action; import org.gradle.api.NamedDomainObjectProvider; import org.gradle.api.PolymorphicDomainObjectContainer; import org.jetbrains.annotations.NotNull; +import static java.util.Objects.requireNonNull; + /** * Templating that applies to a specific source set. * @@ -48,11 +49,7 @@ public interface BlossomExtension { * @since 2.0.0 */ default @NotNull NamedDomainObjectProvider resources() { - if (this.getTemplateSets().getNames().contains(RESOURCE_TEMPLATE_SET_NAME)) { - return this.getTemplateSets().named(RESOURCE_TEMPLATE_SET_NAME, ResourceTemplateSet.class); - } else { - return this.getTemplateSets().register(RESOURCE_TEMPLATE_SET_NAME, ResourceTemplateSet.class); - } + return this.customResources(RESOURCE_TEMPLATE_SET_NAME); } /** @@ -62,7 +59,38 @@ public interface BlossomExtension { * @since 2.0.0 */ default void resources(final @NotNull Action configureAction) { - this.resources().configure(Objects.requireNonNull(configureAction, "configureAction")); + this.resources().configure(requireNonNull(configureAction, "configureAction")); + } + + /** + * Register an additional template set for resources. + * + *

By default, this set will read templates from the {@code src//