forked from wttech/gradle-aem-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAemExtension.kt
716 lines (598 loc) · 24.8 KB
/
AemExtension.kt
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
package com.cognifide.gradle.aem
import com.cognifide.gradle.aem.bundle.BundlePlugin
import com.cognifide.gradle.aem.bundle.tasks.BundleCompose
import com.cognifide.gradle.aem.common.CommonPlugin
import com.cognifide.gradle.aem.common.build.*
import com.cognifide.gradle.aem.common.file.FileOperations
import com.cognifide.gradle.aem.common.file.FileWatcher
import com.cognifide.gradle.aem.common.file.resolver.FileResolver
import com.cognifide.gradle.aem.common.file.transfer.FileTransferManager
import com.cognifide.gradle.aem.common.file.transfer.http.HttpFileTransfer
import com.cognifide.gradle.aem.common.file.transfer.sftp.SftpFileTransfer
import com.cognifide.gradle.aem.common.file.transfer.smb.SmbFileTransfer
import com.cognifide.gradle.aem.common.http.HttpClient
import com.cognifide.gradle.aem.common.instance.*
import com.cognifide.gradle.aem.common.notifier.NotifierFacade
import com.cognifide.gradle.aem.common.pkg.PackageDefinition
import com.cognifide.gradle.aem.common.pkg.PackageFile
import com.cognifide.gradle.aem.common.pkg.PackageOptions
import com.cognifide.gradle.aem.common.pkg.PackageValidator
import com.cognifide.gradle.aem.common.pkg.vlt.FilterFile
import com.cognifide.gradle.aem.common.utils.Formats
import com.cognifide.gradle.aem.common.utils.LineSeparator
import com.cognifide.gradle.aem.common.utils.Patterns
import com.cognifide.gradle.aem.environment.Environment
import com.cognifide.gradle.aem.environment.EnvironmentPlugin
import com.cognifide.gradle.aem.environment.docker.RunSpec
import com.cognifide.gradle.aem.instance.*
import com.cognifide.gradle.aem.pkg.PackagePlugin
import com.cognifide.gradle.aem.pkg.tasks.PackageCompose
import com.cognifide.gradle.aem.tooling.ToolingPlugin
import com.cognifide.gradle.aem.tooling.rcp.RcpClient
import com.cognifide.gradle.aem.tooling.vlt.VltException
import com.cognifide.gradle.aem.tooling.vlt.VltClient
import com.cognifide.gradle.aem.tooling.vlt.VltSummary
import com.fasterxml.jackson.annotation.JsonIgnore
import java.io.File
import java.io.Serializable
import org.gradle.api.Project
import org.gradle.api.Task
import org.gradle.api.tasks.Internal
/**
* Core of library, facade for implementing tasks, configuration aggregator.
*/
@Suppress("TooManyFunctions")
class AemExtension(@JsonIgnore val project: Project) : Serializable {
@JsonIgnore
val logger = project.logger
/**
* Allows to read project property specified in command line and system property as a fallback.
*/
@JsonIgnore
val props = PropertyParser(this)
/**
* Access configuration for local instances or environment from different project (cross-project configuring).
*/
@get:JsonIgnore
val main: AemExtension
get() = of(projectMain)
/**
* Project under which common configuration files are stored.
* Usually it is also configures local instances and environment (is applying corresponding plugins).
*
* Convention assumes in case of:
* - multi-project build - subproject with path ':aem'
* - single-project build - root project
*/
@JsonIgnore
val projectMain: Project = project.findProject(props.string("projectMainPath") ?: ":aem") ?: project.rootProject
/**
* Project name convention prefixes used to determine default:
*
* - bundle install subdirectory
* - CRX package base name
* - OSGi bundle JAR base name
*
* in case of multi-project build and assembly packages.
*/
val projectPrefixes: List<String> = props.list("projectPrefixes") ?: listOf("aem.", "aem-", "aem_")
/**
* Project name with skipped convention prefixes.
*/
val projectName: String
get() = project.name.run {
var n = this; projectPrefixes.forEach { n = n.removePrefix(it) }; n
}
/**
* Base name used as default for CRX packages being created by compose or collect task
* and also for OSGi bundle JARs.
*/
val baseName: String
get() = Formats.normalizeSeparators(if (project == project.rootProject) {
project.rootProject.name
} else {
"${project.rootProject.name}.$projectName"
}, ".")
/**
* Allows to disable features that are using running AEM instances.
*
* It is more soft offline mode than Gradle's one which does much more.
* It will not use any Maven repository so that CI build will fail which is not expected in e.g integration tests.
*/
val offline = props.flag("offline")
/**
* Determines current environment name to be used in e.g package deployment.
*/
val env: String = props.string("env") ?: run { System.getenv("ENV") ?: "local" }
/**
* Specify characters to be used as line endings when cleaning up checked out JCR content.
*/
var lineSeparator: String = props.string("lineSeparator") ?: "LF"
@JsonIgnore
val lineSeparatorString: String = LineSeparator.string(lineSeparator)
/**
* Directory for storing project specific files used by plugin e.g:
* - Groovy Scripts to be launched by Groovy Console instance service in tasks defined in project.
*/
val configDir: File
get() = project.file(props.string("configDir") ?: "gradle")
/**
* Directory for storing common files used by plugin e.g:
* - CRX package thumbnail
* - environment configuration files (HTTPD virtual hosts, Dispatcher)
* - instance overrides files
* - tail incident filter
*/
val configCommonDir: File
get() = projectMain.file(props.string("configCommonDir") ?: "gradle")
@get:Internal
val fileTransfer = FileTransferManager(this)
/**
* Define settings for file transfer facade which allows to perform basic file operations on remote servers
* like uploading and downloading files.
*
* Supports multiple protocols: HTTP, SFTP, SMB and other supported by JVM.
*/
fun fileTransfer(options: FileTransferManager.() -> Unit) {
fileTransfer.apply(options)
}
val packageOptions = PackageOptions(this)
/**
* Defines common settings for built packages and deployment related behavior.
*/
fun `package`(options: PackageOptions.() -> Unit) {
packageOptions.apply(options)
}
/**
* Defines common settings for built packages and deployment related behavior.
*/
fun pkg(options: PackageOptions.() -> Unit) = `package`(options)
/**
* Read CRX package properties of specified ZIP file.
*/
fun `package`(file: File) = PackageFile(file)
/**
* Read CRX package properties of specified ZIP file.
*/
fun pkg(file: File) = `package`(file)
val instanceOptions = InstanceOptions(this)
/**
* Defines instances to work with.
*/
fun instance(options: InstanceOptions.() -> Unit) {
instanceOptions.apply(options)
}
val localInstanceManager = LocalInstanceManager(this)
/**
* Define common settings valid only for instances created at local file system.
*/
fun localInstance(options: LocalInstanceManager.() -> Unit) = localInstanceManager.apply(options)
/**
* Provides API for controlling virtualized AEM environment with HTTPD and dispatcher module.
*/
val environment = Environment(this)
fun environment(configurer: Environment.() -> Unit) {
environment.apply(configurer)
}
/**
* Provides API for displaying interactive notification during running build tasks.
*/
val notifier = NotifierFacade.of(this)
fun notifier(configurer: NotifierFacade.() -> Unit) {
notifier.apply(configurer)
}
/**
* Provides API for easier creation of tasks (e.g in sequence) in the matter of Gradle task configuration avoidance.
*/
@JsonIgnore
val tasks = AemTaskFacade(this)
fun tasks(configurer: AemTaskFacade.() -> Unit) {
tasks.apply(configurer)
}
/**
* Provides API for performing actions affecting multiple instances at once.
*/
@JsonIgnore
val instanceActions = InstanceActionPerformer(this)
/**
* Collection of all java packages from all projects applying bundle plugin.
*/
val javaPackages: List<String>
get() = AemPlugin.withId(project, BundlePlugin.ID).flatMap { subproject ->
of(subproject).tasks.bundles.mapNotNull { it.javaPackage }
}
/**
* All instances matching default filtering.
*
* @see <https://github.com/Cognifide/gradle-aem-plugin#filter-instances-to-work-with>
*/
@get:JsonIgnore
val instances: List<Instance>
get() = filterInstances()
/**
* Work in parallel with instances matching default filtering.
*/
fun instances(consumer: (Instance) -> Unit) = parallel.with(instances, consumer)
/**
* Work in parallel with instances which name is matching specified wildcard filter.
*/
fun instances(filter: String, consumer: (Instance) -> Unit) = parallel.with(filterInstances(filter), consumer)
/**
* Shorthand method for getting defined instance or creating temporary instance by URL.
*/
fun instance(urlOrName: String): Instance = instanceOptions.parse(urlOrName)
/**
* Shorthand method for getting defined instances or creating temporary instances by URLs.
*/
fun instances(urlsOrNames: Iterable<String>): List<Instance> = urlsOrNames.map { instance(it) }
/**
* Get instance from command line parameter named 'instance' which holds instance name or URL.
* If it is not specified, then first instance matching default filtering fill be returned.
*
* Purpose of this method is to easily get any instance to work with (no matter how it will be defined).
*
* @see <https://github.com/Cognifide/gradle-aem-plugin#filter-instances-to-work-with>
*/
@get:JsonIgnore
val anyInstance: Instance
get() {
val cmdInstanceArg = props.string("instance")
if (!cmdInstanceArg.isNullOrBlank()) {
return instance(cmdInstanceArg)
}
return namedInstance(Instance.FILTER_ANY)
}
/**
* Get available instance of any type (most often first defined).
*/
@get:JsonIgnore
val availableInstance: Instance?
get() = instances.asSequence().firstOrNull { it.available }
/**
* Get all instances which names are matching wildcard filter specified via command line parameter 'instance.name'.
* By default, this method respects current environment which is used to work only with instances running locally.
*
* If none instances will be found, throws exception.
*/
fun namedInstance(desiredName: String? = props.string("instance.name"), defaultName: String = "$env-*"): Instance {
val nameMatcher: String = desiredName ?: defaultName
val namedInstance = filterInstances(nameMatcher).firstOrNull()
if (namedInstance != null) {
return namedInstance
}
throw AemException("Instance named '$nameMatcher' is not defined.")
}
/**
* Find all instances which names are matching wildcard filter specified via command line parameter 'instance.name'.
*/
fun filterInstances(nameMatcher: String = props.string("instance.name") ?: "$env-*"): List<Instance> {
val all = instanceOptions.defined.values
// Specified by command line should not be filtered
val cmd = all.filter { it.environment == Instance.ENVIRONMENT_CMD }
if (cmd.isNotEmpty()) {
return cmd
}
// Defined by build script, via properties or defaults are filterable by name
return all.filter { instance ->
when {
props.flag("instance.author", "instance.authors") -> instance.author
props.flag("instance.publish", "instance.publishes", "instance.publishers") -> instance.publish
else -> Patterns.wildcard(instance.name, nameMatcher)
}
}
}
/**
* Get all author instances running on current environment.
*/
@get:JsonIgnore
val authorInstances: List<Instance>
get() = filterInstances().filter { it.author }
@get:JsonIgnore
val authorInstance: Instance
get() = authorInstances.firstOrNull() ?: throw AemException("No author instances defined!")
/**
* Work in parallel with all author instances running on current environment.
*/
fun authorInstances(consumer: (Instance) -> Unit) = parallel.with(authorInstances, consumer)
/**
* Get all publish instances running on current environment.
*/
@get:JsonIgnore
val publishInstances: List<Instance>
get() = filterInstances().filter { it.publish }
@get:JsonIgnore
val publishInstance: Instance
get() = publishInstances.firstOrNull() ?: throw AemException("No publish instances defined!")
/**
* Work in parallel with all publish instances running on current environment.
*/
fun publishInstances(consumer: Instance.() -> Unit) = parallel.with(publishInstances, consumer)
/**
* Get all local instances.
*/
@get:JsonIgnore
val localInstances: List<LocalInstance>
get() = instances.filterIsInstance(LocalInstance::class.java)
/**
* Work in parallel with all local instances.
*/
fun localInstances(consumer: LocalInstance.() -> Unit) = parallel.with(localInstances, consumer)
/**
* Get all remote instances.
*/
@get:JsonIgnore
val remoteInstances: List<RemoteInstance>
get() = instances.filterIsInstance(RemoteInstance::class.java)
/**
* Work in parallel with all remote instances.
*/
fun remoteInstances(consumer: RemoteInstance.() -> Unit) = parallel.with(remoteInstances, consumer)
/**
* Get CRX package defined to be built (could not yet exist).
*/
@Suppress("VariableNaming")
@get:JsonIgnore
val `package`: File
get() = tasks.get(PackageCompose.NAME, PackageCompose::class.java).composedFile
@get:JsonIgnore
val pkg: File
get() = `package`
/**
* Get all CRX packages defined to be built.
*/
@get:JsonIgnore
val packages: List<File>
get() = tasks.packages.map { it.composedFile }
/**
* Get all CRX packages built before running particular task.
*/
fun dependentPackages(task: Task): List<File> {
return task.taskDependencies.getDependencies(task)
.filterIsInstance(PackageCompose::class.java)
.map { it.composedFile }
}
/**
* Get OSGi bundle defined to be built (could not yet exist).
*/
@get:JsonIgnore
val bundle: File
get() = tasks.get(BundleCompose.NAME, BundleCompose::class.java).composedFile
/**
* Get all OSGi bundles defined to be built.
*/
@get:JsonIgnore
val bundles: List<File>
get() = tasks.bundles.map { it.composedFile }
/**
* Get all OSGi bundles built before running particular task.
*/
fun dependentBundles(task: Task): List<File> {
return task.taskDependencies.getDependencies(task)
.filterIsInstance(BundleCompose::class.java)
.map { it.composedFile }
}
/**
* In parallel, work with services of all instances matching default filtering.
*/
fun sync(synchronizer: InstanceSync.() -> Unit) = sync(instances, synchronizer)
/**
* Work with instance services of specified instance.
*/
fun <T> sync(instance: Instance, synchronizer: InstanceSync.() -> T) = instance.sync(synchronizer)
/**
* In parallel, work with services of all specified instances.
*/
fun sync(instances: Iterable<Instance>, synchronizer: InstanceSync.() -> Unit) {
parallel.with(instances) { this.sync.apply(synchronizer) }
}
/**
* In parallel, work with built packages and services of instances matching default filtering.
*/
fun syncPackages(synchronizer: InstanceSync.(File) -> Unit) = syncFiles(instances, packages, synchronizer)
/**
* In parallel, work with built OSGi bundles and services of instances matching default filtering.
*/
fun syncBundles(synchronizer: InstanceSync.(File) -> Unit) = syncFiles(instances, bundles, synchronizer)
/**
* In parallel, work with built packages and services of specified instances.
*/
fun syncFiles(instances: Iterable<Instance>, packages: Iterable<File>, synchronizer: InstanceSync.(File) -> Unit) {
packages.forEach { pkg -> // single AEM instance dislikes parallel CRX package / OSGi bundle installation
parallel.with(instances) { // but same file could be in parallel deployed on different AEM instances
sync.apply { synchronizer(pkg) }
}
}
}
/**
* Build minimal CRX package in-place / only via code.
* All details like Vault properties, archive destination directory, file name are customizable.
*/
fun composePackage(definition: PackageDefinition.() -> Unit): File {
return PackageDefinition(this).compose(definition)
}
/**
* Validate any CRX packages.
*/
fun validatePackage(vararg packages: File, options: PackageValidator.() -> Unit) = validatePackage(packages.asIterable(), options)
/**
* Validate any CRX packages.
*/
fun validatePackage(packages: Iterable<File>, options: PackageValidator.() -> Unit) = PackageValidator(this).apply(options).perform(packages)
/**
* Show asynchronous progress indicator with percentage while performing some action.
*/
fun <T> progress(total: Int, action: ProgressIndicator.() -> T): T = progress(total.toLong(), action)
/**
* Show asynchronous progress indicator with percentage while performing some action.
*/
fun <T> progress(total: Long, action: ProgressIndicator.() -> T): T {
return ProgressIndicator(project).apply { this.total = total }.launch(action)
}
fun <T> progress(action: ProgressIndicator.() -> T) = progressIndicator(action)
/**
* Show asynchronous progress indicator while performing some action.
*/
fun <T> progressIndicator(action: ProgressIndicator.() -> T): T = ProgressIndicator(project).launch(action)
/**
* Show synchronous progress logger while performing some action.
*/
fun <T> progressLogger(action: ProgressLogger.() -> T): T = ProgressLogger.of(project).launch(action)
/**
* Wait some time after performing asynchronous operation.
*/
fun waitFor(time: Long) = progressCountdown(time)
/**
* Show synchronous progress countdown / time to wait after performing asynchronous operation.
*/
fun progressCountdown(time: Long) = progressCountdown { this.time = time }
/**
* Show synchronous progress countdown / time to wait after performing asynchronous operation.
*/
fun progressCountdown(options: ProgressCountdown.() -> Unit) = ProgressCountdown(project).apply(options).run()
@get:JsonIgnore
val filter: FilterFile
get() {
val cmdFilterRoots = props.list("filter.roots") ?: listOf()
if (cmdFilterRoots.isNotEmpty()) {
logger.debug("Using Vault filter roots specified as command line property: $cmdFilterRoots")
return FilterFile.temporary(project, cmdFilterRoots)
}
val cmdFilterPath = props.string("filter.path") ?: ""
if (cmdFilterPath.isNotEmpty()) {
val cmdFilter = FileOperations.find(project, packageOptions.vltDir.toString(), cmdFilterPath)
?: throw VltException("Vault check out filter file does not exist at path: $cmdFilterPath" +
" (or under directory: ${packageOptions.vltDir}).")
logger.debug("Using Vault filter file specified as command line property: $cmdFilterPath")
return FilterFile(cmdFilter)
}
val conventionFilterFiles = listOf(
"${packageOptions.vltDir}/${FilterFile.SYNC_NAME}",
"${packageOptions.vltDir}/${FilterFile.BUILD_NAME}"
)
val conventionFilterFile = FileOperations.find(project, packageOptions.vltDir.toString(), conventionFilterFiles)
if (conventionFilterFile != null) {
logger.debug("Using Vault filter file found by convention: $conventionFilterFile")
return FilterFile(conventionFilterFile)
}
logger.debug("None of Vault filter files found by CMD properties or convention.")
return FilterFile.temporary(project, listOf())
}
/**
* Get Vault filter object for specified file.
*/
fun filter(file: File) = FilterFile(file)
/**
* Get Vault filter object for specified path.
*/
fun filter(path: String) = filter(project.file(path))
/**
* Determine temporary directory for particular task.
*/
fun temporaryDir(task: Task) = temporaryDir(task.name)
/**
* Determine temporary directory for particular service (any name).
*/
fun temporaryDir(name: String) = AemTask.temporaryDir(project, name)
/**
* Determine temporary file for particular service (any name).
*/
fun temporaryFile(name: String) = AemTask.temporaryFile(project, TEMPORARY_DIR, name)
/**
* Predefined temporary directory.
*/
@get:JsonIgnore
val temporaryDir: File
get() = temporaryDir(TEMPORARY_DIR)
/**
* Factory method for configuration object determining how operation should be retried.
*/
fun retry(configurer: Retry.() -> Unit): Retry {
return retry().apply(configurer)
}
/**
* Factory method for configuration object determining that operation should not be retried.
*/
fun retry(): Retry = Retry.none(this)
/**
* React on file changes under configured directories.
*/
fun watchFiles(options: FileWatcher.() -> Unit) {
FileWatcher(this).apply(options).start()
}
/**
* Resolve single file from defined repositories or by using defined file transfers.
*/
fun resolveFile(value: Any) = resolveFile { get(value) }
/**
* Resolve single file from defined repositories or by using defined file transfers.
*/
fun resolveFile(options: FileResolver.() -> Unit) = resolveFiles(options).firstOrNull()
?: throw AemException("There is no files resolved!")
/**
* Resolve files from defined repositories or by using defined file transfers.
*/
fun resolveFiles(options: FileResolver.() -> Unit) = resolveFiles(temporaryDir, options)
/**
* Resolve files from defined repositories or by using defined file transfers.
*/
fun resolveFiles(downloadDir: File, options: FileResolver.() -> Unit): List<File> {
return FileResolver(this, downloadDir).apply(options).allFiles
}
/**
* Perform any HTTP requests to external endpoints.
*/
fun <T> http(consumer: HttpClient.() -> T) = HttpClient(this).run(consumer)
/**
* Download files using HTTP protocol using custom settings.
*/
fun <T> httpFile(consumer: HttpFileTransfer.() -> T) = fileTransfer.factory.http(consumer)
/**
* Transfer files using over SFTP protocol using custom settings.
*/
fun <T> sftpFile(consumer: SftpFileTransfer.() -> T) = fileTransfer.factory.sftp(consumer)
/**
* Transfer files using over SMB protocol using custom settings.
*/
fun <T> smbFile(consumer: SmbFileTransfer.() -> T) = fileTransfer.factory.smb(consumer)
/**
* Execute any Vault command.
*/
fun vlt(command: String): VltSummary = vlt { this.command = command; run() }
/**
* Execute any Vault command with customized options like content directory.
*/
fun <T> vlt(options: VltClient.() -> T) = VltClient(this).run(options)
/**
* Execute any Vault JCR content remote copying with customized options like content directory.
*/
fun <T> rcp(options: RcpClient.() -> T) = RcpClient(this).run(options)
/**
* Execute any Docker command using all available images with mounting volumes etc, exposing ports etc.
*/
fun runDocker(spec: RunSpec.() -> Unit) = environment.docker.run(spec)
// Utilities (to use without imports)
@JsonIgnore
val parallel = Parallel
@JsonIgnore
val formats = Formats
@JsonIgnore
val patterns = Patterns
@JsonIgnore
val buildScope = BuildScope.of(project)
companion object {
const val NAME = "aem"
const val TEMPORARY_DIR = "tmp"
private val PLUGIN_IDS = listOf(
PackagePlugin.ID,
BundlePlugin.ID,
InstancePlugin.ID,
EnvironmentPlugin.ID,
ToolingPlugin.ID,
CommonPlugin.ID
)
fun of(project: Project): AemExtension {
return project.extensions.findByType(AemExtension::class.java)
?: throw AemException("${project.displayName.capitalize()} must have at least one of following plugins applied: $PLUGIN_IDS")
}
}
}