forked from jsettlers/settlers-remake
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
159 lines (128 loc) · 4.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
// Top-level build file where you can add configuration options common to all sub-projects/modules.
apply plugin: 'java'
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'org.eclipse.jgit:org.eclipse.jgit:3.1.0.201310021548-r'
classpath 'com.android.tools.build:gradle:2.1.0'
}
}
allprojects {
repositories {
jcenter()
}
}
subprojects {
plugins.withType(JavaPlugin).whenPluginAdded {
compileJava {
sourceCompatibility = 1.7
targetCompatibility = 1.7
}
compileTestJava {
sourceCompatibility = 1.8
targetCompatibility = 1.8
}
dependencies {
testCompile 'junit:junit:4.12'
}
//sourceSets.main.output.resourcesDir = sourceSets.main.output.classesDir
if (gradle.ext.projectsWithExtraTest.contains(project.path)) {
// println "Disable tests for " + project
project.test.onlyIf ( {p -> false} )
project.compileTestJava.onlyIf ( {p -> false} )
println sourceSets.test.getClass()
}
if (project.name == 'test' && gradle.ext.projectsWithExtraTest.contains(project.parent.path)) {
// println "Configure additional tests for " + project.parent
sourceSets.main.java.exclude { f -> true }
sourceSets.main.resources.exclude { f -> true }
sourceSets.test.java.srcDirs = parent.sourceSets.test.java.srcDirs;
sourceSets.test.resources.srcDirs = parent.sourceSets.test.resources.srcDirs;
parent.sourceSets.test.java.srcDirs = [];
parent.sourceSets.test.resources.srcDirs = [];
parent.sourceSets.test.java.exclude { f -> true }
parent.sourceSets.test.resources.exclude { f -> true }
compileJava {
sourceCompatibility = 1.8
targetCompatibility = 1.8
}
dependencies {
compile project.parent
testCompile project(':jsettlers.testutils')
}
}
}
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 'started', 'passed'
}
}
}
// 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') {}
task runAndroid(dependsOn: ':jsettlers.main.android:assembleDebug') << {
Properties local = new Properties()
local.load(new FileInputStream("local.properties"))
def adb = local.getProperty('sdk.dir') + '/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
}
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'])
clean {
delete releaseDir
}