-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle
308 lines (257 loc) · 11.5 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
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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
import java.util.regex.Pattern
plugins{
id 'fabric-loom'
id 'maven-publish'
id "com.jfrog.artifactory" version "4.15.2"
}
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
version = project.mod_version+"-"+minecraft_version
group = project.maven_group
allprojects{
repositories{
mavenCentral()
mavenLocal()
maven{ url 'https://server.bbkr.space/artifactory/libs-release' }
maven{ url 'https://server.bbkr.space/artifactory/libs-snapshot' }
maven{
url "https://libraries.minecraft.net"
}
}
if(rootProject.file('private.gradle').exists()){ //Publishing details
apply from: rootProject.rootDir.absolutePath + '/private.gradle'
}
apply plugin: "idea"
}
minecraft{
}
dependencies{
//to change the versions see the gradle.properties file
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}"
modCompile "net.fabricmc:fabric-loader:${project.loader_version}"
modApi "net.fabricmc.fabric-api:fabric-api:$fabric_version"
modImplementation group: 'io.github.cottonmc.cotton', name: 'cotton-config', version: '1.0.0-rc.7'
include group: 'io.github.cottonmc.cotton', name: 'cotton-config', version: '1.0.0-rc.7'
modImplementation group: 'io.github.cottonmc.cotton', name: 'cotton-config', version: '1.0.0-rc.7'
include group: 'io.github.cottonmc.cotton', name: 'cotton-config', version: '1.0.0-rc.7'
modImplementation(group : "net.fabricmc", name : "fabric-language-kotlin", version : fabric_kotlin_version)
include(group: 'io.github.cottonmc.cotton', name: 'cotton-logging', version: '1.0.0-rc.1')
include(group: 'io.github.cottonmc', name: 'Jankson-Fabric', version: '3.0.1+j1.2.0')
//non-mod library dependencies.
modCompile("io.github.cottonmc:functionapi-scripting:1.1"){
exclude group: "com.google.guava"
exclude group: "com.google.code.gson"
exclude group: "org.apache.commons"
exclude group: "com.mojang"
}
include("io.github.cottonmc:functionapi-scripting:1.1")
include("io.github.cottonmc:functionapi-api:1.5-SNAPSHOT")
// PSA: Some older mods, compiled on Loom 0.2.1, might have outdated Maven POMs.
// You may need to force-disable transitiveness on them.
}
processResources{
inputs.property "version", project.version
from(sourceSets.main.resources.srcDirs){
include "fabric.mod.json"
expand "version": project.version
}
from(sourceSets.main.resources.srcDirs){
exclude "fabric.mod.json"
}
}
// ensure that the encoding is set to UTF-8, no matter what the system default is
// this fixes some edge cases with special characters not displaying correctly
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
tasks.withType(JavaCompile){
options.encoding = "UTF-8"
}
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this task, sources will not be generated.
task sourcesJar(type: Jar, dependsOn: classes){
classifier = "sources"
from sourceSets.main.allSource
}
jar{
from "LICENSE"
}
// configure the maven publication
publishing{
publications{
maven(MavenPublication){
from components.java
pom.withXml{
def pomFile = asNode()
def depsNode = pomFile.get("dependencies")
pomFile.remove(depsNode)
def newDeps = pomFile.appendNode("dependencies")
configurations.modCompile.getResolvedConfiguration().getFirstLevelModuleDependencies().each{
def artifactNode = newDeps.appendNode("dependency")
artifactNode.appendNode('groupId', it.moduleGroup)
artifactNode.appendNode('artifactId', it.moduleName)
artifactNode.appendNode('version', it.moduleVersion)
}
}
artifacts = [
artifact("${project.buildDir.absolutePath}/libs/${archivesBaseName}-${project.version}" + ".jar"){
//release jar - file location not provided anywhere in loom
classifier null
builtBy remapJar
},
artifact("${project.buildDir.absolutePath}/libs/${archivesBaseName}-${project.version}-dev" + ".jar"){
//release jar - file location not provided anywhere in loom
classifier "dev"
builtBy remapJar
},
artifact(tasks.sourcesJar)
]
}
}
/* Supply an ext block in private.gradle like so:
ext { mavenSnapshotDir="file:///some_local_directory_path" }
* and then just run "./gradlew publish" to save the artifacts to the specified directory, in a way that they can be
* served by apache or your favorite httpd and behave like a maven repo. Complete with verification hashes.
*/
repositories{
if(rootProject.ext.has("localMavenUrl")){
maven{
url = rootProject.ext.localMavenUrl
}
}
}
}
artifactory{
if(project.hasProperty("artifactoryUsername")){
contextUrl = 'https://server.bbkr.space/artifactory/'
publish{
repository{
if(version.contains("SNAPSHOT")){
repoKey = "libs-snapshot"
}else{
repoKey = "libs-release"
}
username = artifactoryUsername
password = artifactoryPassword
}
defaults{
publications('maven')
publishArtifacts = true
publishPom = true
}
}
}else{
println "Cannot configure artifactory; please define ext.artifactoryUsername and ext.artifactoryPassword before running artifactoryPublish"
}
}
def eventReference = file(project.buildDir.absolutePath + "/events.csv")
task generateEventReference(){
group = "documentation"
doLast{
FileTree tree = fileTree('src')
def doc = file("docs/eventReference.md")
eventReference.write("")
doc.write("""
Function API Event reference. This document has been generated from the source code of the mod!
The event names are normal identifiers. To get the tag that you can use to bind a function file is as follows:
event name: `minecraft:block/dirt/broken`
tag name: `minecraft:function_api/block/dirt/broken`
If an event is blocking, then it will pause the game until the execution is done, so it CAN cause lagspikes! (non blocking events will run when the server has time for it)
| name | description | includes | blocking |
|---|---|---|---|
""")
tree.each{ file ->
def contents = file.readLines().join("\n")
def pattern = Pattern.compile("GlobalEventContainer\\.getInstance\\(\\)\\.execute(Event|EventBlocking)\\((.*?), \"(.*?)\",([^;\n]+|[^{])")
def found = contents.findAll(pattern)
if(!found.isEmpty()){
println(file.name)
found.each{
def params = it.replaceAll("^GlobalEventContainer\\.getInstance\\(\\)\\.executeEvent(|Blocking)\\(", "")
params = params.split(",", 3)
switch(params[0]){
case "(ScriptedObject) blockState.getBlock()":
case "(ScriptedObject)blockState.getBlock()":
case "(ScriptedObject) this.getBlock()":
case "(ScriptedObject)this.getBlock()":
case "(ScriptedObject) block":
case "(ScriptedObject)block":
params[0] = "block"
break;
case "(ScriptedObject) entity":
case "(ScriptedObject)entity":
case "(ScriptedObject)entitySource":
case "(ScriptedObject) entitySource":
case "Target.ENTITY_TARGET":
params[0] = "entity"
break;
case "(ScriptedObject)stack.getItem()":
params[0] = "item"
break;
default:
if(file.name == "BlockMixin.java")
params[0] = "block"
break;
}
params[1] = params[1].replaceAll("\"", "").trim()
def components = params[2]
.replaceAll("ServerCommandSourceFactory.INSTANCE.create\\(", "")
.replaceAll("\\)\\)\\) \\{", "")
.replaceAll("\\)\\)", "")
.split(",")
//.reverse()
.toList()
if(!components.isEmpty())
components.removeAt(0)
if(components.size() == 1 || params[0] == "entity"){
components = "The source entity, running it it's position"
}else
if(components.size() == 2){
components = "The source block, running it it's position"
}else
if(components.size() == 3){
components = "The source block, running it it's position, also the entity that is the source of this interaction"
}else
if(components.size() == 4){
components = "The source block, running it it's position, also the entity that is the source of this interaction"
}
def isBlocking = "No"
if(params[1].contains("before/")){
isBlocking = "Yes, can be cancelled!"
}
if(params[1].contains("after/")){
isBlocking = "Yes"
}
println(components)
doc.append("| \\<namespace\\>:${params[0]}/\\<name\\>/${params[1]}||${components}|$isBlocking|\n")
if(params[0] == "entity"){
doc.append("| function_api:${params[0]}/\\<name\\>/${params[1]}|Called when any entity calls \\<namespace\\>:${params[0]}/\\<name\\>/${params[1]}|${components}|$isBlocking|\n")
}
println(params)
eventReference.append("${params[0]};${params[1]};${components};$isBlocking\n")
}
}
def functionPattern = Pattern.compile("#(.*?)\nevent run (.*?)\n")
def foundInFunction = contents.findAll(functionPattern)
if(!foundInFunction.isEmpty()){
println(file.name)
foundInFunction.each{
println(it)
def lines = it.split("\n")
lines[0] = lines[0].replaceAll("#", "")
lines[1] = lines[1].replaceAll("event run ", "")
doc.append("| ${lines[1]}|${lines[0]}| The server | No |\n")
eventReference.append("${lines[1]};${lines[0]};The server; No\n")
}
}
}
}
}
jar{
dependsOn generateEventReference
if(eventReference.exists())
from(eventReference){
into("")
}
}
apply from:"./datapacks/datapacks.gradle"