-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle
83 lines (64 loc) · 2.48 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
import groovy.json.internal.LazyMap
import groovyx.net.http.HttpResponseDecorator
import groovyx.net.http.RESTClient
import org._10ne.gradle.rest.RestTask
buildscript {
ext.kotlin_version = '1.3.30'
repositories {
repositories { jcenter() }
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
}
}
plugins {
id "org.tenne.rest" version "0.4.2"
}
group 'screeps.game'
version '1.0-SNAPSHOT'
apply plugin: 'kotlin2js'
apply plugin: 'kotlinx-serialization'
apply plugin: 'kotlin-dce-js'
runDceKotlinJs.dceOptions.devMode = false
runDceTestKotlinJs.dceOptions.devMode = true
repositories {
jcenter()
maven {
url "https://dl.bintray.com/exav/screeps-kotlin"
}
mavenLocal()
maven { url "https://kotlin.bintray.com/kotlinx" }
maven { url 'https://jitpack.io' }
}
dependencies {
compile 'org.jetbrains.kotlin:kotlin-stdlib-js:$kotlin_version'
compile "org.jetbrains.kotlinx:kotlinx-serialization-runtime-js:0.11.0"
compile "ch.delconte.screeps-kotlin:screeps-kotlin-types:1.3.0"
testCompile "org.jetbrains.kotlin:kotlin-test-js:$kotlin_version"
}
compileKotlin2Js {
kotlinOptions.outputFile = "${buildDir}/screeps/main.js"
kotlinOptions.moduleKind = "commonjs"
kotlinOptions.sourceMap = true
kotlinOptions.freeCompilerArgs = ["-Xuse-experimental=kotlin.Experimental,kotlinx.serialization.ImplicitReflectionSerializer"]
runDceKotlinJs.keep "main.loop", "main.Traveler", "Traveler"
}
task('deploy', type: RestTask) {
group 'screeps'
dependsOn build
def modules = [:]
httpMethod = "post"
uri = "https://screeps.com/api/user/code"
requestHeaders = ["X-Token": "$screepsToken"]
contentType = groovyx.net.http.ContentType.JSON
requestBody = ["branch": "kotlin", "modules": modules]
doFirst {
println "uploading code to screeps.com"
modules.put('main', file("$buildDir/kotlin-js-min/main/main.js").getText('UTF-8'))
modules.put('screeps-kotlin-types', file("$buildDir/kotlin-js-min/main/screeps-kotlin-types.js").getText('UTF-8'))
modules.put('kotlin', file("$buildDir/kotlin-js-min/main/kotlin.js").getText('UTF-8'))
modules.put('kotlinx-serialization-runtime-js', file("$buildDir/kotlin-js-min/main/kotlinx-serialization-runtime-js.js").getText('UTF-8'))
modules.put('Traveler', file("traveler/Traveler.js").getText('UTF-8'))
}
}