2021-07-17 02:13:54 +08:00
|
|
|
import org.apache.tools.ant.filters.ReplaceTokens
|
|
|
|
|
|
|
|
plugins {
|
|
|
|
id 'java'
|
2024-05-13 01:43:36 +08:00
|
|
|
id 'com.github.johnrengelman.shadow' version '8.1.1'
|
2022-03-03 04:14:30 +08:00
|
|
|
id 'com.palantir.git-version' version '0.13.0'
|
2021-07-17 02:13:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
group = 'net.coreprotect'
|
2024-05-14 07:47:50 +08:00
|
|
|
String projectVersion = '22.4'
|
2021-07-17 02:13:54 +08:00
|
|
|
String projectBranch = ''
|
|
|
|
version = projectVersion // `version` might be modified, we don't always want that (e.g. plugin.yml)
|
|
|
|
description = 'Provides block protection for your server.'
|
2024-05-14 07:46:16 +08:00
|
|
|
sourceCompatibility = '21'
|
2021-07-17 02:13:54 +08:00
|
|
|
|
|
|
|
if (System.getenv("BUILD_NUMBER") != null) {
|
|
|
|
// Being built in Jenkins, append Build ID
|
|
|
|
version += "-${System.getenv("BUILD_NUMBER")}"
|
|
|
|
} else if (!(version ==~ '^[^.]*\\.[^.]*\\.[^.]*$')) { // Thanks https://stackoverflow.com/a/9949200/1709894
|
|
|
|
// Append the Git hash if 'version' has less than two periods
|
|
|
|
version += "-${gitVersion()}"
|
|
|
|
}
|
|
|
|
logger.info("Building version $version")
|
|
|
|
|
|
|
|
repositories {
|
|
|
|
maven { url = 'https://hub.spigotmc.org/nexus/content/groups/public/' }
|
2024-05-13 01:43:36 +08:00
|
|
|
maven { url = 'https://repo.papermc.io/repository/maven-public/' }
|
2021-07-17 02:13:54 +08:00
|
|
|
maven { url = 'https://repo.codemc.org/repository/maven-public/' }
|
|
|
|
}
|
|
|
|
|
|
|
|
dependencies {
|
2024-06-18 08:31:33 +08:00
|
|
|
implementation(platform("com.intellectualsites.bom:bom-newest:1.45")) // Ref: https://github.com/IntellectualSites/bom
|
2024-05-13 01:43:36 +08:00
|
|
|
compileOnly("com.fastasyncworldedit:FastAsyncWorldEdit-Core")
|
|
|
|
compileOnly("com.fastasyncworldedit:FastAsyncWorldEdit-Bukkit")
|
2024-06-18 08:31:33 +08:00
|
|
|
compileOnly 'io.papermc.paper:paper-api:1.21-R0.1-SNAPSHOT'
|
2021-12-17 05:01:43 +08:00
|
|
|
implementation 'org.bstats:bstats-bukkit-lite:1.8'
|
2023-08-01 08:39:57 +08:00
|
|
|
implementation 'com.zaxxer:HikariCP:5.0.1'
|
2021-07-17 02:13:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
jar {
|
|
|
|
archiveClassifier.set("original")
|
|
|
|
}
|
|
|
|
|
|
|
|
artifacts {
|
|
|
|
archives shadowJar
|
|
|
|
}
|
|
|
|
|
|
|
|
shadowJar {
|
|
|
|
dependencies {
|
|
|
|
// #toString because #getGroup technically returns an Object
|
|
|
|
relocate('org.bstats', project.group.toString())
|
2021-11-16 08:57:33 +08:00
|
|
|
relocate('com.zaxxer', project.group.toString())
|
2022-12-22 10:56:32 +08:00
|
|
|
exclude(dependency('com.google.code.gson:.*'))
|
|
|
|
exclude(dependency('org.intellij:.*'))
|
|
|
|
exclude(dependency('org.jetbrains:.*'))
|
|
|
|
exclude(dependency('org.slf4j:.*'))
|
2021-07-17 02:13:54 +08:00
|
|
|
}
|
|
|
|
archiveClassifier.set(null)
|
|
|
|
}
|
|
|
|
|
|
|
|
ext {
|
|
|
|
author = 'Intelli'
|
|
|
|
|
|
|
|
resourceTokens = [
|
|
|
|
'project.version': projectVersion,
|
|
|
|
'project.branch': projectBranch,
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
processResources {
|
|
|
|
include 'plugin.yml'
|
|
|
|
// Whole lotta boilerplate to get the same functionality as Maven here.
|
|
|
|
// Replace this if Gradle ever lets us configure the filter before filtering.
|
|
|
|
filter(new Transformer<String, String>() {
|
|
|
|
@Override
|
|
|
|
String transform(String s) {
|
|
|
|
ReplaceTokens replaceTokens = new ReplaceTokens(new StringReader(s))
|
|
|
|
replaceTokens.setBeginToken('${')
|
|
|
|
replaceTokens.setEndToken('}')
|
|
|
|
resourceTokens.forEach { key, val ->
|
|
|
|
def token = new ReplaceTokens.Token()
|
|
|
|
token.setKey(key.toString())
|
|
|
|
token.setValue(val.toString())
|
|
|
|
replaceTokens.addConfiguredToken(token)
|
|
|
|
}
|
|
|
|
return replaceTokens.readLines().join('\n')
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|