+ update description file generator
This commit is contained in:
parent
170c7e26bf
commit
438eff19da
|
|
@ -1,266 +0,0 @@
|
|||
package io.izzel.taboolib.gradle
|
||||
|
||||
import com.google.gson.GsonBuilder
|
||||
import org.gradle.api.Project
|
||||
import com.google.gson.JsonArray
|
||||
import com.google.gson.JsonObject
|
||||
|
||||
import java.nio.charset.StandardCharsets
|
||||
|
||||
class Description {
|
||||
|
||||
def authors
|
||||
def contributors
|
||||
def depend
|
||||
def softdepend
|
||||
def loadbefore
|
||||
def website
|
||||
def prefix
|
||||
def load
|
||||
def api = "1.0.0"
|
||||
def apiVersion = '1.13'
|
||||
def libraries
|
||||
def dependencies
|
||||
def requiredMods = "spongeapi@7.2.0"
|
||||
def custom = new HashMap<String, Object>()
|
||||
|
||||
static List<String> buildFile() {
|
||||
def str = []
|
||||
str += ""
|
||||
str += ""
|
||||
str += "# Powered by TabooLib 6.0 #"
|
||||
str += ""
|
||||
str += ""
|
||||
return str
|
||||
}
|
||||
|
||||
static def appendName(str, any, key) {
|
||||
if (any != null) {
|
||||
str.add("$key: $any")
|
||||
}
|
||||
}
|
||||
|
||||
static def appendNameList(str, any, key) {
|
||||
if (any instanceof List<String>) {
|
||||
str.add("$key:")
|
||||
for (i in any) {
|
||||
str.add(" - '${i}'")
|
||||
}
|
||||
} else if (any != null) {
|
||||
str.add("$key:")
|
||||
str.add(" - '${any}'")
|
||||
}
|
||||
}
|
||||
|
||||
byte[] buildBukkitFile(Project project) {
|
||||
def str = buildFile()
|
||||
str += "name: ${project.name}"
|
||||
str += "main: ${project.group}.taboolib.platform.BukkitPlugin"
|
||||
appendName(str, load, "load")
|
||||
str += "version: ${project.version}"
|
||||
if (apiVersion != null) {
|
||||
str += "api-version: ${apiVersion}"
|
||||
}
|
||||
appendName(str, prefix, "prefix")
|
||||
appendName(str, website, "website")
|
||||
appendNameList(str, authors, "authors")
|
||||
appendNameList(str, contributors, "contributors")
|
||||
appendNameList(str, depend, "depend")
|
||||
appendNameList(str, softdepend, "softdepend")
|
||||
appendNameList(str, loadbefore, "loadbefore")
|
||||
appendNameList(str, libraries, "libraries")
|
||||
custom.entrySet().each {
|
||||
if (it.value instanceof List) {
|
||||
appendNameList(str, it.value, it.key)
|
||||
} else {
|
||||
appendName(str, it.value, it.key)
|
||||
}
|
||||
}
|
||||
return str.join("\n").getBytes(StandardCharsets.UTF_8)
|
||||
}
|
||||
|
||||
byte[] buildBungeeFile(Project project) {
|
||||
def str = buildFile()
|
||||
str += "name: ${project.name}"
|
||||
str += "main: ${project.group}.taboolib.platform.BungeePlugin"
|
||||
str += "version: ${project.version}"
|
||||
appendName(str, authors, "author")
|
||||
appendNameList(str, depend, "depends")
|
||||
appendNameList(str, softdepend, "softDepends")
|
||||
appendNameList(str, libraries, "libraries")
|
||||
custom.entrySet().each {
|
||||
if (it.value instanceof List) {
|
||||
appendNameList(str, it.value, it.key)
|
||||
} else {
|
||||
appendName(str, it.value, it.key)
|
||||
}
|
||||
}
|
||||
return str.join("\n").getBytes(StandardCharsets.UTF_8)
|
||||
}
|
||||
|
||||
byte[] buildNukkitFile(Project project) {
|
||||
def str = buildFile()
|
||||
str += "name: ${project.name}"
|
||||
str += "main: ${project.group}.taboolib.platform.NukkitPlugin"
|
||||
appendName(str, load, "load")
|
||||
str += "version: ${project.version}"
|
||||
if (api != null) {
|
||||
str += "api: ${api}"
|
||||
}
|
||||
appendName(str, prefix, "prefix")
|
||||
appendName(str, website, "website")
|
||||
appendNameList(str, authors, "authors")
|
||||
appendNameList(str, depend, "depend")
|
||||
appendNameList(str, softdepend, "softdepend")
|
||||
appendNameList(str, loadbefore, "loadbefore")
|
||||
appendNameList(str, libraries, "libraries")
|
||||
custom.entrySet().each {
|
||||
if (it.value instanceof List) {
|
||||
appendNameList(str, it.value, it.key)
|
||||
} else {
|
||||
appendName(str, it.value, it.key)
|
||||
}
|
||||
}
|
||||
return str.join("\n").getBytes(StandardCharsets.UTF_8)
|
||||
}
|
||||
|
||||
byte[] buildSpongeFile(Project project) {
|
||||
def base = new JsonArray()
|
||||
def info = new JsonObject()
|
||||
info.addProperty("modid", project.name.toLowerCase())
|
||||
info.addProperty("name", project.name)
|
||||
info.addProperty("version", project.version.toString())
|
||||
if (website != null) {
|
||||
info.addProperty("url", website.toString())
|
||||
}
|
||||
if (authors instanceof List<String>) {
|
||||
def arr = new JsonArray()
|
||||
authors.each { arr.add(it) }
|
||||
info.add("authorList", arr)
|
||||
} else if (authors != null) {
|
||||
def arr = new JsonArray()
|
||||
arr.add(authors.toString())
|
||||
info.add("authorList", arr)
|
||||
}
|
||||
if (dependencies instanceof List<String>) {
|
||||
def arr = new JsonArray()
|
||||
if (dependencies.none { "spongeapi" in it }) {
|
||||
arr.add("spongeapi@7.2.0")
|
||||
}
|
||||
dependencies.each { arr.add(it) }
|
||||
info.add("dependencies", arr)
|
||||
} else if (dependencies != null) {
|
||||
def arr = new JsonArray()
|
||||
arr.add(dependencies.toString())
|
||||
info.add("dependencies", arr)
|
||||
} else {
|
||||
def arr = new JsonArray()
|
||||
arr.add("spongeapi@7.2.0")
|
||||
info.add("dependencies", arr)
|
||||
}
|
||||
if (requiredMods instanceof List<String>) {
|
||||
def arr = new JsonArray()
|
||||
requiredMods.each { arr.add(it) }
|
||||
info.add("requiredMods", arr)
|
||||
} else if (requiredMods != null) {
|
||||
def arr = new JsonArray()
|
||||
arr.add(requiredMods.toString())
|
||||
info.add("requiredMods", arr)
|
||||
}
|
||||
base.add(info)
|
||||
return new GsonBuilder().setPrettyPrinting().create().toJson(base).getBytes(StandardCharsets.UTF_8)
|
||||
}
|
||||
|
||||
byte[] buildVelocityFile(Project project) {
|
||||
def base = new JsonArray()
|
||||
def info = new JsonObject()
|
||||
info.addProperty("id", project.name.toLowerCase())
|
||||
info.addProperty("name", project.name)
|
||||
info.addProperty("main", "${project.group}.taboolib.platform.VelocityPlugin")
|
||||
info.addProperty("version", project.version.toString())
|
||||
if (authors instanceof List<String>) {
|
||||
def arr = new JsonArray()
|
||||
authors.each { arr.add(it) }
|
||||
info.add("authors", arr)
|
||||
} else if (authors != null) {
|
||||
def arr = new JsonArray()
|
||||
arr.add(authors.toString())
|
||||
info.add("authors", arr)
|
||||
}
|
||||
if (dependencies instanceof List<String>) {
|
||||
def arr = new JsonArray()
|
||||
dependencies.each { arr.add(it) }
|
||||
info.add("dependencies", arr)
|
||||
} else if (dependencies != null) {
|
||||
def arr = new JsonArray()
|
||||
arr.add(dependencies.toString())
|
||||
info.add("dependencies", arr)
|
||||
}
|
||||
base.add(info)
|
||||
return new GsonBuilder().setPrettyPrinting().create().toJson(base).getBytes(StandardCharsets.UTF_8)
|
||||
}
|
||||
|
||||
def author(author) {
|
||||
this.authors = author
|
||||
}
|
||||
|
||||
def contributor(contributor) {
|
||||
this.contributors = contributor
|
||||
}
|
||||
|
||||
def authors(author) {
|
||||
this.authors = author
|
||||
}
|
||||
|
||||
def contributors(contributor) {
|
||||
this.contributors = contributor
|
||||
}
|
||||
|
||||
def depend(depend) {
|
||||
this.depend = depend
|
||||
}
|
||||
|
||||
def softdepend(softdepend) {
|
||||
this.softdepend = softdepend
|
||||
}
|
||||
|
||||
def loadbefore(loadbefore) {
|
||||
this.loadbefore = loadbefore
|
||||
}
|
||||
|
||||
def website(website) {
|
||||
this.website = website
|
||||
}
|
||||
|
||||
def prefix(prefix) {
|
||||
this.prefix = prefix
|
||||
}
|
||||
|
||||
def load(load) {
|
||||
this.load = load
|
||||
}
|
||||
|
||||
def api(api) {
|
||||
this.api = api
|
||||
}
|
||||
|
||||
def apiVersion(apiVersion) {
|
||||
this.apiVersion = apiVersion
|
||||
}
|
||||
|
||||
def libraries(libraries) {
|
||||
this.libraries = libraries
|
||||
}
|
||||
|
||||
def dependencies(dependencies) {
|
||||
this.dependencies = dependencies
|
||||
}
|
||||
|
||||
def requiredMods(requiredMods) {
|
||||
this.requiredMods = requiredMods
|
||||
}
|
||||
|
||||
def custom(String key, value) {
|
||||
this.custom[key] = value
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
package io.izzel.taboolib.gradle
|
||||
|
||||
import groovy.transform.ToString
|
||||
import io.izzel.taboolib.gradle.description.Platforms
|
||||
import org.gradle.api.DefaultTask
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.tasks.Input
|
||||
|
|
@ -112,25 +113,11 @@ class RelocateJar extends DefaultTask {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (tabooExt.modules.contains("platform-bukkit")) {
|
||||
out.putNextEntry(new JarEntry("plugin.yml"))
|
||||
out.write(tabooExt.description.buildBukkitFile(project))
|
||||
Platforms.values().each {
|
||||
if (tabooExt.modules.contains(it.module)) {
|
||||
out.putNextEntry(new JarEntry(it.file))
|
||||
out.write(it.builder.build(tabooExt.des, project))
|
||||
}
|
||||
if (tabooExt.modules.contains("platform-nukkit")) {
|
||||
out.putNextEntry(new JarEntry("nukkit.yml"))
|
||||
out.write(tabooExt.description.buildNukkitFile(project))
|
||||
}
|
||||
if (tabooExt.modules.contains("platform-bungee")) {
|
||||
out.putNextEntry(new JarEntry("bungee.yml"))
|
||||
out.write(tabooExt.description.buildBungeeFile(project))
|
||||
}
|
||||
if (tabooExt.modules.contains("platform-sponge")) {
|
||||
out.putNextEntry(new JarEntry("mcmod.info"))
|
||||
out.write(tabooExt.description.buildSpongeFile(project))
|
||||
}
|
||||
if (tabooExt.modules.contains("platform-velocity")) {
|
||||
out.putNextEntry(new JarEntry("velocity-plugin.json"))
|
||||
out.write(tabooExt.description.buildVelocityFile(project))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
package io.izzel.taboolib.gradle
|
||||
|
||||
import groovy.transform.Canonical
|
||||
import org.codehaus.groovy.runtime.DefaultGroovyMethods
|
||||
import io.izzel.taboolib.gradle.description.Description
|
||||
import org.gradle.api.Action
|
||||
|
||||
@Canonical
|
||||
class TabooLibExtension {
|
||||
|
|
@ -12,7 +13,7 @@ class TabooLibExtension {
|
|||
|
||||
List<String> modules = []
|
||||
|
||||
Description description = new Description()
|
||||
Description des = new Description()
|
||||
|
||||
Map<String, String> relocation = new LinkedHashMap<>()
|
||||
|
||||
|
|
@ -24,7 +25,8 @@ class TabooLibExtension {
|
|||
relocation[pre] = post
|
||||
}
|
||||
|
||||
def descriptionFile(@DelegatesTo(Description.class) Closure<Description> closure) {
|
||||
DefaultGroovyMethods.with(description, closure)
|
||||
def description(closure) {
|
||||
closure.delegate = des
|
||||
closure()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,75 @@
|
|||
package io.izzel.taboolib.gradle.description
|
||||
|
||||
import com.google.gson.GsonBuilder
|
||||
import com.google.gson.JsonArray
|
||||
import com.google.gson.JsonElement
|
||||
import com.google.gson.JsonObject
|
||||
import org.gradle.api.Project
|
||||
|
||||
import java.nio.charset.StandardCharsets
|
||||
|
||||
abstract class Builder {
|
||||
|
||||
abstract byte[] build(Description description, Project project)
|
||||
|
||||
static List<String> startBukkitFile() {
|
||||
def str = []
|
||||
str += ''
|
||||
str += ''
|
||||
str += '# Powered by TabooLib 6.0 #'
|
||||
str += ''
|
||||
str += ''
|
||||
return str
|
||||
}
|
||||
|
||||
static def writeLine(body) {
|
||||
body.add("")
|
||||
}
|
||||
|
||||
static def write(List<String> body, data, key) {
|
||||
if (data != null) {
|
||||
body.add("$key: $data")
|
||||
}
|
||||
}
|
||||
|
||||
static def write(JsonObject body, data, key) {
|
||||
if (data != null) {
|
||||
body.addProperty("$key", "$data")
|
||||
}
|
||||
}
|
||||
|
||||
static def writeList(List<String> body, data, key) {
|
||||
if (data instanceof List<String>) {
|
||||
if (data.size() > 0) {
|
||||
body.add("$key:")
|
||||
for (i in data) {
|
||||
body.add(" - '${i}'")
|
||||
}
|
||||
}
|
||||
} else if (data != null) {
|
||||
body.add("$key:")
|
||||
body.add(" - '${data}'")
|
||||
}
|
||||
}
|
||||
|
||||
static def writeList(JsonObject body, data, key) {
|
||||
def arr = new JsonArray()
|
||||
if (data instanceof List<String>) {
|
||||
if (data.size() > 0) {
|
||||
data.each { arr.add(it) }
|
||||
body.add(key, arr)
|
||||
}
|
||||
} else if (data != null) {
|
||||
arr.add(data.toString())
|
||||
body.add(key, arr)
|
||||
}
|
||||
}
|
||||
|
||||
static byte[] bytes(List<String> body) {
|
||||
return body.join('\n').getBytes(StandardCharsets.UTF_8)
|
||||
}
|
||||
|
||||
static byte[] bytes(JsonElement body) {
|
||||
return new GsonBuilder().setPrettyPrinting().create().toJson(body).getBytes(StandardCharsets.UTF_8)
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
package io.izzel.taboolib.gradle.description
|
||||
|
||||
import org.gradle.api.Project
|
||||
|
||||
class BuilderBukkit extends Builder {
|
||||
|
||||
@Override
|
||||
byte[] build(Description description, Project project) {
|
||||
def body = startBukkitFile()
|
||||
body += "name: ${project.name}"
|
||||
body += "main: ${project.group}.taboolib.platform.BukkitPlugin"
|
||||
body += "version: ${project.version}"
|
||||
write(body, description.lin.links['homepage'], 'website')
|
||||
writeLine(body)
|
||||
// authors
|
||||
def con = description.con.contributors.collect { it.name }
|
||||
writeList(body, con, 'authors')
|
||||
writeLine(body)
|
||||
// dependency
|
||||
writeList(body, description.dep.dependencies
|
||||
.findAll { it.with == null || it.with.equalsIgnoreCase('bukkit') }
|
||||
.findAll { it.forceDepend() }
|
||||
.collect { it.name }, 'depend')
|
||||
writeList(body, description.dep.dependencies
|
||||
.findAll { it.with == null || it.with.equalsIgnoreCase('bukkit') }
|
||||
.findAll { it.optional }
|
||||
.collect { it.name }, 'softdepend')
|
||||
writeList(body, description.dep.dependencies
|
||||
.findAll { it.with == null || it.with.equalsIgnoreCase('bukkit') }
|
||||
.findAll { it.loadbefore }
|
||||
.collect { it.name }, 'loadbefore')
|
||||
writeLine(body)
|
||||
// custom nodes
|
||||
description.bukkitNodes.each {
|
||||
if (it.value instanceof List) {
|
||||
writeList(body, it.value, it.key)
|
||||
} else {
|
||||
write(body, it.value, it.key)
|
||||
}
|
||||
}
|
||||
return bytes(body)
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
package io.izzel.taboolib.gradle.description
|
||||
|
||||
import org.gradle.api.Project
|
||||
|
||||
class BuilderBungee extends Builder {
|
||||
|
||||
@Override
|
||||
byte[] build(Description description, Project project) {
|
||||
def body = startBukkitFile()
|
||||
body += "name: ${project.name}"
|
||||
body += "main: ${project.group}.taboolib.platform.BungeePlugin"
|
||||
body += "version: ${project.version}"
|
||||
write(body, description.lin.links['homepage'], 'website')
|
||||
writeLine(body)
|
||||
// authors
|
||||
def con = description.con.contributors.collect { it.name }
|
||||
writeList(body, con, 'authors')
|
||||
writeLine(body)
|
||||
// dependency
|
||||
writeList(body, description.dep.dependencies
|
||||
.findAll { it.with == null || it.with.equalsIgnoreCase('bungee') }
|
||||
.findAll { it.forceDepend() }
|
||||
.collect { it.name }, 'depends')
|
||||
writeList(body, description.dep.dependencies
|
||||
.findAll { it.with == null || it.with.equalsIgnoreCase('bungee') }
|
||||
.findAll { it.optional }
|
||||
.collect { it.name }, 'softDepends')
|
||||
writeLine(body)
|
||||
// custom nodes
|
||||
description.bungeeNodes.each {
|
||||
if (it.value instanceof List) {
|
||||
writeList(body, it.value, it.key)
|
||||
} else {
|
||||
write(body, it.value, it.key)
|
||||
}
|
||||
}
|
||||
return bytes(body)
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
package io.izzel.taboolib.gradle.description
|
||||
|
||||
import org.gradle.api.Project
|
||||
|
||||
class BuilderNukkit extends Builder {
|
||||
|
||||
@Override
|
||||
byte[] build(Description description, Project project) {
|
||||
def body = startBukkitFile()
|
||||
body += "name: ${project.name}"
|
||||
body += "main: ${project.group}.taboolib.platform.NukkitPlugin"
|
||||
body += "version: ${project.version}"
|
||||
write(body, description.lin.links['homepage'], 'website')
|
||||
writeLine(body)
|
||||
// authors
|
||||
def con = description.con.contributors.collect { it.name }
|
||||
writeList(body, con, 'authors')
|
||||
writeLine(body)
|
||||
// dependency
|
||||
writeList(body, description.dep.dependencies
|
||||
.findAll { it.with == null || it.with.equalsIgnoreCase('nukkit') }
|
||||
.findAll { it.forceDepend() }
|
||||
.collect { it.name }, 'depend')
|
||||
writeList(body, description.dep.dependencies
|
||||
.findAll { it.with == null || it.with.equalsIgnoreCase('nukkit') }
|
||||
.findAll { it.optional }
|
||||
.collect { it.name }, 'softdepend')
|
||||
writeList(body, description.dep.dependencies
|
||||
.findAll { it.with == null || it.with.equalsIgnoreCase('nukkit') }
|
||||
.findAll { it.loadbefore }
|
||||
.collect { it.name }, 'loadbefore')
|
||||
writeLine(body)
|
||||
// custom nodes
|
||||
description.nukkitNodes.each {
|
||||
if (it.value instanceof List) {
|
||||
writeList(body, it.value, it.key)
|
||||
} else {
|
||||
write(body, it.value, it.key)
|
||||
}
|
||||
}
|
||||
return bytes(body)
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
package io.izzel.taboolib.gradle.description
|
||||
|
||||
import com.google.gson.JsonArray
|
||||
import com.google.gson.JsonObject
|
||||
import org.gradle.api.Project
|
||||
|
||||
class BuilderSponge7 extends Builder {
|
||||
|
||||
@Override
|
||||
byte[] build(Description description, Project project) {
|
||||
def json = new JsonArray()
|
||||
def info = new JsonObject()
|
||||
info.addProperty('modid', project.name.toLowerCase())
|
||||
info.addProperty('name', project.name)
|
||||
info.addProperty('version', project.version.toString())
|
||||
write(info, description.spongeDesc, 'description')
|
||||
write(info, description.lin.links['homepage'], 'url')
|
||||
// authors
|
||||
def con = description.con.contributors.collect { it.name }
|
||||
writeList(info, con, 'authorList')
|
||||
// dependencies
|
||||
writeList(info, description.dep.dependencies
|
||||
.findAll { it.with == null || it.with.equalsIgnoreCase('sponge7') }
|
||||
.findAll { !it.mod }
|
||||
.collect { it.fullyName() }, 'dependencies')
|
||||
writeList(info, description.dep.dependencies
|
||||
.findAll { it.with == null || it.with.equalsIgnoreCase('sponge7') }
|
||||
.findAll { it.mod }
|
||||
.collect { it.fullyName() }, 'requiredMods')
|
||||
json.add(info)
|
||||
return bytes(json)
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
package io.izzel.taboolib.gradle.description
|
||||
|
||||
import com.google.gson.JsonArray
|
||||
import com.google.gson.JsonObject
|
||||
import org.gradle.api.Project
|
||||
|
||||
class BuilderSponge8 extends Builder {
|
||||
|
||||
@Override
|
||||
byte[] build(Description description, Project project) {
|
||||
def json = new JsonObject()
|
||||
def plugins = new JsonArray()
|
||||
def info = new JsonObject()
|
||||
info.addProperty('loader', 'java_plain')
|
||||
info.addProperty('id', project.name.toLowerCase())
|
||||
info.addProperty('name', project.name)
|
||||
info.addProperty('version', project.version.toString())
|
||||
info.addProperty('main-class', "${project.group}.taboolib.platform.Sponge8Plugin")
|
||||
write(info, description.spongeDesc, 'description')
|
||||
// links
|
||||
if (description.lin.links.size() > 0) {
|
||||
def links = new JsonObject()
|
||||
description.lin.links.each {
|
||||
links.addProperty(it.key, it.value.url)
|
||||
}
|
||||
info.add('links', links)
|
||||
}
|
||||
// contributors
|
||||
if (description.con.contributors.size() > 0) {
|
||||
def contributors = new JsonArray()
|
||||
description.con.contributors.each {
|
||||
def con = new JsonObject()
|
||||
write(con, it.name, 'name')
|
||||
write(con, it.description, 'description')
|
||||
contributors.add(con)
|
||||
}
|
||||
info.add('contributors', contributors)
|
||||
}
|
||||
// dependencies
|
||||
if (description.dep.dependencies.size() > 0) {
|
||||
def dependencies = new JsonArray()
|
||||
description.dep.dependencies.findAll { it.with == null || it.with.equalsIgnoreCase('sponge8') }.each {
|
||||
def dep = new JsonObject()
|
||||
write(dep, it.name, 'id')
|
||||
write(dep, it.version, 'version')
|
||||
dep.addProperty('load-order', it.loadafter ? 'AFTER' : 'UNDEFINED')
|
||||
dep.addProperty('optional', it.optional)
|
||||
dependencies.add(dep)
|
||||
}
|
||||
info.add('dependencies', dependencies)
|
||||
}
|
||||
plugins.add(info)
|
||||
json.add('plugins', plugins)
|
||||
return bytes(json)
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
package io.izzel.taboolib.gradle.description
|
||||
|
||||
import com.google.gson.JsonArray
|
||||
import com.google.gson.JsonObject
|
||||
import org.gradle.api.Project
|
||||
|
||||
class BuilderVelocity extends Builder {
|
||||
|
||||
@Override
|
||||
byte[] build(Description description, Project project) {
|
||||
def json = new JsonArray()
|
||||
def info = new JsonObject()
|
||||
info.addProperty('id', project.name.toLowerCase())
|
||||
info.addProperty('name', project.name)
|
||||
info.addProperty('main', "${project.group}.taboolib.platform.VelocityPlugin")
|
||||
info.addProperty('version', project.version.toString())
|
||||
// authors
|
||||
def con = description.con.contributors.collect { it.name }
|
||||
writeList(info, con, 'authors')
|
||||
// dependencies
|
||||
writeList(info, description.dep.dependencies
|
||||
.findAll { it.with == null || it.with.equalsIgnoreCase('velocity') }
|
||||
.collect { it.name }, 'dependencies')
|
||||
json.add(info)
|
||||
return bytes(json)
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
package io.izzel.taboolib.gradle.description
|
||||
|
||||
class Contributors {
|
||||
|
||||
List<Contributor> contributors = []
|
||||
|
||||
Contributor name(name) {
|
||||
def con = new Contributor(name)
|
||||
contributors += con
|
||||
return con
|
||||
}
|
||||
|
||||
class Contributor {
|
||||
|
||||
def name
|
||||
def description
|
||||
|
||||
Contributor(name) {
|
||||
this.name = name
|
||||
}
|
||||
|
||||
Contributor description(description) {
|
||||
this.description = description
|
||||
return this
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,66 @@
|
|||
package io.izzel.taboolib.gradle.description
|
||||
|
||||
class Dependencies {
|
||||
|
||||
List<Dependency> dependencies = []
|
||||
|
||||
Dependency name(name) {
|
||||
def dep = new Dependency(name)
|
||||
dependencies += dep
|
||||
return dep
|
||||
}
|
||||
|
||||
class Dependency {
|
||||
|
||||
String name
|
||||
String with
|
||||
String version
|
||||
|
||||
def loadafter = false
|
||||
def loadbefore = false
|
||||
def optional = false
|
||||
def mod = false
|
||||
|
||||
Dependency(name) {
|
||||
this.name = name
|
||||
}
|
||||
|
||||
def fullyName(spec = '@') {
|
||||
return version == null ? name : name + spec + version
|
||||
}
|
||||
|
||||
def forceDepend() {
|
||||
return !loadafter && !loadbefore && !optional
|
||||
}
|
||||
|
||||
Dependency with(description) {
|
||||
this.with = description
|
||||
return this
|
||||
}
|
||||
|
||||
Dependency version(version) {
|
||||
this.version = version
|
||||
return this
|
||||
}
|
||||
|
||||
Dependency loadafter(loadafter) {
|
||||
this.loadafter = loadafter
|
||||
return this
|
||||
}
|
||||
|
||||
Dependency loadbefore(loadbefore) {
|
||||
this.loadbefore = loadbefore
|
||||
return this
|
||||
}
|
||||
|
||||
Dependency optional(optional) {
|
||||
this.optional = optional
|
||||
return this
|
||||
}
|
||||
|
||||
Dependency mod(mod) {
|
||||
this.mod = mod
|
||||
return this
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
package io.izzel.taboolib.gradle.description
|
||||
|
||||
import org.gradle.api.Action
|
||||
|
||||
class Description {
|
||||
|
||||
Contributors con = new Contributors()
|
||||
|
||||
Dependencies dep = new Dependencies()
|
||||
|
||||
Links lin = new Links()
|
||||
|
||||
def bukkitNodes = new HashMap()
|
||||
|
||||
def nukkitNodes = new HashMap()
|
||||
|
||||
def bungeeNodes = new HashMap()
|
||||
|
||||
String spongeDesc
|
||||
|
||||
Description() {
|
||||
bukkitApi('1.13')
|
||||
nukkitApi('1.0.0')
|
||||
}
|
||||
|
||||
def desc(desc) {
|
||||
bukkitNodes['description'] = desc
|
||||
nukkitNodes['description'] = desc
|
||||
bungeeNodes['description'] = desc
|
||||
spongeDesc = desc
|
||||
}
|
||||
|
||||
def load(order) {
|
||||
bukkitNodes['load'] = order
|
||||
nukkitNodes['load'] = order
|
||||
}
|
||||
|
||||
def bukkitApi(api) {
|
||||
bukkitNodes['api-version'] = api
|
||||
}
|
||||
|
||||
def nukkitApi(api) {
|
||||
nukkitNodes['api'] = api
|
||||
}
|
||||
|
||||
def prefix(prefix) {
|
||||
bukkitNodes['prefix'] = prefix
|
||||
nukkitNodes['prefix'] = prefix
|
||||
}
|
||||
|
||||
def contributors(closure) {
|
||||
closure.delegate = con
|
||||
closure()
|
||||
}
|
||||
|
||||
def dependencies(closure) {
|
||||
closure.delegate = dep
|
||||
closure()
|
||||
}
|
||||
|
||||
def links(Action<? super Links> action) {
|
||||
action.execute(lin)
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
package io.izzel.taboolib.gradle.description
|
||||
|
||||
class Links {
|
||||
|
||||
def links = new HashMap<String, Link>()
|
||||
|
||||
Link name(name) {
|
||||
def link = new Link(name)
|
||||
links[link.name] = link
|
||||
return link
|
||||
}
|
||||
|
||||
class Link {
|
||||
|
||||
String name
|
||||
String url
|
||||
|
||||
Link(name) {
|
||||
this.name = name
|
||||
}
|
||||
|
||||
Link url(url) {
|
||||
this.url = url
|
||||
return this
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
package io.izzel.taboolib.gradle.description
|
||||
|
||||
enum Platforms {
|
||||
|
||||
BUKKIT('platform-bukkit', 'plugin.yml', new BuilderBukkit()),
|
||||
|
||||
NUKKIT('platform-nukkit', 'nukkit.yml', new BuilderNukkit()),
|
||||
|
||||
BUNGEE('platform-bungee', 'bungee.yml', new BuilderBungee()),
|
||||
|
||||
VELOCITY('platform-velocity', 'velocity-plugin.json', new BuilderVelocity()),
|
||||
|
||||
SPONGE7('platform-sponge-api7', 'mcmod.info', new BuilderSponge7()),
|
||||
|
||||
SPONGE8('platform-sponge-api8', 'META-INF/plugins.json', new BuilderSponge8());
|
||||
|
||||
String module
|
||||
String file
|
||||
Builder builder
|
||||
|
||||
Platforms(module, file, builder) {
|
||||
this.module = module
|
||||
this.file = file
|
||||
this.builder = builder
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue