forked from jsettlers/settlers-remake
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
208 lines (170 loc) · 6.4 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
// Top-level build file where you can add configuration options common to all sub-projects/modules.
apply plugin: 'java'
ext {
streamSupportVersion = '1.5.4'
androidAnnotationsVersion = '4.3.0'
androidSupportLibraryVersion = '25.3.1'
androidBuildToolsVersion = '25.0.3'
androidCompileSdkVersion = 25
androidMinSdkVersion = 19
androidTargetSdkVersion = 25
}
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'org.eclipse.jgit:org.eclipse.jgit:3.1.0.201310021548-r'
classpath 'com.android.tools.build:gradle:2.2.3'
classpath 'me.tatarka:gradle-retrolambda:3.4.0'
}
}
allprojects {
repositories {
mavenCentral()
jcenter()
maven { url "https://raw.github.com/laenger/maven-releases/master/releases" }
}
}
subprojects {
apply plugin: 'me.tatarka.retrolambda'
plugins.withType(JavaPlugin).whenPluginAdded {
test {
testLogging {
events "failed"
exceptionFormat "short"
}
}
compileJava {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
compileTestJava {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
task copyMainResources(type: Copy) {
from sourceSets.main.resources
into sourceSets.main.output.classesDir
}
processResources.dependsOn copyMainResources
task copyTestResources(type: Copy) {
from sourceSets.test.resources
into sourceSets.test.output.classesDir
}
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 {
events 'passed'
}
}
tasks.withType(Jar) {
duplicatesStrategy 'exclude'
}
plugins.withId("me.tatarka.retrolambda") {
retrolambda {
jdk System.getenv("JAVA_HOME")
oldJdk System.getenv("JAVA_HOME")
javaVersion JavaVersion.VERSION_1_7
incremental true
}
}
// Add streamsupport dependency
def addGlobalDependencies = {
dependencies {
compile 'net.sourceforge.streamsupport:streamsupport:' + rootProject.ext.streamSupportVersion
compile 'net.sourceforge.streamsupport:streamsupport-cfuture:' + rootProject.ext.streamSupportVersion
compile 'net.sourceforge.streamsupport:streamsupport-atomic:' + rootProject.ext.streamSupportVersion
compile 'net.sourceforge.streamsupport:streamsupport-flow:' + rootProject.ext.streamSupportVersion
compile 'net.sourceforge.streamsupport:streamsupport-literal:' + rootProject.ext.streamSupportVersion
testCompile 'junit:junit:4.12'
}
}
plugins.withId('java', 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') << {
// We do not need any more tasks.
tasks.getAsMap().values().each { Task 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") }
task runMapCreator(dependsOn: ':jsettlers.mapcreator:run') {}
if (findProject(':jsettlers.main.android')) {
// Android is present.
task runAndroid(dependsOn: ':jsettlers.main.android:assembleDebug') << {
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:releaseJar')
from tasks.getByPath(':jsettlers.mapcreator:releaseJar')
into('maps') {
from project.getRootProject().file('maps/release')
}
}
destinationDir releaseDir
baseName "JSettlers"
}
task releaseDedicatedServer(type: Copy) {
from tasks.getByPath(':jsettlers.network:jar')
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/jsettlers.main.android-debug.apk')
rename 'jsettlers.main.android-debug.apk', 'JSettlers-Android.apk'
}
destinationDir releaseDir
baseName "JSettlers-Android"
}
}
task release(dependsOn: ['releaseJSettlers', 'releaseDedicatedServer', 'releaseAndroid'])
task deployToGithub(type: Exec, dependsOn: 'release') {
commandLine 'bash', './deploy.sh'
}
clean {
delete releaseDir
}