forked from wttech/gradle-aem-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PackageOptions.kt
98 lines (80 loc) · 3.22 KB
/
PackageOptions.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
package com.cognifide.gradle.aem.common.pkg
import com.cognifide.gradle.aem.AemExtension
import com.cognifide.gradle.aem.common.instance.service.pkg.Package
import com.cognifide.gradle.common.utils.using
import java.io.Serializable
class PackageOptions(private val aem: AemExtension) : Serializable {
/**
* Package specific configuration
*/
val commonDir = aem.obj.projectDir(aem.prop.string("package.commonPath") ?: "src/aem/package")
/**
* Package root directory containing 'jcr_root' and 'META-INF' directories.
*/
val contentDir = aem.obj.projectDir(aem.prop.string("package.contentPath") ?: "src/main/content")
/**
* JCR root directory.
*/
val jcrRootDir = aem.obj.relativeDir(contentDir, Package.JCR_ROOT)
/**
* Vault metadata files directory (package definition).
*/
val vltDir = aem.obj.relativeDir(contentDir, Package.VLT_PATH)
/**
* Custom path to Vault files that will be used to build CRX package.
* Useful to share same files for all packages, like package thumbnail.
*/
val metaCommonDir = aem.obj.relativeDir(commonDir, "defaults/${Package.META_PATH}")
/**
* Content path for AEM application placed in CRX package.
*/
val appPath = aem.obj.string {
convention(aem.obj.provider {
when (aem.project) {
aem.project.rootProject -> "/apps/${aem.project.rootProject.name}"
else -> "/apps/${aem.project.rootProject.name}/${aem.project.name}"
}
})
aem.prop.string("package.appPath")?.let { set(it) }
}
/**
* Repository path for OSGi bundles (JAR files) placed in CRX package.
*/
val installPath = aem.obj.string { convention(appPath.map { "$it/install" }) }
/**
* Source directory for OSGi bundles (JAR files) placed in CRX package.
*/
val installDir = aem.obj.dir { convention(jcrRootDir.dir(installPath.map { it.removePrefix("/") })) }
/**
* Repository path for OSGi configurations placed in CRX package.
*/
val configPath = aem.obj.string { convention(appPath.map { "$it/config" }) }
/**
* Source directory for XML files holding OSGi configurations placed in CRX package.
*/
val configDir = aem.obj.dir { convention(jcrRootDir.dir(configPath.map { it.removePrefix("/") })) }
/**
* Content path at which CRX Package Manager is storing uploaded packages.
*/
val storagePath = aem.obj.string {
convention("/etc/packages")
aem.prop.string("package.storagePath")?.let { set(it) }
}
/**
* Configures a local repository from which unreleased JARs could be added as 'compileOnly' dependency
* and be deployed within CRX package deployment.
*/
val installRepository = aem.obj.boolean {
convention(true)
aem.prop.boolean("package.installRepository")?.let { set(it) }
}
/**
* Customize default validation options.
*/
fun validator(options: PackageValidator.() -> Unit) {
this.validatorOptions = options
}
internal var validatorOptions: PackageValidator.() -> Unit = {}
val wrapper by lazy { PackageWrapper(aem) }
fun wrapper(options: PackageWrapper.() -> Unit) = wrapper.using(options)
}