Skip to content

Commit ee175bb

Browse files
authored
Merge pull request #144 from Cognifide/satisfy-minor-impr
Minor satisfy improvements (better logging)
2 parents 784c4ab + 466f1b3 commit ee175bb

3 files changed

Lines changed: 22 additions & 16 deletions

File tree

src/main/kotlin/com/cognifide/gradle/aem/api/AemConfig.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,10 @@ class AemConfig(
452452
instance(RemoteInstance.create(httpUrl, environment))
453453
}
454454

455+
fun remoteInstance(httpUrl: String, user: String, password: String) {
456+
instance(RemoteInstance.create(httpUrl, user, password, deployEnvironment))
457+
}
458+
455459
fun remoteInstance(httpUrl: String, user: String, password: String, environment: String) {
456460
instance(RemoteInstance.create(httpUrl, user, password, environment))
457461
}

src/main/kotlin/com/cognifide/gradle/aem/pkg/deploy/DeployTask.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.cognifide.gradle.aem.pkg.deploy
22

33
import com.cognifide.gradle.aem.api.AemTask
4+
import com.cognifide.gradle.aem.instance.Instance
45
import org.gradle.api.tasks.TaskAction
56

67
open class DeployTask : SyncTask() {
@@ -17,7 +18,7 @@ open class DeployTask : SyncTask() {
1718
@TaskAction
1819
fun deploy() {
1920
if (config.deployDistributed) {
20-
synchronizeInstances({ it.distributePackage() }, filterInstances(config.deployInstanceAuthorName))
21+
synchronizeInstances({ it.distributePackage() }, Instance.filter(project, config.deployInstanceAuthorName))
2122
} else {
2223
synchronizeInstances({ it.deployPackage() })
2324
}

src/main/kotlin/com/cognifide/gradle/aem/pkg/deploy/SyncTask.kt

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,24 @@ abstract class SyncTask : AemDefaultTask() {
1111
protected val propertyParser = PropertyParser(project)
1212

1313
protected fun synchronizeInstances(synchronizer: (InstanceSync) -> Unit) {
14-
synchronizeInstances(synchronizer, filterInstances())
14+
synchronizeInstances(synchronizer, Instance.filter(project))
1515
}
1616

1717
protected fun <T : Instance> synchronizeInstances(synchronizer: (InstanceSync) -> Unit, instances: List<T>) {
18-
val callback = { instance: T -> synchronizeInstance(synchronizer, instance) }
19-
if (config.deployParallel) {
20-
instances.parallelStream().forEach(callback)
18+
synchronizeInstances(instances, { instance: T -> synchronizeInstance(synchronizer, instance) })
19+
}
20+
21+
protected fun <T : Instance> synchronizeInstances(instances: List<T>, callback: (T) -> Unit) {
22+
if (instances.isEmpty()) {
23+
logger.warn("No instances to synchronize. Verify deploy instance name filter '${config.deployInstanceName}' and defined instances name (environment-type).")
2124
} else {
22-
instances.onEach(callback)
25+
if (config.deployParallel) {
26+
logger.info("Synchronizing ${instances.size} instance(s) in parallel mode")
27+
instances.parallelStream().forEach(callback)
28+
} else {
29+
logger.info("Synchronizing ${instances.size} instance(s) in sequential mode")
30+
instances.onEach(callback)
31+
}
2332
}
2433
}
2534

@@ -30,7 +39,7 @@ abstract class SyncTask : AemDefaultTask() {
3039
}
3140

3241
protected fun synchronizeLocalInstances(handler: (LocalHandle) -> Unit) {
33-
Instance.locals(project).forEach { instance -> synchronizeLocalInstance(handler, instance) }
42+
synchronizeInstances(Instance.locals(project), { instance -> synchronizeLocalInstance(handler, instance) })
3443
}
3544

3645
protected fun synchronizeLocalInstance(handler: (LocalHandle) -> Unit, instance: LocalInstance) {
@@ -39,16 +48,8 @@ abstract class SyncTask : AemDefaultTask() {
3948
handler(LocalHandle(project, InstanceSync(project, instance)))
4049
}
4150

42-
protected fun filterInstances(): List<Instance> {
43-
return Instance.filter(project)
44-
}
45-
46-
protected fun filterInstances(instanceGroup: String): List<Instance> {
47-
return Instance.filter(project, instanceGroup)
48-
}
49-
5051
protected fun awaitStableInstances() {
51-
InstanceActions(project).awaitStable(filterInstances())
52+
InstanceActions(project).awaitStable(Instance.filter(project))
5253
}
5354

5455
protected fun awaitStableLocalInstances() {

0 commit comments

Comments
 (0)