-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle
More file actions
197 lines (168 loc) · 5.59 KB
/
build.gradle
File metadata and controls
197 lines (168 loc) · 5.59 KB
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
buildscript {
ext.kotlin_version = "1.7.10"
repositories {
mavenCentral()
maven {
name = "forge"
url = "https://files.minecraftforge.net/maven"
}
maven {
url "https://cloudrep.veritaris.me/repos"
}
}
dependencies {
classpath("com.anatawa12.forge:ForgeGradle:1.2-1.0.+") {
changing = true
}
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
apply plugin: "forge"
apply plugin: "kotlin"
apply plugin: "java"
apply plugin: "project-report"
def projectBuildPropertiesFile = "build.properties"
def projectBuildProperties = new Properties()
file(projectBuildPropertiesFile).withInputStream { projectBuildProperties.load(it) }
project.version = projectBuildProperties.version
project.buildVersion = projectBuildProperties.buildVersion
group 'com.dreamfinity.' + {rootProject.name}
version project.version
minecraft {
version = "1.7.10-10.13.4.1614-1.7.10"
runDir = "run"
replace("@version@": projectBuildProperties.version)
replace("@debug@": projectBuildProperties.debug)
replace("BuildController.internalBuildState()", isClientBuild)
}
sourceCompatibility = targetCompatibility = JavaVersion.VERSION_1_8
runClient {
if (project.hasProperty("appArgs")) {
args Eval.me(appArgs)
}
}
repositories {
maven {
url "https://cloudrep.veritaris.me/repos/"
metadataSources {
mavenPom()
artifact()
}
}
flatDir {
dirs "libs"
}
mavenCentral()
}
dependencies {
implementation 'com.fasterxml.jackson.core:jackson-core:2.13.0'
implementation 'com.fasterxml.jackson.core:jackson-annotations:2.13.0'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.13.0'
implementation 'org.dreamfinity:craftbukkit:1.7.10-R0.1:dev'
implementation 'com.google.code.gson:gson:2.8.8'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
}
processResources {
duplicatesStrategy = DuplicatesStrategy.INCLUDE
inputs.property "version", projectBuildProperties.version
inputs.property "mcversion", project.minecraft.version
from(sourceSets.main.resources.srcDirs) {
include "mcmod.info"
expand "version": projectBuildProperties.version,
"mcversion": project.minecraft.version
}
from(sourceSets.main.resources.srcDirs) {
exclude "mcmod.info"
}
}
// client-server build separation
jar {
if (isClientBuild.toBoolean()) {
archiveClassifier.set("client")
} else {
archiveClassifier.set("universal")
}
}
task buildClient(type: GradleBuild) {
startParameter.projectProperties = ["isClientBuild": "true"]
tasks = ["build"]
}
task runProtectedClient(type: GradleBuild) {
startParameter.projectProperties = ["isClientBuild": "true"]
tasks = ["runClient"]
}
// Semantic versioning start
def semanticVersioning = [
"Major" : "Builds .jar increasing major number: major.y.z",
"Minor" : "Builds .jar increasing minor number: x.minor.y",
"Patch" : "Builds .jar increasing patch number: x.y.patch",
"JustBuild": "Builds .jar adding \"-build-N\" suffix and increasing build number: x.y.z-build-N",
]
semanticVersioning.keySet().each { semVerType ->
tasks.register(semVerType, WriteProperties) {
outputFile = file(projectBuildPropertiesFile)
projectBuildProperties.replace(
"buildVersion",
semVerType.toLowerCase() == "justbuild"
? "${Integer.parseInt(projectBuildProperties.buildVersion as String) + 1}"
: "0"
)
projectBuildProperties.replace("version", makeVersion(semVerType))
properties = projectBuildProperties as Map<String, Object>
it.group = "Semantic versioned"
it.finalizedBy("build")
}
}
tasks.register("TestSemVerBuilds", GradleBuild) {
tasks = ["JustBuild", "Patch", "Minor", "Major"]
}
def makeVersion(String bumpType) {
def prevVersion = project.version
def (major, minor, patch) = prevVersion.tokenize(".") as Collection<String>
def newVersion
println("Old version: ${prevVersion}, old build number: ${project.buildVersion}")
patch = patch.split("-")[0]
switch (bumpType.toLowerCase()) {
case "major":
newVersion = "${Integer.parseInt(major) + 1}.${minor}.${patch}"
break
case "minor":
newVersion = "${major}.${Integer.parseInt(minor) + 1}.${patch}"
break
case "patch":
newVersion = "${major}.${minor}.${Integer.parseInt(patch) + 1}"
break
default:
newVersion = "${major}.${minor}.${patch}-build-${Integer.parseInt(project.buildVersion) + 1}"
}
if (bumpType in ["major", "minor", "patch"]) {
println("Migrating from ${prevVersion} to ${newVersion}")
} else {
println("Building version ${newVersion}")
}
project.version = newVersion
return newVersion
}
// Semantic versioning end
tasks.register("DebugBuild", GradleBuild) {
startParameter.projectProperties = ["debug": "true"]
tasks = ["build"]
println("Carefully! Building with DEBUG=true")
}
tasks.register("DebugRun", GradleBuild) {
startParameter.projectProperties = ["debug": "true"]
tasks = ["runClient"]
println("Running client with DEBUG=true")
}
DebugRun.finalizedBy("runCLient")
DebugBuild.finalizedBy("build")
compileKotlin {
kotlinOptions {
jvmTarget = "1.8"
}
}
compileTestKotlin {
kotlinOptions {
jvmTarget = "1.8"
}
}