-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle
85 lines (72 loc) · 2.3 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
import org.apache.tools.ant.taskdefs.condition.Os
/* Import to determine os*/
/* Get the openapi generator plugin */
plugins {
id "org.openapi.generator" version "4.3.1"
}
/* Setup OpenApi Specs (OAS): Defaults to latest official.*/
def cineastOAS = "https://raw.githubusercontent.com/vitrivr/cineast/master/docs/openapi.json"
/* If gradle gets 'oas' argument (with -Poas="path/to/OAS"), take these */
if(project.hasProperty('oas')){
cineastOAS = oas
}
/* Name to add to dlls to avoid Unity loading errors. */
def dllName = "Cineast"
/* The OpenApi generator task */
openApiGenerate {
generatorName = "csharp"
inputSpec = cineastOAS
outputDir = "$rootDir/Generated"
packageName = "Org.Vitrivr.CineastApi"
}
/* Customized clean task to delete OpenAPI generated*/
task clean(type: Delete){
delete "$rootDir/Generated", fileTree("$rootDir/Runtime/Libs") { include "**/*.dll", "**/*.xml", "**/*.meta"}
}
/* Task to clean only unused files */
task tidy(type: Delete){
delete "$rootDir/Generated"
}
/* Build the openapi dll */
task buildOpenApi(type: Exec){
dependsOn tasks.openApiGenerate
workingDir "$rootDir/Generated"
if( Os.isFamily(Os.FAMILY_WINDOWS)){
/* only windows */
commandLine = "$rootDir/Generated/build.bat"
}else{
/* Should work with .sh */
dependsOn "modex"
commandLine = "$rootDir/Generated/build.sh"
}
}
task modex(type: Exec){
workingDir "$rootDir/Generated"
if( !Os.isFamily(Os.FAMILY_WINDOWS)){
/* Should work with .sh */
commandLine "chmod", "+x", "$rootDir/Generated/build.sh"
}
}
/* Copy what buildOpenApi produced to unity folder */
task deployLibs(type: Copy){
from(file("$rootDir/Generated/bin"))
into(file("$rootDir/Runtime/Libs"))
rename("RestSharp.dll", "RestSharp." + dllName + ".dll")
rename("Newtonsoft.Json.dll", "Newtonsoft.Json." + dllName + ".dll")
rename("JsonSubTypes.dll", "JsonSubTypes." + dllName + ".dll")
}
/* Copy the mandatory link.xml */
task deployLink(type:Copy){
from file("$rootDir/link.xml")
into(file("$rootDir/Runtime/Libs"))
}
/* Do all the things */
task('deploy'){
dependsOn 'deployLink'
}
/* Specify order */
deployLibs.dependsOn buildOpenApi
deployLink.dependsOn deployLibs
tasks.openApiGenerate.mustRunAfter clean
buildOpenApi.mustRunAfter tasks.openApiGenerate
modex.mustRunAfter tasks.openApiGenerate