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
|
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'org.gretty:gretty:3.1.0'
classpath "org.docstr:gwt-gradle-plugin:$gwtPluginVersion"
}
}
apply plugin: "gwt"
apply plugin: "war"
apply plugin: "org.gretty"
gwt {
gwtVersion = "$gwtFrameworkVersion"
// Should match the version used for building the GWT backend. See gradle.properties.
maxHeapSize = '1G' // Default 256m is not enough for the GWT compiler. GWT is HUNGRY.
minHeapSize = '1G'
src = files(file('src/main/java')) // Needs to be in front of "modules" below.
modules 'kz.ilotterytea.frogartha.GdxDefinition'
devModules 'kz.ilotterytea.frogartha.GdxDefinitionSuperdev'
project.webAppDirName = 'webapp'
compiler.strict = true
compiler.disableCastChecking = true
//// The next line can be useful to uncomment if you want output that hasn't been obfuscated.
// compiler.style = org.docstr.gradle.plugins.gwt.Style.DETAILED
sourceLevel = 1.11
}
dependencies {
implementation "com.badlogicgames.gdx:gdx-backend-gwt:$gdxVersion"
implementation "com.badlogicgames.gdx:gdx-backend-gwt:$gdxVersion:sources"
implementation "com.badlogicgames.gdx:gdx:$gdxVersion:sources"
implementation "com.github.mgsx-dev.gdx-gltf:gltf:$gdxGltfVersion:sources"
implementation "com.crashinvaders.lml:gdx-websocket:$gdxWsVersion:sources"
implementation "com.crashinvaders.lml:gdx-websocket-serialization:$gdxWsVersion:sources"
implementation "com.crashinvaders.lml:gdx-websocket-gwt:$gdxWsVersion"
implementation "com.crashinvaders.lml:gdx-websocket-gwt:$gdxWsVersion:sources"
implementation project(':core')
}
import org.akhikhl.gretty.AppBeforeIntegrationTestTask
import org.docstr.gradle.plugins.gwt.GwtSuperDev
gretty.httpPort = 8080
// The line below will need to be changed only if you change the build directory to something other than "build".
gretty.resourceBase = "${project.layout.buildDirectory.asFile.get().absolutePath}/gwt/draftOut"
gretty.contextPath = "/"
gretty.portPropertiesFileName = "TEMP_PORTS.properties"
task startHttpServer(dependsOn: [draftCompileGwt]) {
doFirst {
copy {
from "webapp"
into gretty.resourceBase
}
copy {
from "war"
into gretty.resourceBase
}
}
}
task beforeRun(type: AppBeforeIntegrationTestTask, dependsOn: startHttpServer) {
// The next line allows ports to be reused instead of
// needing a process to be manually terminated.
file("build/TEMP_PORTS.properties").delete()
// Somewhat of a hack; uses Gretty's support for wrapping a task in
// a start and then stop of a Jetty server that serves files while
// also running the SuperDev code server.
integrationTestTask 'superDev'
interactive false
}
task superDev(type: GwtSuperDev) {
doFirst {
gwt.modules = gwt.devModules
}
}
//// We delete the (temporary) war/ folder because if any extra files get into it, problems occur.
//// The war/ folder shouldn't be committed to version control.
clean.delete += [file("war")]
// This next line can be changed if you want to, for instance, always build into the
// docs/ folder of a Git repo, which can be set to automatically publish on GitHub Pages.
// This is relative to the html/ folder.
var outputPath = "build/dist/"
task dist(dependsOn: [clean, compileGwt]) {
doLast {
// Uncomment the next line if you have changed outputPath and know that its contents
// should be replaced by a new dist build. Some large JS files are not cleaned up by
// default unless the outputPath is inside build/ (then the clean task removes them).
// Do not uncomment the next line if you changed outputPath to a folder that has
// non-generated files that you want to keep!
//delete(file(outputPath))
file(outputPath).mkdirs()
copy {
from("build/gwt/out") {
exclude '**/*.symbolMap' // Not used by a dist, and these can be large.
}
into outputPath
}
copy {
from("webapp") {
exclude 'index.html' // We edit this HTML file later.
exclude 'refresh.png' // We don't need this button; this saves some bytes.
}
into outputPath
}
copy {
from("webapp") {
// These next two lines take the index.html page and remove the superdev refresh button.
include 'index.html'
filter { String line -> line.replaceAll('<a class="superdev" .+', '') }
// This does not modify the original index.html, only the copy in the dist.
// If you decide to manually remove or comment out the superdev button from index.html, you should also
// either remove or comment out only the "filter" line above this.
}
into outputPath
}
copy {
from "war"
into outputPath
}
}
}
task addSource {
doLast {
sourceSets.main.compileClasspath += files(project(':core').sourceSets.main.allJava.srcDirs)
sourceSets.main.compileClasspath += files("../core/build/generated/sources/annotationProcessor/java/main")
sourceSets.main.compileClasspath += files(project(':shared').sourceSets.main.allJava.srcDirs)
}
}
task distZip(type: Zip, dependsOn: dist) {
//// This uses the output of the dist task, which removes the superdev button from index.html .
from(outputPath)
archiveVersion = projectVersion
archiveBaseName.set("${appName}-dist")
//// The result will be in html/build/ with a name containing "-dist".
destinationDirectory.set(file("build"))
}
tasks.compileGwt.dependsOn(addSource)
tasks.draftCompileGwt.dependsOn(addSource)
tasks.checkGwt.dependsOn(addSource)
java.sourceCompatibility = JavaVersion.VERSION_11
java.targetCompatibility = JavaVersion.VERSION_11
sourceSets.main.java.srcDirs = ["src/main/java/"]
eclipse.project.name = appName + "-html"
|