Skip to content

Commit e6e8e34

Browse files
authored
chore: yml -> yaml (#10)
1 parent 763d27c commit e6e8e34

13 files changed

Lines changed: 130 additions & 125 deletions

File tree

README.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,16 @@ Gradle plugin for generating resource files at build time.
2727

2828
## Included factories
2929

30-
| Type | Convention Plugin |
31-
|--------------------|-----------------------------------------------------|
32-
| PaperPluginYml | `xyz.jpenilla.resource-factory-paper-convention` |
33-
| BukkitPluginYml | `xyz.jpenilla.resource-factory-bukkit-convention` |
34-
| VelocityPluginJson | `xyz.jpenilla.resource-factory-velocity-convention` |
35-
| FabricModJson | `xyz.jpenilla.resource-factory-fabric-convention` |
36-
| BungeePluginYml | `xyz.jpenilla.resource-factory-bungee-convention` |
30+
| Type | Convention Plugin |
31+
|----------------------|-----------------------------------------------------|
32+
| PaperPluginYaml | `xyz.jpenilla.resource-factory-paper-convention` |
33+
| BukkitPluginYaml | `xyz.jpenilla.resource-factory-bukkit-convention` |
34+
| VelocityPluginJson | `xyz.jpenilla.resource-factory-velocity-convention` |
35+
| FabricModJson | `xyz.jpenilla.resource-factory-fabric-convention` |
36+
| BungeeCordPluginYaml | `xyz.jpenilla.resource-factory-bungee-convention` |
3737

3838
The included factories can be used in two ways.
39-
PaperPluginYml is used as an example, but the process is the same for the other included factories.
39+
PaperPluginYaml is used as an example, but the process is the same for the other included factories.
4040

4141
### Convention Plugins
4242

@@ -52,7 +52,7 @@ plugins {
5252
id("xyz.jpenilla.resource-factory-paper-convention") version "VERSION"
5353
}
5454

55-
paperPluginYml {
55+
paperPluginYaml {
5656
// Defaults for name, version, and description are inherited from the Gradle project
5757
main = "main.class.Name"
5858
authors.add("MyName")
@@ -66,9 +66,9 @@ The included factories can be used manually in two ways.
6666

6767
1) Directly on the project instance, and then registered manually
6868
```kotlin
69-
import xyz.jpenilla.resourcefactory.paper.paperPluginYml
69+
import xyz.jpenilla.resourcefactory.paper.paperPluginYaml
7070

71-
val yml = paperPluginYml {
71+
val yaml = paperPluginYaml {
7272
// Defaults for name, version, and description are inherited from the Gradle project
7373
main = "main.class.Name"
7474
authors.add("MyName")
@@ -77,15 +77,15 @@ The included factories can be used manually in two ways.
7777

7878
sourceSets.main {
7979
resourceFactory {
80-
factory(yml.resourceFactory())
80+
factory(yaml.resourceFactory())
8181
}
8282
}
8383
```
8484
2) From within the resource factory extension
8585
```kotlin
8686
sourceSets.main {
8787
resourceFactory {
88-
paperPluginYml {
88+
paperPluginYaml {
8989
// Defaults for name, version, and description are inherited from the Gradle project
9090
main = "main.class.Name"
9191
authors.add("MyName")

plugin/build.gradle.kts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,21 +96,21 @@ indraPluginPublishing {
9696
"resource-factory-paper-convention",
9797
"xyz.jpenilla.resourcefactory.paper.PaperConvention",
9898
"Resource Factory Paper Convention",
99-
"Convention for xyz.jpenilla.resource-factory, registers a PaperPluginYml to the main source set and adds it as the paperPluginYml extension",
99+
"Convention for xyz.jpenilla.resource-factory, registers a PaperPluginYaml to the main source set and adds it as the paperPluginYaml extension",
100100
tags("paper")
101101
)
102102
plugin(
103103
"resource-factory-bukkit-convention",
104104
"xyz.jpenilla.resourcefactory.bukkit.BukkitConvention",
105105
"Resource Factory Bukkit Convention",
106-
"Convention for xyz.jpenilla.resource-factory, registers a BukkitPluginYml to the main source set and adds it as the bukkitPluginYml extension",
106+
"Convention for xyz.jpenilla.resource-factory, registers a BukkitPluginYaml to the main source set and adds it as the bukkitPluginYaml extension",
107107
tags("bukkit")
108108
)
109109
plugin(
110110
"resource-factory-bungee-convention",
111-
"xyz.jpenilla.resourcefactory.bungee.BungeeConvention",
112-
"Resource Factory Bungee Convention",
113-
"Convention for xyz.jpenilla.resource-factory, registers a BungeePluginYml to the main source set and adds it as the bungeePluginYml extension",
111+
"xyz.jpenilla.resourcefactory.bungeecord.BungeeCordConvention",
112+
"Resource Factory BungeeCord Convention",
113+
"Convention for xyz.jpenilla.resource-factory, registers a BungeeCordPluginYaml to the main source set and adds it as the bungeePluginYaml extension",
114114
tags("bungee", "bungeecord")
115115
)
116116
plugin(

plugin/src/main/kotlin/xyz/jpenilla/resourcefactory/ResourceFactoryExtension.kt

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ import org.gradle.api.Project
55
import org.gradle.api.model.ObjectFactory
66
import org.gradle.api.provider.ListProperty
77
import org.gradle.kotlin.dsl.newInstance
8-
import xyz.jpenilla.resourcefactory.bukkit.BukkitPluginYml
9-
import xyz.jpenilla.resourcefactory.bukkit.bukkitPluginYml
10-
import xyz.jpenilla.resourcefactory.bungee.BungeePluginYml
11-
import xyz.jpenilla.resourcefactory.bungee.bungeePluginYml
8+
import xyz.jpenilla.resourcefactory.bukkit.BukkitPluginYaml
9+
import xyz.jpenilla.resourcefactory.bukkit.bukkitPluginYaml
10+
import xyz.jpenilla.resourcefactory.bungeecord.BungeeCordPluginYaml
11+
import xyz.jpenilla.resourcefactory.bungeecord.bungeePluginYaml
1212
import xyz.jpenilla.resourcefactory.fabric.FabricModJson
1313
import xyz.jpenilla.resourcefactory.fabric.fabricModJson
14-
import xyz.jpenilla.resourcefactory.paper.PaperPluginYml
15-
import xyz.jpenilla.resourcefactory.paper.paperPluginYml
14+
import xyz.jpenilla.resourcefactory.paper.PaperPluginYaml
15+
import xyz.jpenilla.resourcefactory.paper.paperPluginYaml
1616
import xyz.jpenilla.resourcefactory.velocity.VelocityPluginJson
1717
import xyz.jpenilla.resourcefactory.velocity.velocityPluginJson
1818
import javax.inject.Inject
@@ -24,14 +24,14 @@ abstract class ResourceFactoryExtension @Inject constructor(
2424
) {
2525
abstract val factories: ListProperty<ResourceFactory>
2626

27-
fun paperPluginYml(configure: Action<PaperPluginYml>): PaperPluginYml {
28-
val config = project.paperPluginYml(configure)
27+
fun paperPluginYaml(configure: Action<PaperPluginYaml>): PaperPluginYaml {
28+
val config = project.paperPluginYaml(configure)
2929
factory(config.resourceFactory())
3030
return config
3131
}
3232

33-
fun bukkitPluginYml(configure: Action<BukkitPluginYml>): BukkitPluginYml {
34-
val config = project.bukkitPluginYml(configure)
33+
fun bukkitPluginYaml(configure: Action<BukkitPluginYaml>): BukkitPluginYaml {
34+
val config = project.bukkitPluginYaml(configure)
3535
factory(config.resourceFactory())
3636
return config
3737
}
@@ -48,8 +48,8 @@ abstract class ResourceFactoryExtension @Inject constructor(
4848
return config
4949
}
5050

51-
fun bungeePluginYml(configure: Action<BungeePluginYml>): BungeePluginYml {
52-
val config = project.bungeePluginYml(configure)
51+
fun bungeePluginYaml(configure: Action<BungeeCordPluginYaml>): BungeeCordPluginYaml {
52+
val config = project.bungeePluginYaml(configure)
5353
factory(config.resourceFactory())
5454
return config
5555
}

plugin/src/main/kotlin/xyz/jpenilla/resourcefactory/bukkit/BukkitConvention.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package xyz.jpenilla.resourcefactory.bukkit
22

33
import xyz.jpenilla.resourcefactory.ResourceFactoryConventionPlugin
44

5-
abstract class BukkitConvention : ResourceFactoryConventionPlugin.Provider<BukkitPluginYml>(
6-
"bukkitPluginYml",
7-
{ project -> project.bukkitPluginYml() }
5+
abstract class BukkitConvention : ResourceFactoryConventionPlugin.Provider<BukkitPluginYaml>(
6+
"bukkitPluginYaml",
7+
{ project -> project.bukkitPluginYaml() }
88
)

plugin/src/main/kotlin/xyz/jpenilla/resourcefactory/bukkit/BukkitPluginYml.kt renamed to plugin/src/main/kotlin/xyz/jpenilla/resourcefactory/bukkit/BukkitPluginYaml.kt

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,21 @@ import xyz.jpenilla.resourcefactory.util.nullAction
2323
import xyz.jpenilla.resourcefactory.util.nullIfEmpty
2424
import xyz.jpenilla.resourcefactory.util.validateAll
2525

26-
fun Project.bukkitPluginYml(configure: Action<BukkitPluginYml> = nullAction()): BukkitPluginYml {
27-
val yml = BukkitPluginYml(objects)
28-
yml.setConventionsFromProjectMeta(this)
29-
configure.execute(yml)
30-
return yml
26+
fun Project.bukkitPluginYaml(configure: Action<BukkitPluginYaml> = nullAction()): BukkitPluginYaml {
27+
val yaml = BukkitPluginYaml(objects)
28+
yaml.setConventionsFromProjectMeta(this)
29+
configure.execute(yaml)
30+
return yaml
3131
}
3232

33-
class BukkitPluginYml(
33+
class BukkitPluginYaml(
3434
@Transient
3535
private val objects: ObjectFactory
3636
) : ConfigurateSingleFileResourceFactory.ObjectMapper.ValueProvider, ProjectMetaConventions, ResourceFactory.Provider {
3737

3838
companion object {
3939
private const val PLUGIN_NAME_PATTERN: String = "^[A-Za-z0-9_\\.-]+$"
40+
private const val FILE_NAME: String = "plugin.yml"
4041
}
4142

4243
@get:Input
@@ -163,7 +164,7 @@ class BukkitPluginYml(
163164
}
164165
}.nodeStyle(NodeStyle.BLOCK)
165166
}
166-
gen.path.set("plugin.yml")
167+
gen.path.set(FILE_NAME)
167168
gen.value.set(this)
168169
return gen
169170
}
@@ -173,25 +174,25 @@ class BukkitPluginYml(
173174
}
174175

175176
@ConfigSerializable
176-
class Serializable(yml: BukkitPluginYml) {
177-
val apiVersion = yml.apiVersion.orNull
178-
val name = yml::name.getValidating()
179-
val version = yml.version.get()
180-
val main = yml::main.getValidating()
181-
val description = yml.description.orNull
182-
val load = yml.load.orNull
183-
val author = yml.author.orNull
184-
val authors = yml.authors.nullIfEmpty()
185-
val website = yml.website.orNull
186-
val depend = yml.depend.nullIfEmpty()?.validateAll(PLUGIN_NAME_PATTERN, "Bukkit plugin name (of depend)")
187-
val softDepend = yml.softDepend.nullIfEmpty()?.validateAll(PLUGIN_NAME_PATTERN, "Bukkit plugin name (of softDepend)")
188-
val loadBefore = yml.loadBefore.nullIfEmpty()?.validateAll(PLUGIN_NAME_PATTERN, "Bukkit plugin name (of loadBefore)")
189-
val prefix = yml.prefix.orNull
190-
val defaultPermission = yml.defaultPermission.orNull
191-
val provides = yml.provides.nullIfEmpty()
192-
val libraries = yml.libraries.nullIfEmpty()
193-
val commands = yml.commands.nullIfEmpty()
194-
val permissions = yml.permissions.nullIfEmpty()?.mapValues { Permission.Serializable(it.value) }
195-
val foliaSupported = yml.foliaSupported.orNull
177+
class Serializable(yaml: BukkitPluginYaml) {
178+
val apiVersion = yaml.apiVersion.orNull
179+
val name = yaml::name.getValidating()
180+
val version = yaml.version.get()
181+
val main = yaml::main.getValidating()
182+
val description = yaml.description.orNull
183+
val load = yaml.load.orNull
184+
val author = yaml.author.orNull
185+
val authors = yaml.authors.nullIfEmpty()
186+
val website = yaml.website.orNull
187+
val depend = yaml.depend.nullIfEmpty()?.validateAll(PLUGIN_NAME_PATTERN, "Bukkit plugin name (of depend)")
188+
val softDepend = yaml.softDepend.nullIfEmpty()?.validateAll(PLUGIN_NAME_PATTERN, "Bukkit plugin name (of softDepend)")
189+
val loadBefore = yaml.loadBefore.nullIfEmpty()?.validateAll(PLUGIN_NAME_PATTERN, "Bukkit plugin name (of loadBefore)")
190+
val prefix = yaml.prefix.orNull
191+
val defaultPermission = yaml.defaultPermission.orNull
192+
val provides = yaml.provides.nullIfEmpty()
193+
val libraries = yaml.libraries.nullIfEmpty()
194+
val commands = yaml.commands.nullIfEmpty()
195+
val permissions = yaml.permissions.nullIfEmpty()?.mapValues { Permission.Serializable(it.value) }
196+
val foliaSupported = yaml.foliaSupported.orNull
196197
}
197198
}

plugin/src/main/kotlin/xyz/jpenilla/resourcefactory/bungee/BungeeConvention.kt

Lines changed: 0 additions & 8 deletions
This file was deleted.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package xyz.jpenilla.resourcefactory.bungeecord
2+
3+
import xyz.jpenilla.resourcefactory.ResourceFactoryConventionPlugin
4+
5+
abstract class BungeeCordConvention : ResourceFactoryConventionPlugin.Provider<BungeeCordPluginYaml>(
6+
"bungeePluginYaml",
7+
{ project -> project.bungeePluginYaml() }
8+
)

plugin/src/main/kotlin/xyz/jpenilla/resourcefactory/bungee/BungeePluginYml.kt renamed to plugin/src/main/kotlin/xyz/jpenilla/resourcefactory/bungeecord/BungeeCordPluginYaml.kt

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package xyz.jpenilla.resourcefactory.bungee
1+
package xyz.jpenilla.resourcefactory.bungeecord
22

33
import org.gradle.api.Action
44
import org.gradle.api.Project
@@ -21,23 +21,24 @@ import xyz.jpenilla.resourcefactory.util.nullAction
2121
import xyz.jpenilla.resourcefactory.util.nullIfEmpty
2222
import xyz.jpenilla.resourcefactory.util.validateAll
2323

24-
fun Project.bungeePluginYml(configure: Action<BungeePluginYml> = nullAction()): BungeePluginYml {
25-
val yml = BungeePluginYml(objects)
26-
yml.setConventionsFromProjectMeta(this)
27-
configure.execute(yml)
28-
return yml
24+
fun Project.bungeePluginYaml(configure: Action<BungeeCordPluginYaml> = nullAction()): BungeeCordPluginYaml {
25+
val yaml = BungeeCordPluginYaml(objects)
26+
yaml.setConventionsFromProjectMeta(this)
27+
configure.execute(yaml)
28+
return yaml
2929
}
3030

31-
class BungeePluginYml constructor(
31+
class BungeeCordPluginYaml constructor(
3232
@Transient
3333
private val objects: ObjectFactory
3434
) : ConfigurateSingleFileResourceFactory.ObjectMapper.ValueProvider, ProjectMetaConventions, ResourceFactory.Provider {
3535

3636
companion object {
3737
private const val PLUGIN_NAME_PATTERN: String = "^[A-Za-z0-9_\\.-]+$"
38+
private const val FILE_NAME: String = "bungee.yml"
3839
}
3940

40-
@Pattern(PLUGIN_NAME_PATTERN, "Bungee plugin name")
41+
@Pattern(PLUGIN_NAME_PATTERN, "BungeeCord plugin name")
4142
@get:Input
4243
val name: Property<String> = objects.property()
4344

@@ -75,19 +76,19 @@ class BungeePluginYml constructor(
7576
override fun resourceFactory(): ResourceFactory {
7677
val factory = objects.newInstance(ConfigurateSingleFileResourceFactory.ObjectMapper::class)
7778
factory.yaml { nodeStyle(NodeStyle.BLOCK) }
78-
factory.path.set("bungee.yml")
79+
factory.path.set(FILE_NAME)
7980
factory.value.set(this)
8081
return factory
8182
}
8283

8384
@ConfigSerializable
84-
class Serializable(yml: BungeePluginYml) {
85-
val name = yml::name.getValidating()
86-
val main = yml.main.get()
87-
val version = yml.version.orNull
88-
val author = yml.author.orNull
89-
val depends = yml.depends.nullIfEmpty()?.validateAll(PLUGIN_NAME_PATTERN, "Bungee plugin name (of dependency)")
90-
val softDepends = yml.softDepends.nullIfEmpty()?.validateAll(PLUGIN_NAME_PATTERN, "Bungee plugin name (of soft dependency)")
91-
val description = yml.description.orNull
85+
class Serializable(yaml: BungeeCordPluginYaml) {
86+
val name = yaml::name.getValidating()
87+
val main = yaml.main.get()
88+
val version = yaml.version.orNull
89+
val author = yaml.author.orNull
90+
val depends = yaml.depends.nullIfEmpty()?.validateAll(PLUGIN_NAME_PATTERN, "BungeeCord plugin name (of dependency)")
91+
val softDepends = yaml.softDepends.nullIfEmpty()?.validateAll(PLUGIN_NAME_PATTERN, "BungeeCord plugin name (of soft dependency)")
92+
val description = yaml.description.orNull
9293
}
9394
}

plugin/src/main/kotlin/xyz/jpenilla/resourcefactory/fabric/FabricModJson.kt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ import java.lang.reflect.Type
3030
import javax.inject.Inject
3131

3232
fun Project.fabricModJson(configure: Action<FabricModJson> = nullAction()): FabricModJson {
33-
val yml = FabricModJson(objects)
34-
yml.setConventionsFromProjectMeta(this)
35-
configure.execute(yml)
36-
return yml
33+
val json = FabricModJson(objects)
34+
json.setConventionsFromProjectMeta(this)
35+
configure.execute(json)
36+
return json
3737
}
3838

3939
open class FabricModJson constructor(
@@ -43,6 +43,7 @@ open class FabricModJson constructor(
4343

4444
companion object {
4545
private const val MOD_ID_PATTERN: String = "^[a-z][a-z0-9-_]{1,63}$"
46+
private const val FILE_NAME: String = "fabric.mod.json"
4647
}
4748

4849
@Pattern(MOD_ID_PATTERN, "Fabric mod id")
@@ -285,7 +286,7 @@ open class FabricModJson constructor(
285286
}
286287
}
287288
}
288-
gen.path.set("fabric.mod.json")
289+
gen.path.set(FILE_NAME)
289290
gen.value.set(this)
290291
return gen
291292
}

plugin/src/main/kotlin/xyz/jpenilla/resourcefactory/paper/PaperConvention.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package xyz.jpenilla.resourcefactory.paper
22

33
import xyz.jpenilla.resourcefactory.ResourceFactoryConventionPlugin
44

5-
abstract class PaperConvention : ResourceFactoryConventionPlugin.Provider<PaperPluginYml>(
6-
"paperPluginYml",
7-
{ project -> project.paperPluginYml() }
5+
abstract class PaperConvention : ResourceFactoryConventionPlugin.Provider<PaperPluginYaml>(
6+
"paperPluginYaml",
7+
{ project -> project.paperPluginYaml() }
88
)

0 commit comments

Comments
 (0)