forked from playgameservices/play-games-plugin-for-unity
-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.gradle
754 lines (672 loc) · 25.2 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
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
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
/*
* Gradle file to build the Unity plugin for Google Play Game Services.
*/
buildscript {
repositories {
google()
mavenCentral()
mavenLocal()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.4.2'
}
}
allprojects {
repositories {
google()
mavenCentral()
}
}
/*
Project level variables
*/
project.ext {
os_name = System.getProperty("os.name").toLowerCase();
os_osx = os_name.contains("mac os x");
os_windows = os_name.contains("windows");
os_linux = os_name.contains("linux");
ndk_root = System.getProperty("ANDROID_NDK_ROOT")
if (ndk_root == null || ndk_root.isEmpty()) {
ndk_root = System.getenv("ANDROID_NDK_ROOT")
}
sdk_root = System.getProperty("ANDROID_HOME")
if (sdk_root == null || sdk_root.isEmpty()) {
sdk_root = System.getenv("ANDROID_HOME")
}
unity_exe = System.getProperty("UNITY_EXE")
if (unity_exe == null || unity_exe.isEmpty()) {
unity_exe = System.getenv("UNITY_EXE")
}
// Take a guess at where Unity is located as a last resort.
if (unity_exe == null || unity_exe.isEmpty()) {
if (os_osx) {
unity_exe ='/Applications/Unity/Unity.app/Contents/MacOS/Unity'
} else if (os_windows) {
unity_exe ='c:\\program files\\unity\\editor\\unity.exe'
} else {
unity_exe = 'Unity'
}
}
git_exe = System.getProperty("GIT_EXE")
if (git_exe == null || git_exe.isEmpty()) {
git_exe = System.getenv("GIT_EXE")
}
if (git_exe == null || git_exe.isEmpty()) {
git_exe = 'git'
}
// Also update in com.google.play.games/package.json
pluginVersion = "0.11.01"
// String for specifying the build mode.
// If 'eap', will include all files from the 'Protected' folder.
// If build mode is anything other than 'eap', assumes a regular public
// build.
// -PbuildMode=eap
if (!project.hasProperty('buildMode') || buildMode != 'eap') {
buildMode = 'public'
}
if (buildMode == 'eap') {
buildPath = file('build-eap').absolutePath
currentPluginPath = buildPath
currentPluginVersion = "${pluginVersion}-eap"
} else {
buildPath = file('build').absolutePath
currentPluginPath = buildPath
currentPluginVersion = "${pluginVersion}"
}
pluginSrc = file('Assets/Public/GooglePlayGames').absolutePath
manifestSrc = file('Assets/Plugins').absolutePath
protectedPluginSrc = file('Assets/Protected/GooglePlayGames').absolutePath
supportLib = file('SupportFiles/Public').absolutePath
protectedSupportLib = file('SupportFiles/Protected').absolutePath
supportLibProj = file("${buildPath}/SupportLibProject").absolutePath
supportLibGradle = "${buildPath}/SupportLibProject/build.gradle"
pluginBuildSrc = file("${buildPath}/PluginSrc/Assets/GooglePlayGames").absolutePath
manifestBuildSrc = file("${buildPath}/PluginSrc/Assets/Plugins").absolutePath
pluginProj = file("${buildPath}/PluginProject").absolutePath
samplesPath = file('Samples').absolutePath
protectedSamplesPath = file('Samples').absolutePath
samplesBuildSrc = file("${buildPath}/sampleSrc").absolutePath
exportPath = file("${buildPath}/plugin.unitypackage").absolutePath
currentPluginBasename = 'GooglePlayGamesPlugin'
currentPluginName = "${currentPluginBasename}-${currentPluginVersion}.unitypackage"
resolverDir = new File("${buildPath}/jarresolver").absolutePath
editorDir = "Assets/GooglePlayGames/com.google.play.games/Editor"
pluginRepoDir = "${pluginProj}/${editorDir}/m2repository"
// Determine where we are relative to the Assets directory.
def currentDirectory = file('.')
if (file('PluginDev/Assets').isDirectory()) {
assetsPath = file('PluginDev/Assets')
} else if (file('Assets').isDirectory()) {
assetsPath = file('Assets')
} else if (currentDirectory.getName() == 'Assets') {
assetsPath = currentDirectory
} else if (currentDirectory.getParentFile().getName() == 'Assets') {
assetsPath = currentDirectory.getParentFile()
} else {
throw new GradleException("Unable to locate Assets directory in path: $currentDirectory")
}
// String for specifying if samples are built.
// If 'off', only the plugin will be built.
// If sampleBuild mode is anything other than 'off', assume samples are
// built.
// -PsampleBuild=off
if (!project.hasProperty('sampleBuild') || sampleBuild != 'off') {
sampleBuild = 'on'
}
if (sampleBuild == 'on') {
sampleList = ['SmokeTest']
} else {
sampleList = []
}
jarresolver_uri = System.getProperty("RESOLVER_PACKAGE_URI")
jarresolver_repos = [
'https://github.com/googlesamples/unity-jar-resolver.git'
]
jarresolver_tag = 'v1.2.182';
}
if (!tasks.findByName('prebuild')) {
task prebuild() {
println('Local prebuild')
}
prebuild.dependsOn {
project.tasks.findAll { task -> task.ext.has('remoteTaskPhase') && task.ext.remoteTaskPhase == 'prebuild' }
}
}
if (!tasks.findByName('build')) {
task build() {
println('Local build')
}
build.dependsOn {
project.tasks.findAll { task -> task.ext.has('remoteTaskPhase') && task.ext.remoteTaskPhase == 'build' }
}
}
if (!tasks.findByName('postbuild')) {
task postbuild() {
println('Local postbuild')
}
postbuild.dependsOn {
project.tasks.findAll { task -> task.ext.has('remoteTaskPhase') && task.ext.remoteTaskPhase == 'postbuild' }
}
}
project.defaultTasks = ['prebuild', 'build', 'postbuild']
/**
Final task of building all the unity packages.
**/
task unity_package(dependsOn:'export_legacy_package') {
description = "Top level task for building the unity packages"
doLast {
println "Packaging Complete!"
}
// Mark this a build phase task for remoteTask support.
ext.remoteTaskPhase = 'build'
// Depends on packaging all the samples
dependsOn {
tasks.findAll { task -> task.name.startsWith('PackageSample') }
}
}
/**
Generate tasks for the samples. There are several tasks for each sample.
**/
sampleList.each { sampleName ->
def createTask = project.tasks.create('CreateSample' + sampleName)
def copySrcTask = project.tasks.create('CopySrcSample' + sampleName)
def copyBuildSrcTask = project.tasks.create('CopyBuildSrcSample' + sampleName)
def copyPluginSrcTask = project.tasks.create('CopyPluginSrcSample' + sampleName)
// this is the path to the source code
def sampleSrcDir = samplesPath + '/' + sampleName
// this is the path to the source code for eap code
def protectedSampleSrcDir = protectedSamplesPath + '/' + sampleName
// this is the path to the source code in the build dir
def sampleBuildSrcDir = samplesBuildSrc + '/' + sampleName
// this is the path to build the sample package
def sampleDestSrcDir = file("${pluginProj}/Samples/${sampleName}/Assets/${sampleName}").absolutePath
// this is the path for the plugin assets for the sample package
def samplePluginSrcDir = file("${pluginProj}/Samples/${sampleName}/Assets").absolutePath
// the relative path to the sample assets within the project.
def sampleAssets = "Assets/${sampleName}"
// the path to the plugin code that will be copied into the sample package
def pluginDir = file("${pluginProj}/Assets")
def sampleDir = file("${pluginProj}/Samples/${sampleName}/Assets/${sampleName}")
if (!sampleDir.exists()) {
sampleDir.mkdirs()
}
/*
Create the sample in the build directory
*/
createTask.description = "Create the ${sampleName} package"
createTask.dependsOn 'export_legacy_package'
createTask.doFirst {
delete "${pluginProj}/Samples/${sampleName}/Assets/${sampleName}"
def logFilename = "${pluginProj}/Samples/${sampleName}/CreateSample${sampleName}.log"
def argv = [
"-gvh_disable",
"-g.building",
"-batchmode",
"-createProject", "${pluginProj}/Samples/${sampleName}",
"-logFile", logFilename,
"-quit"
]
runUnity(argv, logFilename)
}
// This is a build task
createTask.ext.remoteTaskPhase = 'build'
/*
Copy the source of the sample into build dir.
This is done so it can be remoted and assembled as a part of a RemoteTask.
*/
copyBuildSrcTask.description = "Copies sample ${sampleName} source code to build area"
copyBuildSrcTask.doFirst {
copy {
from sampleSrcDir
into sampleBuildSrcDir
}
if (buildMode == 'eap') {
copy {
from protectedSampleSrcDir
into sampleBuildSrcDir
}
}
}
copyBuildSrcTask.doLast {
println 'copied ' + sampleSrcDir + ' to ' + sampleBuildSrcDir
}
copyBuildSrcTask.ext.remoteTaskPhase = 'prebuild'
/*
Copy the source of the sample into build target. Don't import the
sample package, since we want the latest source code.
*/
copySrcTask.description = "Copies sample ${sampleName} source code to sample project build area"
copySrcTask.dependsOn createTask, copyBuildSrcTask
copySrcTask.doFirst {
copy {
from sampleBuildSrcDir
into sampleDestSrcDir
}
}
copySrcTask.doLast {
println 'copied ' + sampleBuildSrcDir + ' to ' + sampleDestSrcDir
}
copySrcTask.ext.remoteTaskPhase = 'build'
/*
Copy the source of the plugin and jar resolver into build dir.
This is done so it can be remoted and assembled as a part of a RemoteTask.
*/
copyPluginSrcTask.description = "Copies plugin into sample ${sampleName} build area"
copyPluginSrcTask.dependsOn createTask, copySrcTask, 'export_legacy_package'
copyPluginSrcTask.doFirst {
copy {
from pluginDir
into samplePluginSrcDir
}
}
copyPluginSrcTask.doLast {
println 'copied ' + pluginDir + ' to ' + samplePluginSrcDir
}
copyPluginSrcTask.ext.remoteTaskPhase = 'build'
/*
Create the exported package
*/
def packageTask = project.tasks.create('PackageSample' + sampleName)
packageTask.description = "Package ${sampleName} sample"
packageTask.dependsOn createTask, copySrcTask, copyPluginSrcTask
packageTask.doLast {
def pluginAssets = file("${pluginProj}/Samples/${sampleName}/Assets/GooglePlayGames/com.google.play.games")
if (!pluginAssets.exists()) {
println 'Could not find ' + pluginAssets
}
def logFilename = "${pluginProj}/Samples/${sampleName}/ExportSample${sampleName}.log"
def argv = [
"-gvh_disable",
"-g.building",
"-batchmode",
"-projectPath", "${pluginProj}/Samples/${sampleName}",
"-buildTarget", "android",
"-logFile", logFilename,
"-exportPackage",
"${sampleAssets}",
"Assets/GooglePlayGames/com.google.play.games",
"Assets/Plugins/Android/GooglePlayGamesManifest.androidlib",
"${pluginProj}/Samples/${sampleName}.unitypackage",
"-quit"
]
runUnity(argv, logFilename)
}
packageTask.ext.remoteTaskPhase = 'build'
/*
Finally, copy the package to the source sample dir.
*/
def copySamplePackageTask = project.tasks.create('CopySamplePackage' + sampleName)
copySamplePackageTask.description = "Copy unity package for " + sampleName + " back to src dir"
copySamplePackageTask.doLast {
if (buildMode == 'eap') {
copy {
from file("${pluginProj}/Samples/${sampleName}.unitypackage")
into file("${protectedSamplesPath}/${sampleName}")
}
} else {
copy {
from file("${pluginProj}/Samples/${sampleName}.unitypackage")
into file("${samplesPath}/${sampleName}")
}
}
}
copySamplePackageTask.ext.remoteTaskPhase = 'postbuild'
}
task import_jarresolver() {
description = "Imports the jar resolver package into the plugin"
ext.remoteTaskPhase = 'build'
doFirst {
if (file(pluginProj).exists()) {
delete pluginProj
}
}
doLast {
def tree = fileTree("${resolverDir}")
{
include 'external-dependency-manager-latest.unitypackage'
}
def jarresolver_package = tree.getSingleFile()
def logFilename = "${pluginProj}/import_resolver_unity.log"
def argv = [
"-gvh_disable",
"-g.building",
"-batchmode",
"-createProject", "${pluginProj}",
"-logFile", logFilename,
"-importPackage", "${jarresolver_package}",
"-quit"
]
runUnity(argv, logFilename)
}
}
// don't explicitly depend on copy_jarresolver here since it is run
// as a prebuild step, and import_jarresolver is a build step which can happen
// on a machine with limited network connectivity.
// import_jarresolver.dependsOn "copy_jarresolver"
task copy_pluginProjSrc () {
doFirst {
copy {
from {"${pluginBuildSrc}"}
includes ["**/*"]
duplicatesStrategy DuplicatesStrategy.INCLUDE
into {"${pluginProj}/Assets/GooglePlayGames"}
}
copy {
from {"${manifestBuildSrc}"}
includes ["**/*"]
duplicatesStrategy DuplicatesStrategy.INCLUDE
into {"${pluginProj}/Assets/Plugins"}
}
}
doLast {
copy {
from {"${project.ext.buildPath}/m2repository"}
includes ["**/*"]
duplicatesStrategy DuplicatesStrategy.INCLUDE
into {"${pluginRepoDir}"}
}
}
}
copy_pluginProjSrc.dependsOn import_jarresolver
copy_pluginProjSrc.ext.remoteTaskPhase = 'build'
task generate_dependency_xml() {
description "Generate the JarResolver dependency file for the support library"
dependsOn copy_pluginProjSrc
doFirst {
def xmlFile = file("${pluginProj}/${editorDir}/${currentPluginBasename}Dependencies.xml")
xmlFile << '<?xml version="1.0" encoding="UTF-8" ?>\n'
xmlFile << '<dependencies>\n'
xmlFile << '<!-- Internal library dependency generated at build time. \n'
xmlFile << ' It also defines the transitive dependencies on play-services\n'
xmlFile << '-->\n'
xmlFile << ' <androidPackages>\n'
xmlFile << ' <androidPackage spec="com.google.games:gpgs-plugin-support:'
xmlFile << "${currentPluginVersion}\">\n"
xmlFile << ' <repositories>\n'
xmlFile << ' <repository>Assets/GooglePlayGames/com.google.play.games/Editor/m2repository</repository>\n'
xmlFile << ' </repositories>\n'
xmlFile << ' </androidPackage>\n'
xmlFile << ' </androidPackages>\n'
xmlFile << '</dependencies>\n'
}
}
task inject_versionIntoMetaFiles() {
description 'Inject the version number into the plugin\'s meta files.'
dependsOn copy_pluginProjSrc, generate_dependency_xml, import_jarresolver
doLast {
def currentManifestFile = versionedAssetName("${currentPluginBasename}.txt", "${currentPluginVersion}")
for (fileobj in fileTree("${pluginProj}")) {
if (fileobj.path.endsWith('.meta')) {
// Skip the manifest files for any previous versions
// Skip any files in 'PackageCache' subdirectory
if (fileobj.path.contains("Editor/${currentPluginBasename}") &&
!fileobj.path.contains(currentManifestFile) ||
fileobj.path.contains("PackageCache")) {
continue
}
def lines = fileobj.text.split('\n')
def outputLines = []
def added = false
for (line in lines) {
outputLines.add(line)
if (line.contains('labels:')) {
outputLines.add("- gvh_v${currentPluginVersion}")
added = true
} else if (line.contains('folderAsset:') && line.contains('yes')) {
added = true
}
}
if (!added) {
outputLines.add("labels:\n- gvh_v${currentPluginVersion}")
}
fileobj.write(outputLines.join('\n') + '\n')
}
}
}
}
task generate_manifest(dependsOn: [ 'inject_versionIntoMetaFiles']) {
description 'Generate a manifest for the files in the plug-in.'
doLast {
def dir = file("${pluginProj}/Assets")
def list = []
dir.eachFileRecurse(groovy.io.FileType.FILES) { filename ->
def path = filename.path
if (!path.toLowerCase().endsWith('.meta')) {
list << filename.path.replace("${pluginProj}/", '')
}
}
def manifest = file("${pluginProj}/${editorDir}/" +
versionedAssetName(currentPluginBasename + '.txt', "${currentPluginVersion}"))
manifest.write(list.join('\n') + '\n')
}
}
task copy_manifestMetadata(dependsOn: generate_manifest, type: Copy) {
def manifestBasename = versionedAssetName(currentPluginBasename + '.txt',
null) + '.meta'
description 'Copy .meta file for the plugin manifest.'
from file("${pluginProj}/${editorDir}/" + manifestBasename)
into file("${pluginProj}/${editorDir}/")
rename {
String fn ->
return fn.replace(manifestBasename,
versionedAssetName(currentPluginBasename + '.txt',
"${currentPluginVersion}") + '.meta')
}
}
task export_legacy_package () {
description = "Creates and exports the Plugin unity package"
doFirst {
ext.path = "${pluginProj}/${editorDir}/projsettings.txt"
delete '${ext.path}'
}
doLast {
def logFilename = "${pluginProj}/unity.log"
def argv = [
"-g.building",
// This prevents the VersionHandler to preserve the plugin layout
"-gvh_disable",
// NOTE: This doesn't target Android since we don't want to have
// dependencies on the Jar Resolver as they require the plugin to
// be enabled during the build process which would break the
// versioning process. Compilation is verified when exporting
// the sample projects.
"-batchmode",
"-projectPath", "${pluginProj}",
"-logFile", logFilename,
"-exportPackage",
"Assets/GooglePlayGames/com.google.play.games",
"Assets/Plugins/Android/GooglePlayGamesManifest.androidlib",
"Assets/ExternalDependencyManager",
"${exportPath}",
"-quit"
]
runUnity(argv, logFilename)
}
}
export_legacy_package.dependsOn generate_manifest, import_jarresolver, copy_manifestMetadata
export_legacy_package.dependsOn copy_pluginProjSrc
export_legacy_package.ext.remoteTaskPhase = 'build'
task export_plugin_tgz_setup() {
description 'Creates a gradle task for each UPM .tgz that we need to generate'
fileTree(assetsPath).matching {
include '**/package.json'
}.each {
def packageJsonFile ->
println 'Package.json file found at ' + packageJsonFile
def packageJson = new groovy.json.JsonSlurper().parse(packageJsonFile)
def packageName = packageJson.name
def packageVersion = packageJson.version
// Create a Tar task for each package.
def task = tasks.create(name: "upmTar-${packageName}", type: Tar) {
compression = Compression.GZIP
archiveFileName = "${packageName}-${packageVersion}.tgz"
destinationDirectory = file("${project.ext.buildPath}")
into('package') {
from file("${pluginProj}/Assets/GooglePlayGames/${packageName}")
}
}
task.dependsOn generate_manifest, import_jarresolver, copy_manifestMetadata
task.dependsOn copy_pluginProjSrc
}
}
export_plugin_tgz_setup.ext.remoteTaskPhase = 'build'
task export_plugin_tgz(dependsOn: export_plugin_tgz_setup) {
description 'Creates a Unity Package Manager .tgz file for every package in the project'
doFirst {
println "Creating .tgz packages."
}
// Lazily add a dependency on each of the package creation tasks.
dependsOn {
tasks.findAll { task -> task.name.startsWith('upmTar') }
}
}
export_plugin_tgz.ext.remoteTaskPhase = 'build'
/*
Copy the plugin to the current-build directory
*/
task copy_plugin() {
description = 'Copy plugin to the current-build directory'
doFirst {
copy {
from file(exportPath)
into file(currentPluginPath)
rename ('plugin.unitypackage', currentPluginName)
}
}
doLast {
println "Copied ${exportPath} to ${currentPluginPath}"
}
ext.remoteTaskPhase = 'postbuild'
}
task copy_plugin_source {
description = "Copies plugin source into build directory"
ext.remoteTaskPhase = 'prebuild'
doFirst {
copy {
from("${pluginSrc}") {
exclude '**/Samples', '**/Samples.meta'
}
into {"${pluginBuildSrc}"}
}
copy {
from("${manifestSrc}")
into {"${manifestBuildSrc}"}
}
println "Copied ${manifestSrc} to ${manifestBuildSrc}"
if (buildMode == 'eap') {
copy {
from("${protectedPluginSrc}") {
exclude 'README.md', '**/Samples', '**/Samples.meta'
}
into {"${pluginBuildSrc}"}
}
}
}
}
task copy_supportlib_source {
description = "Copies support lib source into build directory for EAPs only"
ext.remoteTaskPhase = 'prebuild'
copy {
from("${supportLib}")
into {"${supportLibProj}"}
}
if (buildMode == 'eap') {
copy {
from("${protectedSupportLib}") {
exclude 'README.md'
}
into {"${supportLibProj}"}
}
}
}
task copy_jarresolver() {
description = "Clones the jar resolver project and copied into the build."
ext.remoteTaskPhase = "prebuild"
dependsOn copy_plugin_source
doFirst {
if (file(resolverDir).exists()) {
delete resolverDir
}
}
doLast {
if (jarresolver_uri != null) {
mkdir("${resolverDir}")
def resolver = new File("${resolverDir}/resolver.unitypackage")
new URL("${jarresolver_uri}").withInputStream {
inputStream -> resolver.withOutputStream { it << inputStream }
}
return
}
for (repo in jarresolver_repos) {
println 'clone ' + repo
def result = exec {
executable "${git_exe}"
args "clone", repo, "${resolverDir}"
ignoreExitValue true
}
if (result.exitValue == 0 && jarresolver_tag != null) {
result = exec {
executable "${git_exe}"
args "checkout", "-b", "buildver", "${jarresolver_tag}"
workingDir "${resolverDir}"
}
}
if (result.exitValue == 0) {
println "Downloaded resolver from " + repo
return
}
}
}
}
task build_java_support_lib(type: GradleBuild) {
description = "Builds the client libraries for Android"
buildFile = supportLibGradle
dependsOn copy_supportlib_source
startParameter.projectProperties.put('projVersion',currentPluginVersion)
startParameter.projectProperties.put('uploadDir', "${project.ext.buildPath}/m2repository")
tasks = ['build', 'publish']
}
build_java_support_lib.ext.remoteTaskPhase = 'prebuild'
task clean_support_lib(type: GradleBuild) {
description = "cleans the client libraries for Android"
buildFile = supportLibGradle
tasks = ['clean']
}
task clean() {
doFirst {
delete 'build'
}
dependsOn clean_support_lib
}
tasks.findAll { task -> task.ext.has('remoteTaskPhase') && task.ext.remoteTaskPhase == 'build' }*.dependsOn('prebuild')
tasks.findAll { task -> task.ext.has('remoteTaskPhase') && task.ext.remoteTaskPhase == 'postbuild' }*.dependsOn('build')
// Construct the name of a versioned asset from the source filename and version
// // string.
// // The encoded string takes the form...
// // ${filename}_v${version}_.${extension}
// // where extension is derived from the specified filename.
def versionedAssetName(filename, version) {
def extensionIndex = filename.lastIndexOf('.')
def basename = filename.substring(0, extensionIndex)
def extension = filename.substring(extensionIndex)
// Encode the DLL version and target names into the DLL in the form...
// ${dllname}_t${hypen_separated_target_names}_v${version}.dll
def targetName = basename
if (version != null && !version.isEmpty()) {
targetName += '_v' + version
}
return targetName + extension
}
def runUnity(argv, logFilename) {
def result = exec {
executable "${project.ext.unity_exe}"
args argv
ignoreExitValue true
}
if (result.exitValue != 0) {
println "***Error Running Unity: ${result}"
def src = file(logFilename).text
print src
throw new GradleException('error exporting sample')
}
}