Skip to content

jpenilla/resource-factory

Repository files navigation

Resource Factory Gradle Plugin

build license latest release

Gradle plugin for generating resource files at build time.

Usage

  1. Apply the plugin
    plugins {
      // Apply the plugin
      id("xyz.jpenilla.resource-factory") version "VERSION"
    }
  2. Add resource factories to the desired source sets
    // for example, the 'main' source set
    sourceSets.main {
      resourceFactory {
        factories(/* ... */)
      }
    }

Included factories

Type Convention Plugin
PaperPluginYaml xyz.jpenilla.resource-factory-paper-convention
BukkitPluginYaml xyz.jpenilla.resource-factory-bukkit-convention
VelocityPluginJson xyz.jpenilla.resource-factory-velocity-convention
FabricModJson xyz.jpenilla.resource-factory-fabric-convention
BungeeCordPluginYaml xyz.jpenilla.resource-factory-bungee-convention

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

Convention Plugins

The provided convention plugins can be applied in addition to or instead of the base xyz.jpenilla.resource-factory plugin. These conventions behave the same as the below manual examples, however they also register an extension for the resource object. This allows simplifying use to the following:

plugins {
  // Apply the convention plugin
  id("xyz.jpenilla.resource-factory-paper-convention") version "VERSION"
}

paperPluginYaml {
  // Defaults for name, version, and description are inherited from the Gradle project
  main = "main.class.Name"
  authors.add("MyName")
  // configure fields...
}

Manually

The included factories can be used manually in two ways.

  1. Directly on the project instance, and then registered manually
    import xyz.jpenilla.resourcefactory.paper.paperPluginYaml
    
    val yaml = paperPluginYaml {
      // Defaults for name, version, and description are inherited from the Gradle project
      main = "main.class.Name"
      authors.add("MyName")
      // configure fields...
    }
    
    sourceSets.main {
      resourceFactory {
        factory(yaml.resourceFactory())
      }
    }
  2. From within the resource factory extension
    sourceSets.main {
      resourceFactory {
        paperPluginYaml {
          // Defaults for name, version, and description are inherited from the Gradle project
          main = "main.class.Name"
          authors.add("MyName")
          // configure fields...
        }
      }
    }