Skip to content

Commit

Permalink
rename op parameters to configure
Browse files Browse the repository at this point in the history
  • Loading branch information
jpenilla committed Mar 23, 2024
1 parent 22f993d commit 5eaa930
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,43 +24,43 @@ abstract class ResourceFactoryExtension @Inject constructor(
) {
abstract val factories: ListProperty<ResourceFactory>

fun paperPluginYml(op: Action<PaperPluginYml>): PaperPluginYml {
val config = project.paperPluginYml(op)
fun paperPluginYml(configure: Action<PaperPluginYml>): PaperPluginYml {
val config = project.paperPluginYml(configure)
factory(config.resourceFactory())
return config
}

fun bukkitPluginYml(op: Action<BukkitPluginYml>): BukkitPluginYml {
val config = project.bukkitPluginYml(op)
fun bukkitPluginYml(configure: Action<BukkitPluginYml>): BukkitPluginYml {
val config = project.bukkitPluginYml(configure)
factory(config.resourceFactory())
return config
}

fun velocityPluginJson(op: Action<VelocityPluginJson>): VelocityPluginJson {
val config = project.velocityPluginJson(op)
fun velocityPluginJson(configure: Action<VelocityPluginJson>): VelocityPluginJson {
val config = project.velocityPluginJson(configure)
factory(config.resourceFactory())
return config
}

fun fabricModJson(op: Action<FabricModJson>): FabricModJson {
val config = project.fabricModJson(op)
fun fabricModJson(configure: Action<FabricModJson>): FabricModJson {
val config = project.fabricModJson(configure)
factory(config.resourceFactory())
return config
}

fun bungeePluginYml(op: Action<BungeePluginYml>): BungeePluginYml {
val config = project.bungeePluginYml(op)
fun bungeePluginYml(configure: Action<BungeePluginYml>): BungeePluginYml {
val config = project.bungeePluginYml(configure)
factory(config.resourceFactory())
return config
}

fun <T : ResourceFactory> factory(
generatorType: KClass<T>,
vararg params: Any,
op: Action<T>
configure: Action<T>
): T {
val o = objects.newInstance(generatorType, *params)
op.execute(o)
configure.execute(o)
factory(o)
return o
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ import xyz.jpenilla.resourcefactory.util.nullAction
import xyz.jpenilla.resourcefactory.util.nullIfEmpty
import java.nio.file.Path

fun Project.bukkitPluginYml(op: Action<BukkitPluginYml> = nullAction()): BukkitPluginYml {
fun Project.bukkitPluginYml(configure: Action<BukkitPluginYml> = nullAction()): BukkitPluginYml {
val yml = BukkitPluginYml(objects)
yml.copyProjectMeta(this)
op.execute(yml)
configure.execute(yml)
return yml
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ import xyz.jpenilla.resourcefactory.util.nullAction
import xyz.jpenilla.resourcefactory.util.nullIfEmpty
import java.nio.file.Path

fun Project.bungeePluginYml(op: Action<BungeePluginYml> = nullAction()): BungeePluginYml {
fun Project.bungeePluginYml(configure: Action<BungeePluginYml> = nullAction()): BungeePluginYml {
val yml = BungeePluginYml(objects)
yml.copyProjectMeta(this)
op.execute(yml)
configure.execute(yml)
return yml
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ import java.lang.reflect.Type
import java.nio.file.Path
import javax.inject.Inject

fun Project.fabricModJson(op: Action<FabricModJson> = nullAction()): FabricModJson {
fun Project.fabricModJson(configure: Action<FabricModJson> = nullAction()): FabricModJson {
val yml = FabricModJson(objects)
yml.copyProjectMeta(this)
op.execute(yml)
configure.execute(yml)
return yml
}

Expand All @@ -52,20 +52,20 @@ open class FabricModJson constructor(
@get:Nested
val entrypoints: ListProperty<Entrypoint> = objects.listProperty()

fun mainEntrypoint(value: String, op: Action<Entrypoint> = nullAction()) =
entrypoint("main", value, op)
fun mainEntrypoint(value: String, configure: Action<Entrypoint> = nullAction()) =
entrypoint("main", value, configure)

fun clientEntrypoint(value: String, op: Action<Entrypoint> = nullAction()) =
entrypoint("client", value, op)
fun clientEntrypoint(value: String, configure: Action<Entrypoint> = nullAction()) =
entrypoint("client", value, configure)

fun serverEntrypoint(value: String, op: Action<Entrypoint> = nullAction()) =
entrypoint("server", value, op)
fun serverEntrypoint(value: String, configure: Action<Entrypoint> = nullAction()) =
entrypoint("server", value, configure)

fun entrypoint(type: String, value: String, op: Action<Entrypoint> = nullAction()): Entrypoint {
fun entrypoint(type: String, value: String, configure: Action<Entrypoint> = nullAction()): Entrypoint {
val ep = objects.newInstance(Entrypoint::class)
ep.type.set(type)
ep.value.set(value)
op.execute(ep)
configure.execute(ep)
entrypoints.add(ep)
return ep
}
Expand All @@ -76,10 +76,10 @@ open class FabricModJson constructor(
@get:Nested
val mixins: ListProperty<MixinConfig> = objects.listProperty()

fun mixin(name: String, op: Action<MixinConfig> = nullAction()): MixinConfig {
fun mixin(name: String, configure: Action<MixinConfig> = nullAction()): MixinConfig {
val mixin = objects.newInstance(MixinConfig::class)
mixin.config.set(name)
op.execute(mixin)
configure.execute(mixin)
mixins.add(mixin)
return mixin
}
Expand Down Expand Up @@ -124,17 +124,17 @@ open class FabricModJson constructor(
@get:Nested
val authors: ListProperty<Person> = objects.listProperty()

fun author(name: String, op: Action<Person> = nullAction()) = authors.add(person(name, op))
fun author(name: String, configure: Action<Person> = nullAction()) = authors.add(person(name, configure))

@get:Nested
val contributors: ListProperty<Person> = objects.listProperty()

fun contributor(name: String, op: Action<Person> = nullAction()) = contributors.add(person(name, op))
fun contributor(name: String, configure: Action<Person> = nullAction()) = contributors.add(person(name, configure))

@get:Nested
val contact: ContactInformation = objects.newInstance()

fun contact(op: Action<ContactInformation>) = contact.apply { op.execute(this) }
fun contact(configure: Action<ContactInformation>) = contact.apply { configure.execute(this) }

@get:Input
val license: ListProperty<String> = objects.listProperty()
Expand Down Expand Up @@ -191,9 +191,9 @@ open class FabricModJson constructor(
val icons: Map<String, String>
) : Icon

fun person(name: String, op: Action<Person> = nullAction()): Person = objects.newInstance<Person>().apply {
fun person(name: String, configure: Action<Person> = nullAction()): Person = objects.newInstance<Person>().apply {
this.name.set(name)
op.execute(this)
configure.execute(this)
}

abstract class Person @Inject constructor(objects: ObjectFactory) {
Expand All @@ -203,7 +203,7 @@ open class FabricModJson constructor(
@get:Nested
val contact: ContactInformation = objects.newInstance()

fun contact(op: Action<ContactInformation>) = contact.apply { op.execute(this) }
fun contact(configure: Action<ContactInformation>) = contact.apply { configure.execute(this) }
}

abstract class ContactInformation {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ import xyz.jpenilla.resourcefactory.util.nullIfEmpty
import java.nio.file.Path
import javax.inject.Inject

fun Project.paperPluginYml(op: Action<PaperPluginYml> = nullAction()): PaperPluginYml {
fun Project.paperPluginYml(configure: Action<PaperPluginYml> = nullAction()): PaperPluginYml {
val yml = PaperPluginYml(objects)
yml.copyProjectMeta(this)
op.execute(yml)
configure.execute(yml)
return yml
}

Expand Down Expand Up @@ -92,8 +92,8 @@ class PaperPluginYml constructor(
@get:Nested
val permissions: NamedDomainObjectContainer<Permission> = objects.domainObjectContainer(Permission::class) { Permission(it) }

fun dependencies(op: Action<Dependencies>) {
op.execute(dependencies)
fun dependencies(configure: Action<Dependencies>) {
configure.execute(dependencies)
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ import xyz.jpenilla.resourcefactory.util.nullAction
import xyz.jpenilla.resourcefactory.util.nullIfEmpty
import java.nio.file.Path

fun Project.velocityPluginJson(op: Action<VelocityPluginJson> = nullAction()): VelocityPluginJson {
fun Project.velocityPluginJson(configure: Action<VelocityPluginJson> = nullAction()): VelocityPluginJson {
val yml = VelocityPluginJson(objects)
yml.copyProjectMeta(this)
op.execute(yml)
configure.execute(yml)
return yml
}

Expand Down

0 comments on commit 5eaa930

Please sign in to comment.