-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
92 lines (79 loc) · 2.53 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
import org.apache.tools.ant.taskdefs.condition.Os
/* Import to determine os*/
/* Get the openapi generator plugin */
plugins {
id "org.openapi.generator" version "6.4.0"
}
/* Setup OpenApi Specs (OAS): Defaults to default.*/
/* Additional, sensible settings:
+ http://localhost:8080/client-oas.json // Local DRES
+ https://raw.githubusercontent.com/dres-dev/DRES/master/doc/oas-client.json // When oas-client is released
*/
def dresOAS = "https://raw.githubusercontent.com/dres-dev/DRES/2.0.0-RC1/doc/oas-client.json"
/* If gradle gets 'oas' argument (with -Poas="path/to/OAS"), take these */
if(project.hasProperty('oas')){
dresOAS = oas
}
/* Name to add to dlls to avoid Unity loading errors. */
def dllName = "Dres"
/* The OpenApi generator task */
openApiGenerate {
generatorName = "csharp"
inputSpec = dresOAS
outputDir = "$rootDir/Generated"
packageName = "Dev.Dres.ClientApi"
configOptions = [
optionalEmitDefaultValues: "true"
]
}
/* 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