forked from jsettlers/settlers-remake
-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathbuild.gradle
212 lines (171 loc) · 6.41 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
// Top-level build file where you can add configuration options common to all sub-projects/modules.
apply plugin: 'java'
ext {
androidAnnotationsVersion = '4.8.0'
androidSupportLibraryVersion = '28.0.0'
androidBuildToolsVersion = '30.0.3'
androidCompileSdkVersion = 30
androidMinSdkVersion = 19
androidTargetSdkVersion = 26
lwjglVersion = "3.3.0"
}
buildscript {
repositories {
mavenCentral()
google()
}
dependencies {
classpath 'org.eclipse.jgit:org.eclipse.jgit:6.1.0.202203080745-r'
if (findProject(':jsettlers.main.android')) {
classpath 'com.android.tools.build:gradle:7.0.0'
}
}
}
allprojects {
repositories {
mavenCentral()
google()
//jcenter()
// fallback for vbps
maven { url "https://raw.github.com/laenger/maven-releases/master/releases" }
maven { url "https://maven.google.com" }
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
}
}
subprojects {
plugins.withType(JavaPlugin).whenPluginAdded {
compileJava {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
options.release = 11
}
compileTestJava {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
options.release = 11
}
task copyMainResources(type: Copy) {
from sourceSets.main.resources
into sourceSets.main.output.classesDirs[0]
}
processResources.dependsOn copyMainResources
task copyTestResources(type: Copy) {
from sourceSets.test.resources
into sourceSets.test.output.classesDirs[0]
}
processTestResources.dependsOn copyTestResources
}
plugins.withType(ApplicationPlugin).whenPluginAdded {
startScripts {
defaultJvmOpts = ['-Xmx2G']
optsEnvironmentVar = "XXXREPLACEXXX"
def args = '"-Dsettlers.maps=$APP_HOME/maps"'
doLast {
unixScript.text = unixScript.text.replace('$XXXREPLACEXXX', args)
windowsScript.text = windowsScript.text.replace('%XXXREPLACEXXX%', args.replace('$APP_HOME', '%APP_HOME%'))
}
}
}
tasks.withType(Test) {
testLogging {
exceptionFormat = 'full'
}
}
tasks.withType(Jar) {
duplicatesStrategy DuplicatesStrategy.EXCLUDE
}
def addGlobalDependencies = {
dependencies {
testImplementation 'junit:junit:4.12'
}
}
plugins.withId('java', addGlobalDependencies)
plugins.withId('java-library', addGlobalDependencies)
plugins.withId('application', addGlobalDependencies)
plugins.withId('com.android.application', addGlobalDependencies)
plugins.withId('com.android.library', addGlobalDependencies)
}
// This is a hack to make ./gradlew run only run the swing version.
task run(dependsOn: ':jsettlers.main.swing:run') {
doLast {
// We do not need any more tasks.
tasks.getAsMap().values().each { task ->
if (!task.state.executed && task != tasks.getByPath(":run")) task.onlyIf {
false
}
}
}
}
tasks.getByPath(":jsettlers.mapcreator:run").onlyIf { !gradle.taskGraph.hasTask(":run") }
tasks.getByPath(":jsettlers.network:run").onlyIf { !gradle.taskGraph.hasTask(":run") }
tasks.getByPath(":jsettlers.tools:run").onlyIf { !gradle.taskGraph.hasTask(":run") }
task runMapCreator(dependsOn: ':jsettlers.mapcreator:run') {}
task runTools(dependsOn: ':jsettlers.tools:run') {}
if (findProject(':jsettlers.main.android')) {
// Android is present.
task runAndroid(dependsOn: ':jsettlers.main.android:assembleDebug') {
doLast {
def androidHome = System.env.ANDROID_HOME;
if (!androidHome) {
Properties local = new Properties()
local.load(new FileInputStream("local.properties"))
androidHome = local.getProperty('sdk.dir');
}
def adb = androidHome + '/platform-tools/adb'
println 'Copy files to your device...'
exec {
commandLine adb, 'uninstall', 'jsettlers.main.android'
}
exec {
commandLine adb, 'install', '-r', './jsettlers.main.android/build/outputs/apk/jsettlers.main.android-debug.apk'
}
exec {
commandLine adb, 'shell', 'am', 'start', '-n', 'jsettlers.main.android/jsettlers.main.android.JsettlersActivity'
}
println 'The application should have started now.'
}
}
}
def releaseDir = project.file('release')
task releaseJSettlers(type: Zip) {
into('JSettlers') {
from { project.getRootProject().file('LICENSE.txt') }
from tasks.getByPath(':jsettlers.main.swing:shadowJar')
from tasks.getByPath(':jsettlers.mapcreator:jar')
from tasks.getByPath(':jsettlers.tools:jar')
from project.getRootProject().file('jsettlers.main.swing/src/main/resources/jsettlers/main/swing/icon.png')
into('dist') {
from project.getRootProject().file('dist')
}
into('maps') {
from project.getRootProject().file('maps/release')
}
into('dependencies') {
from tasks.getByPath(':jsettlers.main.swing:copyDependencies')
}
}
destinationDirectory.set(releaseDir);
archiveBaseName.set("JSettlers");
}
task releaseDedicatedServer(type: Copy) {
from tasks.getByPath(':jsettlers.network:shadowJar')
into releaseDir
}
if (findProject(':jsettlers.main.android')) {
task releaseAndroid(type: Zip, dependsOn: ':jsettlers.main.android:assembleDebug') {
into('JSettlers-Android') {
from { project.getRootProject().file('LICENSE.txt') }
from file(project(':jsettlers.main.android').getBuildDir().absolutePath + '/outputs/apk/debug/jsettlers.main.android-debug.apk')
rename 'jsettlers.main.android-debug.apk', 'JSettlers-Android.apk'
}
destinationDirectory.set(releaseDir);
archiveBaseName.set("JSettlers-Android");
}
}
task release(dependsOn: ['releaseJSettlers', 'releaseDedicatedServer', 'releaseAndroid'])
task deployToGithub(type: Exec, dependsOn: 'release') {
commandLine 'bash', './deploy.sh'
}
clean {
delete releaseDir
}