mirror of
https://github.com/sekwah41/Advanced-Portals.git
synced 2024-11-24 11:37:06 +01:00
9030ff5363
BREAKING CHANGE: Permissions have been reworked, if you use a permissions manager you may need to change a few of the permissions
112 lines
3.7 KiB
Groovy
112 lines
3.7 KiB
Groovy
|
|
// Check the root build.gradle under allprojects for common settings
|
|
configurations {
|
|
// configuration that holds jars to copy into lib
|
|
includeLibs
|
|
}
|
|
|
|
repositories {
|
|
maven { url "https://repo.maven.apache.org/maven2" }
|
|
maven { url "https://hub.spigotmc.org/nexus/content/repositories/snapshots/" }
|
|
maven { url 'https://papermc.io/repo/repository/maven-public/' }
|
|
}
|
|
|
|
// includeLibs just says to include the library in the final jar
|
|
dependencies {
|
|
implementation project(":core")
|
|
|
|
|
|
// For spigot api
|
|
// We are using an older version to try and ensure that we are not using anything new older versions cant use.
|
|
implementation "org.spigotmc:spigot-api:1.13.2-R0.1-SNAPSHOT"
|
|
implementation "net.md-5:bungeecord-api:1.16-R0.4"
|
|
implementation "com.mojang:authlib:3.5.41"
|
|
implementation "com.google.inject:guice:5.0.1"
|
|
// Be careful to only use what you need to from paper, otherwise it will become incompatible with spigot.
|
|
// compileOnly 'com.destroystokyo.paper:paper-api:1.16.5-R0.1-SNAPSHOT'
|
|
}
|
|
|
|
jar {
|
|
from configurations.includeLibs.collect {
|
|
it.isDirectory() ? it : zipTree(it)
|
|
}
|
|
}
|
|
|
|
// Code for generating extra data in plugins.yml
|
|
// This may be able to be simplified drastically, though the goal is to get this working for now
|
|
// as it has gone through a few iterations.
|
|
sourceSets {
|
|
permissionsGen {
|
|
java {
|
|
srcDirs = ['src/main/java']
|
|
}
|
|
}
|
|
}
|
|
|
|
configurations {
|
|
permissionsGenCompileClasspath.extendsFrom compileClasspath
|
|
}
|
|
|
|
def compilePermissionsGen = tasks.register('compilePermissionsGen', JavaCompile) {
|
|
source = sourceSets.permissionsGen.allJava
|
|
classpath = configurations.permissionsGenCompileClasspath
|
|
destinationDirectory = file("$buildDir/classes/permissionsGen")
|
|
}
|
|
|
|
def templateSource = file('src/main/templates')
|
|
def templateDest = layout.buildDirectory.dir('generated/resources/templates')
|
|
|
|
def generatePermissionsYaml = tasks.register('generatePermissionsYaml') {
|
|
dependsOn compilePermissionsGen
|
|
|
|
doLast {
|
|
println "Generating permissions.yml file"
|
|
|
|
def classFiles = []
|
|
classFiles.addAll(files("$buildDir/classes/permissionsGen", sourceSets.permissionsGen.runtimeClasspath)
|
|
.collect { it.toURI().toURL() })
|
|
|
|
classFiles.addAll(project(':core').sourceSets.main.output.classesDirs
|
|
.collect { it.toURI().toURL() })
|
|
|
|
def urls = classFiles.toArray(new URL[0])
|
|
|
|
def parentClassLoader = Thread.currentThread().contextClassLoader
|
|
def classLoader = new URLClassLoader(urls, parentClassLoader)
|
|
|
|
def permissionsGeneratorClass = classLoader.loadClass('com.sekwah.advancedportals.spigot.PermissionsGeneratorSpigot')
|
|
def getPermissionsMethod = permissionsGeneratorClass.getMethod('getPermissions')
|
|
def permissionsYaml = getPermissionsMethod.invoke(null)
|
|
|
|
def permissionsFile = file("$buildDir/generated/resources/permissions.yml")
|
|
permissionsFile.parentFile.mkdirs()
|
|
permissionsFile.text = permissionsYaml
|
|
|
|
println "Permissions YAML generated at: $permissionsFile"
|
|
}
|
|
}
|
|
|
|
def generateTemplates = tasks.register('generateTemplates', Copy) { task ->
|
|
dependsOn generatePermissionsYaml
|
|
|
|
def props = [
|
|
'permissions': { -> file("$buildDir/generated/resources/permissions.yml").text },
|
|
'pluginVersion': { -> project.version }
|
|
]
|
|
|
|
task.inputs.properties(props)
|
|
task.from(templateSource)
|
|
task.into(templateDest)
|
|
task.expand(props)
|
|
|
|
doFirst {
|
|
println "Running generateTemplates task"
|
|
}
|
|
}
|
|
|
|
generateTemplates.configure {
|
|
outputs.upToDateWhen { false }
|
|
}
|
|
|
|
sourceSets.main.resources.srcDir(generateTemplates.map { it.outputs })
|