2021-07-16 20:13:54 +02:00
|
|
|
import org.apache.tools.ant.filters.ReplaceTokens
|
|
|
|
|
|
|
|
plugins {
|
|
|
|
id 'java'
|
|
|
|
id 'com.github.johnrengelman.shadow' version '6.0.0'
|
|
|
|
id 'com.palantir.git-version' version '0.12.3'
|
|
|
|
}
|
|
|
|
|
|
|
|
group = 'net.coreprotect'
|
2021-12-18 19:35:55 +01:00
|
|
|
String projectVersion = '20.3'
|
2021-07-16 20:13:54 +02: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.'
|
|
|
|
sourceCompatibility = '1.8'
|
|
|
|
|
|
|
|
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 {
|
|
|
|
jcenter()
|
|
|
|
maven { url = 'https://hub.spigotmc.org/nexus/content/groups/public/' }
|
|
|
|
maven { url = 'https://oss.sonatype.org/content/repositories/snapshots/' }
|
|
|
|
maven { url = 'https://papermc.io/repo/repository/maven-public/' }
|
|
|
|
maven { url = 'https://repo.codemc.org/repository/maven-public/' }
|
|
|
|
maven { url = 'https://maven.sk89q.com/repo/' }
|
|
|
|
}
|
|
|
|
|
|
|
|
dependencies {
|
|
|
|
compileOnly('com.sk89q.worldedit:worldedit-bukkit:7.0.0-SNAPSHOT') {
|
|
|
|
exclude group: 'org.bukkit'
|
|
|
|
}
|
|
|
|
compileOnly 'org.spigotmc:spigot-api:1.17-R0.1-SNAPSHOT'
|
2021-12-16 22:01:43 +01:00
|
|
|
implementation 'org.bstats:bstats-bukkit-lite:1.8'
|
2021-11-16 01:57:33 +01:00
|
|
|
implementation 'com.zaxxer:HikariCP:4.0.3'
|
2021-07-16 20:13:54 +02: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 01:57:33 +01:00
|
|
|
relocate('com.zaxxer', project.group.toString())
|
2021-07-16 20:13:54 +02: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')
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|