@@ -7,11 +7,13 @@ import com.cognifide.gradle.aem.internal.PropertyParser
77import com.cognifide.gradle.aem.pkg.ComposeTask
88import com.cognifide.gradle.aem.pkg.PackagePlugin
99import com.fasterxml.jackson.annotation.JsonIgnore
10+ import groovy.lang.Closure
1011import org.gradle.api.DefaultTask
1112import org.gradle.api.Project
1213import org.gradle.api.tasks.Input
1314import org.gradle.api.tasks.Internal
1415import org.gradle.language.base.plugins.LifecycleBasePlugin
16+ import org.gradle.util.ConfigureUtil
1517import java.io.File
1618import java.io.Serializable
1719import java.util.*
@@ -421,63 +423,82 @@ class AemConfig(
421423 instance(LocalInstance .create(httpUrl))
422424 }
423425
424- fun localInstance (httpUrl : String , type : String ) {
425- instance(LocalInstance .create(httpUrl, type ))
426+ fun localInstance (httpUrl : String , configurer : LocalInstance .() -> Unit ) {
427+ instance(LocalInstance .create(httpUrl, configurer ))
426428 }
427429
428- fun localInstance (httpUrl : String , user : String , password : String ) {
429- instance( LocalInstance .create( httpUrl, user, password) )
430+ fun localInstance (httpUrl : String , configurer : Closure < * > ) {
431+ localInstance( httpUrl, { ConfigureUtil .configure(configurer, this ) } )
430432 }
431433
432- fun localInstance ( httpUrl : String , user : String , password : String , type : String ) {
433- instance( LocalInstance .create(httpUrl, user, password, type) )
434+ fun localAuthorInstance ( ) {
435+ localAuthorInstance({} )
434436 }
435437
436- fun localInstance ( httpUrl : String , user : String , password : String , type : String , debugPort : Int ) {
437- instance( LocalInstance (httpUrl, user, password, type, debugPort) )
438+ fun localAuthorInstance ( configurer : LocalInstance .() -> Unit ) {
439+ localInstance(propParser.string( Instance . AUTHOR_URL_PROP , Instance . URL_AUTHOR_DEFAULT ), configurer )
438440 }
439441
440- fun localAuthorInstance () {
441- val httpUrl = propParser.string(Instance .AUTHOR_URL_PROP , Instance .URL_AUTHOR_DEFAULT )
442- instance(LocalInstance .create(httpUrl))
442+ fun localAuthorInstance (configurer : Closure <* >) {
443+ localAuthorInstance({ ConfigureUtil .configure(configurer, this ) })
443444 }
444445
445446 fun localPublishInstance () {
446- val httpUrl = propParser.string(Instance .PUBLISH_URL_PROP , Instance .URL_PUBLISH_DEFAULT )
447- instance(LocalInstance .create(httpUrl))
447+ localPublishInstance({})
448448 }
449449
450- fun remoteInstance ( httpUrl : String ) {
451- instance( RemoteInstance .create(httpUrl, deployEnvironment) )
450+ fun localPublishInstance ( configurer : LocalInstance .() -> Unit ) {
451+ localInstance(propParser.string( Instance . PUBLISH_URL_PROP , Instance . URL_PUBLISH_DEFAULT ), configurer )
452452 }
453453
454- fun remoteInstance ( httpUrl : String , environment : String ) {
455- instance( RemoteInstance .create(httpUrl, environment) )
454+ fun localPublishInstance ( configurer : Closure < * > ) {
455+ localPublishInstance({ ConfigureUtil .configure(configurer, this ) } )
456456 }
457457
458- fun remoteInstance (httpUrl : String , user : String , password : String ) {
459- instance(RemoteInstance .create(httpUrl, user, password, deployEnvironment ))
458+ fun remoteInstance (httpUrl : String ) {
459+ instance(RemoteInstance .create(httpUrl))
460460 }
461461
462- fun remoteInstance (httpUrl : String , user : String , password : String , environment : String ) {
463- instance(RemoteInstance .create(httpUrl, user, password, environment))
462+ fun remoteInstance (httpUrl : String , configurer : RemoteInstance .() -> Unit ) {
463+ instance(RemoteInstance .create(httpUrl, {
464+ this .environment = deployEnvironment
465+ this .apply (configurer)
466+ }))
464467 }
465468
466- fun remoteInstance (httpUrl : String , user : String , password : String , type : String , environment : String ) {
467- instance( RemoteInstance ( httpUrl, user, password, type, environment) )
469+ fun remoteInstance (httpUrl : String , configurer : Closure < * > ) {
470+ remoteInstance( httpUrl, { ConfigureUtil .configure(configurer, this ) } )
468471 }
469472
470473 fun remoteAuthorInstance () {
471- val httpUrl = propParser.string(Instance .AUTHOR_URL_PROP , Instance .URL_AUTHOR_DEFAULT )
472- instance(RemoteInstance .create(httpUrl, deployEnvironment))
474+ remoteAuthorInstance({})
475+ }
476+
477+ fun remoteAuthorInstance (configurer : RemoteInstance .() -> Unit ) {
478+ remoteInstance(propParser.string(Instance .AUTHOR_URL_PROP , Instance .URL_AUTHOR_DEFAULT ), configurer)
479+ }
480+
481+ fun remoteAuthorInstance (configurer : Closure <* >) {
482+ remoteAuthorInstance({ ConfigureUtil .configure(configurer, this ) })
473483 }
474484
475485 fun remotePublishInstance () {
476- val httpUrl = propParser.string(Instance .PUBLISH_URL_PROP , Instance .URL_PUBLISH_DEFAULT )
477- instance(RemoteInstance .create(httpUrl, deployEnvironment))
486+ remotePublishInstance({})
487+ }
488+
489+ fun remotePublishInstance (configurer : RemoteInstance .() -> Unit ) {
490+ remoteInstance(propParser.string(Instance .PUBLISH_URL_PROP , Instance .URL_PUBLISH_DEFAULT ), configurer)
491+ }
492+
493+ fun remotePublishInstance (configurer : Closure <* >) {
494+ remotePublishInstance({ ConfigureUtil .configure(configurer, this ) })
478495 }
479496
480497 private fun instance (instance : Instance ) {
498+ if (instances.containsKey(instance.name)) {
499+ throw AemException (" Instance named '${instance.name} ' is already defined. Enumerate instance types (for instance 'author1', 'author2') or distinguish environments." )
500+ }
501+
481502 instances[instance.name] = instance
482503 }
483504
@@ -552,6 +573,90 @@ class AemConfig(
552573 @Internal
553574 fun isUniqueProjectName () = project == project.rootProject || project.name == project.rootProject.name
554575
576+ /* *
577+ * @Deprecated Will be removed in 4.0.0
578+ */
579+ fun localInstance (httpUrl : String , typeName : String ) {
580+ localInstance(httpUrl, {
581+ this .typeName = typeName
582+ })
583+ }
584+
585+ /* *
586+ * @Deprecated Will be removed in 4.0.0
587+ */
588+ fun localInstance (httpUrl : String , user : String , password : String ) {
589+ localInstance(httpUrl, {
590+ this .user = user
591+ this .password = password
592+ })
593+ }
594+
595+ /* *
596+ * @Deprecated Will be removed in 4.0.0
597+ */
598+ fun localInstance (httpUrl : String , user : String , password : String , typeName : String ) {
599+ localInstance(httpUrl, {
600+ this .user = user
601+ this .password = password
602+ this .typeName = typeName
603+ })
604+ }
605+
606+ /* *
607+ * @Deprecated Will be removed in 4.0.0
608+ */
609+ fun localInstance (httpUrl : String , user : String , password : String , type : String , debugPort : Int ) {
610+ localInstance(httpUrl, {
611+ this .user = user
612+ this .password = password
613+ this .typeName = type
614+ this .debugPort = debugPort
615+ })
616+ }
617+
618+ /* *
619+ * @Deprecated Will be removed in 4.0.0
620+ */
621+ fun remoteInstance (httpUrl : String , environment : String ) {
622+ remoteInstance(httpUrl, {
623+ this .environment = environment
624+ })
625+ }
626+
627+ /* *
628+ * @Deprecated Will be removed in 4.0.0
629+ */
630+ fun remoteInstance (httpUrl : String , user : String , password : String ) {
631+ remoteInstance(httpUrl, {
632+ this .user = user
633+ this .password = password
634+ })
635+ }
636+
637+ /* *
638+ * @Deprecated Will be removed in 4.0.0
639+ */
640+ fun remoteInstance (httpUrl : String , user : String , password : String , environment : String ) {
641+ remoteInstance(httpUrl, {
642+ this .user = user
643+ this .password = password
644+ this .environment = environment
645+ })
646+ }
647+
648+ /* *
649+ * @Deprecated Will be removed in 4.0.0
650+ */
651+ fun remoteInstance (httpUrl : String , user : String , password : String , typeName : String , environment : String ) {
652+ remoteInstance(httpUrl, {
653+ this .user = user
654+ this .password = password
655+ this .typeName = typeName
656+ this .environment = environment
657+ })
658+ }
659+
555660 companion object {
556661
557662 /* *
0 commit comments