forked from PlayPro/CoreProtect
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
91 lines (80 loc) · 2.9 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import org.apache.tools.ant.filters.ReplaceTokens
plugins {
id 'java'
id 'com.github.johnrengelman.shadow' version '7.1.2'
id 'com.palantir.git-version' version '0.13.0'
}
group = 'net.coreprotect'
String projectVersion = '22.2'
String projectBranch = 'diamondfire'
version = projectVersion // `version` might be modified, we don't always want that (e.g. plugin.yml)
description = 'Provides block protection for your server.'
sourceCompatibility = '17'
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://papermc.io/repo/repository/maven-public/' }
maven { url = 'https://repo.codemc.org/repository/maven-public/' }
maven { url = 'https://maven.enginehub.org/repo/' }
}
dependencies {
compileOnly('com.sk89q.worldedit:worldedit-bukkit:7.0.0-SNAPSHOT') {
exclude group: 'org.bukkit'
}
compileOnly 'dev.folia:folia-api:1.20.1-R0.1-SNAPSHOT'
implementation 'org.bstats:bstats-bukkit-lite:1.8'
implementation 'com.zaxxer:HikariCP:5.0.1'
}
jar {
archiveClassifier.set("original")
}
artifacts {
archives shadowJar
}
shadowJar {
dependencies {
// #toString because #getGroup technically returns an Object
relocate('org.bstats', project.group.toString())
relocate('com.zaxxer', project.group.toString())
exclude(dependency('com.google.code.gson:.*'))
exclude(dependency('org.intellij:.*'))
exclude(dependency('org.jetbrains:.*'))
exclude(dependency('org.slf4j:.*'))
}
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')
}
})
}