Class SymbolCraftExtension
-
- All Implemented Interfaces:
public abstract class SymbolCraftExtensionDSL entry point exposed as
symbolCraft { ... }in a consuming build script.The extension collects icon requests from multiple icon libraries and paths that drive io.github.kingsword09.symbolcraft.tasks.GenerateSymbolsTask.
-
-
Field Summary
Fields Modifier and Type Field Description private final Property<Boolean>cacheEnabledprivate final Property<String>cacheDirectoryprivate final Property<String>outputDirectoryprivate final Property<String>packageNameprivate final Property<Boolean>generatePreviewprivate final Property<Integer>maxRetriesprivate final Property<Long>retryDelayMs
-
Constructor Summary
Constructors Constructor Description SymbolCraftExtension()
-
Method Summary
Modifier and Type Method Description abstract Property<Boolean>getCacheEnabled()enables reuse of downloaded SVG assets between builds. abstract Property<String>getCacheDirectory()directory that hosts cached SVG payloads (relative to build/by default).abstract Property<String>getOutputDirectory()Kotlin source folder where generated code will be written. abstract Property<String>getPackageName()root package used for generated Kotlin types. abstract Property<Boolean>getGeneratePreview()toggles Compose preview function generation for each icon. abstract Property<Integer>getMaxRetries()maximum number of retry attempts for failed downloads (default: 3). abstract Property<Long>getRetryDelayMs()initial delay between retries in milliseconds (default: 1000ms). final Unitnaming(Action<NamingConfig> action)Configure icon naming transformation. final UniticonConfig(String name, IconConfig config)Generic method to add an icon with any IconConfig implementation. final UniticonConfigs(String names, Function1<String, IconConfig> configFactory)Batch configure multiple icons with the same configuration. final UnitmaterialSymbol(String name, Function1<MaterialSymbolsBuilder, Unit> configure)Configure Material Symbols icons with DSL builder. final UnitmaterialSymbols(String names, Function1<MaterialSymbolsBuilder, Unit> configure)Convenience overload for configuring multiple Material Symbols with the same style block. final UnitexternalIcon(String name, String libraryName, Function1<ExternalIconBuilder, Unit> configure)Configure external icon from other icon libraries with URL template. final UnitexternalIcons(String names, String libraryName, Function1<ExternalIconBuilder, Unit> configure)Convenience overload for configuring multiple external icons from the same library. final Map<String, List<IconConfig>>getIconsConfig()Returns an immutable snapshot of all icon requests declared via the DSL. final StringgetConfigHash()Computes a deterministic hash for the current configuration. -
-
Method Detail
-
getCacheEnabled
abstract Property<Boolean> getCacheEnabled()
enables reuse of downloaded SVG assets between builds.
-
getCacheDirectory
abstract Property<String> getCacheDirectory()
directory that hosts cached SVG payloads (relative to
build/by default).
-
getOutputDirectory
abstract Property<String> getOutputDirectory()
Kotlin source folder where generated code will be written.
-
getPackageName
abstract Property<String> getPackageName()
root package used for generated Kotlin types.
-
getGeneratePreview
abstract Property<Boolean> getGeneratePreview()
toggles Compose preview function generation for each icon.
-
getMaxRetries
abstract Property<Integer> getMaxRetries()
maximum number of retry attempts for failed downloads (default: 3).
-
getRetryDelayMs
abstract Property<Long> getRetryDelayMs()
initial delay between retries in milliseconds (default: 1000ms).
-
naming
final Unit naming(Action<NamingConfig> action)
Configure icon naming transformation.
Example:
naming { pascalCase(suffix = "Icon") // Preset // Or customize: namingConvention.set(NamingConvention.PASCAL_CASE) suffix.set("Icon") removePrefix.set("ic_") }- Parameters:
action- Configuration action for NamingConfig
-
iconConfig
final Unit iconConfig(String name, IconConfig config)
Generic method to add an icon with any IconConfig implementation.
This method supports both built-in and user-defined icon libraries.
Example:
iconConfig("home", MaterialSymbolsConfig(weight = SymbolWeight.W400)) iconConfig("custom", MyCustomIconConfig(style = "filled"))- Parameters:
name- Icon nameconfig- IconConfig implementation
-
iconConfigs
final Unit iconConfigs(String names, Function1<String, IconConfig> configFactory)
Batch configure multiple icons with the same configuration.
- Parameters:
names- Icon namesconfigFactory- Factory function that creates IconConfig for each icon name
-
materialSymbol
final Unit materialSymbol(String name, Function1<MaterialSymbolsBuilder, Unit> configure)
Configure Material Symbols icons with DSL builder.
Example:
materialSymbol("home") { weights(400, 500, 700) variant = SymbolVariant.OUTLINED }- Parameters:
name- Material Symbol icon nameconfigure- Configuration block
-
materialSymbols
final Unit materialSymbols(String names, Function1<MaterialSymbolsBuilder, Unit> configure)
Convenience overload for configuring multiple Material Symbols with the same style block.
- Parameters:
names- Material Symbol icon namesconfigure- Configuration block applied to each icon
-
externalIcon
final Unit externalIcon(String name, String libraryName, Function1<ExternalIconBuilder, Unit> configure)
Configure external icon from other icon libraries with URL template.
The URL template supports the following placeholders:
{name}: Replaced with the icon name{key}: Replaced with custom style parameter values
Examples:
// Simple icon URL externalIcon("bell", libraryName = "bootstrap-icons") { urlTemplate = "https://esm.sh/bootstrap-icons/fill/{name}.svg" } // With custom style parameters externalIcon("home", libraryName = "heroicons") { urlTemplate = "https://cdn.jsdelivr.net/npm/heroicons/{size}/{name}.svg" styleParam("size", "24") } // Multi-value style parameters for variants externalIcon("home", libraryName = "official") { urlTemplate = "https://example.com/{name}_{fill}_24px.svg" styleParam("fill") { values("", "fill1") // unfilled, filled variants } } // Custom CDN externalIcon("my-icon", libraryName = "mylib") { urlTemplate = "https://my-cdn.com/icons/{name}.svg" }- Parameters:
name- Icon name (replaces {name} in URL template)libraryName- Library identifier (used for cache isolation)configure- Configuration block
-
externalIcons
final Unit externalIcons(String names, String libraryName, Function1<ExternalIconBuilder, Unit> configure)
Convenience overload for configuring multiple external icons from the same library.
All icons will share the same URL template and style parameters.
Examples:
// Multiple icons from Bootstrap Icons externalIcons("bell", "house", "person", libraryName = "bootstrap-icons") { urlTemplate = "https://esm.sh/bootstrap-icons/fill/{name}.svg" } // Multiple icons with style parameters externalIcons("home", "search", "user", libraryName = "heroicons") { urlTemplate = "https://cdn.jsdelivr.net/npm/heroicons/{size}/{name}.svg" styleParam("size", "24") } // Multi-value style parameters for variants externalIcons("home", "search", "settings", libraryName = "official") { urlTemplate = "https://example.com/{name}_{fill}_24px.svg" styleParam("fill") { values("", "fill1") // unfilled, filled variants } }- Parameters:
names- Icon names to configurelibraryName- Library identifier shared by all iconsconfigure- Configuration block applied to each icon
-
getIconsConfig
final Map<String, List<IconConfig>> getIconsConfig()
Returns an immutable snapshot of all icon requests declared via the DSL.
-
getConfigHash
final String getConfigHash()
Computes a deterministic hash for the current configuration.
The hash is used to decide whether
generateSymbolCraftIconscan reuse cached outputs.
-
-
-
-