Skip to content

Commit

Permalink
Add FabricModJson factory
Browse files Browse the repository at this point in the history
  • Loading branch information
jpenilla committed Mar 22, 2024
1 parent 7e31f6d commit c0afffb
Show file tree
Hide file tree
Showing 5 changed files with 362 additions and 4 deletions.
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,16 @@ Gradle plugin for generating resource files at build time.

- PaperPluginYml
- BukkitPluginYml
- FabricModJson

The included factories can be created in two ways.
PaperPluginYml is used as an example, but the process is the same for the other included factories.

Bukkit and Paper plugin YMLs can be created in two ways:
1) Directly on the project instance, and then registered manually
```kotlin
import xyz.jpenilla.resourcefactory.(bukkit|paper).(bukkit|paper)PluginYml
import xyz.jpenilla.resourcefactory.paper.paperPluginYml

val yml = (bukkit|paper)PluginYml {
val yml = paperPluginYml {
// Defaults for name, version, and description are inherited from the Gradle project
main = "main.class.Name"
authors.add("MyName")
Expand All @@ -52,7 +55,7 @@ Bukkit and Paper plugin YMLs can be created in two ways:
```kotlin
sourceSets.main {
resourceFactory {
(bukkit|paper)PluginYml {
paperPluginYml {
// Defaults for name, version, and description are inherited from the Gradle project
main = "main.class.Name"
authors.add("MyName")
Expand Down
1 change: 1 addition & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ configurate = "4.1.2"

[libraries]
configurateYaml = { group = "org.spongepowered", name = "configurate-yaml", version.ref = "configurate" }
configurateGson = { group = "org.spongepowered", name = "configurate-gson", version.ref = "configurate" }

[bundles]
1 change: 1 addition & 0 deletions plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ repositories {

dependencies {
implementation(libs.configurateYaml)
implementation(libs.configurateGson)
}

kotlin {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import org.gradle.api.provider.ListProperty
import org.gradle.kotlin.dsl.newInstance
import xyz.jpenilla.resourcefactory.bukkit.BukkitPluginYml
import xyz.jpenilla.resourcefactory.bukkit.bukkitPluginYml
import xyz.jpenilla.resourcefactory.fabric.FabricModJson
import xyz.jpenilla.resourcefactory.fabric.fabricModJson
import xyz.jpenilla.resourcefactory.paper.PaperPluginYml
import xyz.jpenilla.resourcefactory.paper.paperPluginYml
import javax.inject.Inject
Expand All @@ -29,6 +31,12 @@ abstract class ResourceFactoryExtension @Inject constructor(
return config
}

fun fabricModJson(op: FabricModJson.() -> Unit): FabricModJson {
val config = project.fabricModJson(op)
factory(config.resourceFactory())
return config
}

fun <T : ResourceFactory> factory(
generatorType: KClass<T>,
vararg params: Any,
Expand Down
Loading

0 comments on commit c0afffb

Please sign in to comment.