forked from jMonkeyEngine/jmonkeyengine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle
More file actions
318 lines (277 loc) · 10.5 KB
/
build.gradle
File metadata and controls
318 lines (277 loc) · 10.5 KB
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
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
buildscript {
repositories {
mavenCentral()
google()
maven {
url = "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath libs.android.build.gradle
classpath libs.spotbugs.gradle.plugin
}
}
plugins {
id 'org.jmonkeyengine.nativeimage' apply false
}
import org.gradle.api.file.RelativePath
// Set the license for IDEs that understand this
ext.license = file("$rootDir/source-file-header-template.txt")
apply plugin: 'base'
apply from: file('version.gradle')
allprojects {
repositories {
mavenCentral()
google()
}
tasks.withType(Jar) {
duplicatesStrategy = 'include'
}
}
// This is applied to all sub projects
subprojects {
if(!project.name.equals('jme3-android-examples')) {
apply from: rootProject.file('common.gradle')
} else {
apply from: rootProject.file('common-android-app.gradle')
}
if (!project.name.endsWith("-native") && enableSpotBugs != "false" ) {
apply plugin: 'com.github.spotbugs'
// Currently we only warn about issues and try to fix them as we go, but those aren't mission critical.
spotbugs {
ignoreFailures = true
toolVersion = libs.versions.spotbugs.get()
}
tasks.withType(com.github.spotbugs.snom.SpotBugsTask ) {
reports {
html.required = !project.hasProperty("xml-reports")
xml.required = project.hasProperty("xml-reports")
}
}
}
}
def nativeImagePluginBuild = gradle.includedBuild('jme3-nativeimage-plugin')
def nativeImagePluginPublishTasks = [
publish : ':publish',
publishToMavenLocal : ':publishToMavenLocal',
install : ':install',
publishAllPublicationsToCentralRepository : ':publishAllPublicationsToCentralRepository',
publishAllPublicationsToSNAPSHOTRepository : ':publishAllPublicationsToSNAPSHOTRepository',
publishAllPublicationsToDistRepository : ':publishAllPublicationsToDistRepository'
]
subprojects {
tasks.configureEach { task ->
String includedTaskPath = nativeImagePluginPublishTasks[task.name]
if (includedTaskPath != null) {
task.dependsOn nativeImagePluginBuild.task(includedTaskPath)
}
}
}
tasks.register('run') {
dependsOn ':jme3-examples:run'
description = 'Run the jME3 examples'
}
defaultTasks 'run'
def libDist = tasks.register('libDist') {
dependsOn(subprojects.collect { it.tasks.named('build') })
description = 'Builds and copies the engine binaries, sources and javadoc to build/libDist'
doLast {
File libFolder = mkdir("$buildDir/libDist/lib")
File sourceFolder = mkdir("$buildDir/libDist/sources")
File javadocFolder = mkdir("$buildDir/libDist/javadoc")
subprojects.each {project ->
if(!project.hasProperty('mainClassName')){
project.tasks.withType(Jar).each {archiveTask ->
String classifier = archiveTask.archiveClassifier.get()
String ext = archiveTask.archiveExtension.get()
File archiveFile = archiveTask.archiveFile.get().asFile
if (classifier == "sources") {
copy {
from archiveFile
into sourceFolder
rename {project.name + '-' + classifier + '.' + ext}
}
} else if (classifier == "javadoc") {
copy {
from archiveFile
into javadocFolder
rename {project.name + '-' + classifier + '.' + ext}
}
} else{
copy {
from archiveFile
into libFolder
rename {project.name + '.' + ext}
}
}
}
}
}
}
}
tasks.register('createZipDistribution', Zip) {
dependsOn(tasks.named('dist'), libDist)
description = 'Package the nightly zip distribution'
archiveFileName = provider {
"jME" + jmeFullVersion + ".zip"
}
into("/") {
from {"./dist"}
}
into("/sources") {
from {"$buildDir/libDist/sources"}
}
}
tasks.register('copyLibs', Copy) {
// description 'Copies the engine dependencies to build/libDist'
from {
subprojects*.configurations*.implementation*.copyRecursive({ !(it instanceof ProjectDependency); })*.resolve()
}
into "$buildDir/libDist/lib-ext" //buildDir.path + '/' + libsDirName + '/lib'
}
tasks.register('dist') {
dependsOn ':jme3-examples:dist', tasks.named('mergedJavadoc')
description = 'Creates a jME3 examples distribution with all jme3 binaries, sources, javadoc and external libraries under ./dist'
}
def mergedJavadocSubprojects = [
":jme3-android",
":jme3-core",
":jme3-desktop",
":jme3-effects",
":jme3-ios",
":jme3-jbullet",
":jme3-jogg",
":jme3-lwjgl",
":jme3-lwjgl3",
":jme3-networking",
":jme3-niftygui",
":jme3-plugins",
":jme3-terrain",
]
tasks.register('mergedJavadoc', Javadoc) {
description = 'Creates Javadoc from all the projects.'
title = 'jMonkeyEngine3'
destinationDir = file("dist/javadoc")
options.encoding = 'UTF-8'
if (JavaVersion.current().isJava8Compatible()) {
options.addStringOption('Xdoclint:none', '-quiet')
}
options.overview = file("javadoc-overview.html")
source = mergedJavadocSubprojects.collect { project(it).sourceSets.main.allJava }
classpath = files(mergedJavadocSubprojects.collect { project(it).sourceSets.main.compileClasspath })
}
def cleanMergedJavadoc = tasks.register('cleanMergedJavadoc', Delete) {
delete file('dist/javadoc')
}
tasks.named('clean') {
dependsOn cleanMergedJavadoc
}
ext {
ndkCommandPath = ""
ndkExists = false
}
apply from: 'gradle/jacoco.gradle'
task configureAndroidNDK {
def ndkBuildFile = "ndk-build"
// if windows, use ndk-build.cmd instead
if (System.properties['os.name'].toLowerCase().contains('windows')) {
ndkBuildFile = "ndk-build.cmd"
}
def ndkCandidates = []
if (System.env.ANDROID_NDK) {
ndkCandidates << file(System.env.ANDROID_NDK)
}
if (System.env.ANDROID_NDK_HOME) {
ndkCandidates << file(System.env.ANDROID_NDK_HOME)
}
if (project.hasProperty('ndkPath') && ndkPath) {
ndkCandidates << file(ndkPath)
}
def localProperties = file('local.properties')
if (localProperties.isFile()) {
Properties properties = new Properties()
localProperties.withInputStream { properties.load(it) }
if (properties.getProperty('ndk.dir')) {
ndkCandidates << file(properties.getProperty('ndk.dir'))
}
if (properties.getProperty('sdk.dir')) {
ndkCandidates.addAll(findAndroidNdkDirs(file(properties.getProperty('sdk.dir'))))
}
}
if (System.env.ANDROID_HOME) {
ndkCandidates.addAll(findAndroidNdkDirs(file(System.env.ANDROID_HOME)))
}
if (System.env.ANDROID_SDK_ROOT) {
ndkCandidates.addAll(findAndroidNdkDirs(file(System.env.ANDROID_SDK_ROOT)))
}
ndkCandidates.addAll(findAndroidNdkDirs(file("${System.properties['user.home']}/Android/Sdk")))
def ndkBuildPath = ndkCandidates.collect { new File(it, ndkBuildFile) }.find { it.isFile() }
if (ndkBuildPath != null) {
ndkExists = true
ndkCommandPath = ndkBuildPath.absolutePath
}
}
def findAndroidNdkDirs(File sdkDir) {
def ndkDirs = []
def nestedSdkDir = new File(sdkDir, 'Sdk')
if (nestedSdkDir.isDirectory()) {
ndkDirs.addAll(findAndroidNdkDirs(nestedSdkDir))
}
def sideBySideDir = new File(sdkDir, 'ndk')
if (sideBySideDir.isDirectory()) {
ndkDirs.addAll(sideBySideDir.listFiles()?.findAll { it.isDirectory() }?.sort { a, b -> b.name <=> a.name } ?: [])
}
ndkDirs << new File(sdkDir, 'ndk-bundle')
return ndkDirs
}
gradle.rootProject.ext.set("usePrebuildNatives", buildNativeProjects!="true");
if (skipPrebuildLibraries != "true" && buildNativeProjects != "true") {
File nativesSnapshotPropF = file('natives-snapshot.properties')
if (nativesSnapshotPropF.exists()) {
def readNativesConfig = {
Properties nativesSnapshotProp = new Properties()
nativesSnapshotPropF.withInputStream { nativesSnapshotProp.load(it) }
String nativesSnapshot = nativesSnapshotProp.getProperty("natives.snapshot")
if (!nativesSnapshot) {
throw new GradleException("Missing 'natives.snapshot' in ${nativesSnapshotPropF}")
}
[
snapshot: nativesSnapshot,
url: PREBUILD_NATIVES_URL.replace('${natives.snapshot}', nativesSnapshot),
zipFile: layout.buildDirectory.file("${nativesSnapshot}-natives.zip"),
nativeDir: layout.buildDirectory.dir("native"),
]
}
def nativesZipFile = providers.provider { readNativesConfig().zipFile.get().asFile }
def nativesPath = layout.buildDirectory.dir("native")
def getNativesZipFile = tasks.register('getNativesZipFile') {
outputs.file(nativesZipFile)
doFirst {
def nativesConfig = readNativesConfig()
File target = nativesConfig.zipFile.get().asFile
println("Use natives snapshot: ${nativesConfig.url}")
println("Download natives from ${nativesConfig.url} to ${target}")
target.getParentFile().mkdirs()
ant.get(src: nativesConfig.url, dest: target)
}
}
def extractPrebuiltNatives = tasks.register('extractPrebuiltNatives', Sync) {
dependsOn(getNativesZipFile)
into(nativesPath)
from({
zipTree(readNativesConfig().zipFile.get().asFile)
}) {
eachFile { details ->
def segments = details.relativePath.segments
if (segments.length > 1) {
details.path = segments[1..-1].join('/')
}
}
includeEmptyDirs = false
}
}
tasks.named('assemble') {
dependsOn extractPrebuiltNatives
}
}
}