Skip to content

Commit 903418f

Browse files
Launcher scaffolding with config plugin
1 parent 129a67b commit 903418f

File tree

7 files changed

+166
-218
lines changed

7 files changed

+166
-218
lines changed

launcher/src/main/kotlin/com/cognifide/gradle/aem/launcher/BuildScaffolder.kt

Lines changed: 162 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ class BuildScaffolder(private val launcher: Launcher) {
99
saveProperties()
1010
saveSettings()
1111
saveRootBuildScript()
12+
savePropertiesTemplate()
1213
when (aemVersion) {
1314
"cloud" -> EnvCloudScaffolder(launcher).scaffold()
1415
null -> EnvScaffolder(launcher).scaffold()
@@ -28,11 +29,9 @@ class BuildScaffolder(private val launcher: Launcher) {
2829
println("Saving Gradle properties file '$this'")
2930
outputStream().use { output ->
3031
Properties().apply {
31-
putAll(defaultProps)
3232
if (savePropsFlag) {
3333
putAll(saveProps)
3434
}
35-
putAll(projectProps)
3635
store(output, null)
3736
}
3837
}
@@ -44,27 +43,123 @@ class BuildScaffolder(private val launcher: Launcher) {
4443
.map { it.removePrefix(Launcher.ARG_SAVE_PREFIX) }
4544
.associate { it.substringBefore("=") to it.substringAfter("=") }
4645

47-
private val defaultProps get() = mapOf(
48-
"org.gradle.logging.level" to "info",
49-
"org.gradle.daemon" to "true",
50-
"org.gradle.parallel" to "true",
51-
"org.gradle.caching" to "true",
52-
"org.gradle.jvmargs" to "-Xmx2048m -Dfile.encoding=UTF-8"
53-
)
54-
55-
private val projectProps get() = mapOf("javaSupport.version" to "11")
56-
5746
private fun saveRootBuildScript() = launcher.workFileOnce("build.gradle.kts") {
5847
println("Saving root Gradle build script file '$this'")
5948
writeText(
6049
"""
50+
import com.cognifide.gradle.aem.common.instance.local.OpenMode
51+
6152
plugins {
53+
id("io.wttech.config")
6254
id("com.cognifide.aem.common")
63-
id("com.neva.fork")
6455
}
6556
66-
apply(from = "gradle/fork/props.gradle.kts")
67-
if (file("gradle.user.properties").exists()) {
57+
config {
58+
define {
59+
labelAbbrs("aem")
60+
valueSaveGradleProperties()
61+
62+
group("instance") {
63+
prop("instanceType") {
64+
options("local", "remote")
65+
description("Local - instance will be created on local file system\nRemote - connecting to remote instance only")
66+
}
67+
prop("instanceAuthorHttpUrl") {
68+
default("http://localhost:4502")
69+
visible { boolValue("instanceAuthorEnabled") }
70+
optional()
71+
}
72+
prop("instanceAuthorEnabled") {
73+
checkbox(true)
74+
}
75+
prop("instancePublishHttpUrl") {
76+
default("http://localhost:4503")
77+
visible { boolValue("instancePublishEnabled") }
78+
optional()
79+
}
80+
prop("instancePublishEnabled") {
81+
checkbox(true)
82+
}
83+
prop("instancePassword") {
84+
default("admin")
85+
optional()
86+
}
87+
prop("instanceServiceCredentialsUri") {
88+
label("Service Credentials Uri")
89+
description("JSON file downloaded from AEMaaCS developer console")
90+
optional()
91+
}
92+
prop("localInstanceRunModes") {
93+
label("Run Modes")
94+
optional()
95+
}
96+
prop("localInstanceQuickstartDistUri") {
97+
label("AEM distribution URI")
98+
description("Typically AEM SDK zip file or AEM jar file")
99+
}
100+
prop("localInstanceQuickstartLicenseUri") {
101+
label("Quickstart License URI")
102+
description("Typically file named 'license.properties'")
103+
}
104+
prop("localInstanceSpUri") {
105+
description("Only for on-prem AEM instances. Typically file named 'aem-service-pkg-*.zip'")
106+
optional()
107+
}
108+
prop("localInstanceCoreComponentsUri") {
109+
description("Only for on-prem AEM instances. Typically file named 'core.wcm.components.all-*.zip'")
110+
optional()
111+
}
112+
prop("localInstanceOpenMode") {
113+
label("Open Automatically")
114+
description("Open web browser when instances are up.")
115+
options(OpenMode.values().map { it.name.toLowerCase() })
116+
default(OpenMode.ALWAYS.name.toLowerCase())
117+
}
118+
}
119+
group("build") {
120+
prop("mvnBuildProfiles") {
121+
default("fedDev")
122+
description("Comma delimited")
123+
optional()
124+
}
125+
prop("mvnBuildArgs") {
126+
description("Added extra")
127+
optional()
128+
}
129+
}
130+
group("deploy") {
131+
prop("packageDeployAvoidance") {
132+
label("Avoidance")
133+
description("Avoids uploading and installing package if identical is already deployed on instance.")
134+
checkbox(true)
135+
}
136+
prop("packageDamAssetToggle") {
137+
label("Toggle DAM Worklows")
138+
description("Turns on/off temporary disablement of assets processing for package deployment time.\n" +
139+
"Useful to avoid redundant rendition generation when package contains renditions synchronized earlier.")
140+
checkbox(true)
141+
}
142+
}
143+
group("authorization") {
144+
prop("companyUser") {
145+
default(System.getProperty("user.name").orEmpty())
146+
description("For resolving AEM files from authorized URL")
147+
optional()
148+
}
149+
prop("companyPassword") {
150+
optional()
151+
}
152+
prop("companyDomain") {
153+
default(System.getenv("USERDOMAIN").orEmpty())
154+
description("For files resolved using SMB")
155+
optional()
156+
}
157+
}
158+
159+
}
160+
}
161+
162+
if (config.captured) {
68163
if (aem.mvnBuild.available) defaultTasks(":env:setup")
69164
else defaultTasks(":env:instanceSetup")
70165
}
@@ -87,6 +182,58 @@ class BuildScaffolder(private val launcher: Launcher) {
87182
)
88183
}
89184

185+
private fun savePropertiesTemplate() = launcher.workFileOnce("gradle.properties.peb") {
186+
println("Saving user-specific properties template '$this'")
187+
writeText(
188+
"""
189+
# === Gradle
190+
191+
org.gradle.logging.level=info
192+
org.gradle.daemon=true
193+
org.gradle.parallel=true
194+
org.gradle.caching=true
195+
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
196+
197+
# === Gradle AEM Plugin ===
198+
199+
package.manager.deployAvoidance={{ config.packageDeployAvoidance }}
200+
{% if packageDamAssetToggle == 'true' %}
201+
package.manager.workflowToggle=[dam_asset=false]
202+
{% endif %}
203+
204+
localInstance.quickstart.distUrl={{ config.localInstanceQuickstartDistUri }}
205+
localInstance.quickstart.licenseUrl={{ config.localInstanceQuickstartLicenseUri }}
206+
localInstance.openMode={{ config.localInstanceOpenMode }}
207+
208+
localInstance.spUrl={{ config.localInstanceSpUri }}
209+
localInstance.coreComponentsUrl={{ config.localInstanceCoreComponentsUri }}
210+
211+
instance.default.runModes={{ config.localInstanceRunModes }}
212+
instance.default.password={{ config.instancePassword }}
213+
214+
instance.{{ config.instanceType }}-author.serviceCredentialsUrl={{ config.instanceServiceCredentialsUri }}
215+
instance.{{ config.instanceType }}-author.enabled={{ config.instanceAuthorEnabled }}
216+
instance.{{ config.instanceType }}-author.httpUrl={{ config.instanceAuthorHttpUrl }}
217+
instance.{{ config.instanceType }}-author.openPath=/aem/start.html
218+
instance.{{ config.instanceType }}-publish.enabled={{ config.instancePublishEnabled }}
219+
instance.{{ config.instanceType }}-publish.httpUrl={{ config.instancePublishHttpUrl }}
220+
instance.{{ config.instanceType }}-publish.openPath=/crx/packmgr
221+
222+
mvnBuild.args={{ config.mvnBuildArgs }}
223+
224+
# === Gradle Common Plugin ===
225+
226+
javaSupport.version=11
227+
228+
notifier.enabled=true
229+
230+
fileTransfer.user={{ config.companyUser }}
231+
fileTransfer.password={{ config.companyPassword }}
232+
fileTransfer.domain={{ config.companyDomain }}
233+
""".trimIndent()
234+
)
235+
}
236+
90237
private fun saveSettings() = launcher.workFileOnce("settings.gradle.kts") {
91238
println("Saving Gradle settings file '$this'")
92239
writeText(

launcher/src/main/kotlin/com/cognifide/gradle/aem/launcher/EnvCloudScaffolder.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ class EnvCloudScaffolder(private val launcher: Launcher) {
1717
}
1818
1919
dependencies {
20+
implementation("io.wttech.gradle.config:plugin:1.0.10")
2021
implementation("com.cognifide.gradle:aem-plugin:${launcher.pluginVersion}")
2122
implementation("com.cognifide.gradle:common-plugin:1.0.41")
22-
implementation("com.neva.gradle:fork-plugin:7.0.11")
2323
implementation("com.cognifide.gradle:environment-plugin:2.2.3")
2424
}
2525
""".trimIndent()

launcher/src/main/kotlin/com/cognifide/gradle/aem/launcher/EnvOnPremScaffolder.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ class EnvOnPremScaffolder(private val launcher: Launcher) {
1818
}
1919
2020
dependencies {
21+
implementation("io.wttech.gradle.config:plugin:1.0.10")
2122
implementation("com.cognifide.gradle:aem-plugin:${launcher.pluginVersion}")
2223
implementation("com.cognifide.gradle:common-plugin:1.0.41")
23-
implementation("com.neva.gradle:fork-plugin:7.0.11")
2424
implementation("com.cognifide.gradle:environment-plugin:2.2.0")
2525
}
2626
""".trimIndent()

launcher/src/main/kotlin/com/cognifide/gradle/aem/launcher/EnvScaffolder.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ class EnvScaffolder(private val launcher: Launcher) {
1616
}
1717
1818
dependencies {
19+
implementation("io.wttech.gradle.config:plugin:1.0.10")
1920
implementation("com.cognifide.gradle:aem-plugin:${launcher.pluginVersion}")
2021
implementation("com.cognifide.gradle:common-plugin:1.0.41")
21-
implementation("com.neva.gradle:fork-plugin:7.0.11")
2222
}
2323
""".trimIndent()
2424
)

0 commit comments

Comments
 (0)