@@ -243,7 +243,8 @@ ext {
243243 if (matchingTask) {
244244 return [taskName : matchingTask. key, config : matchingTask. value]
245245 } else {
246- throw new GradleException (" No debug quickstart configuration found for profile: ${ profile} " )
246+ logger. debug(" No debug quickstart configuration found for profile: ${ profile} " )
247+ return null ;
247248 }
248249 }
249250
@@ -573,11 +574,17 @@ tasks.register("reload", Exec) {
573574 if (activeProfile) {
574575 // Find the task and config that matches this profile
575576 matchingTask = findTaskNameByProfile. call(activeProfile)
576- matchingTaskName = matchingTask. taskName
577- matchingConfig = matchingTask. config
578-
579- // Dynamically depend on the correct prepareAll task
580- dependsOn tasks. named(" prepareAll${ matchingTaskName} " )
577+ if (matchingTask == null ) {
578+ // This may be called even for non-debug profiles during config stage.
579+ // The execution stage needs these and handles if activeProfile is not available.
580+ activeProfile = null ;
581+ } else {
582+ matchingTaskName = matchingTask. taskName
583+ matchingConfig = matchingTask. config
584+
585+ // Dynamically depend on the correct prepareAll task
586+ dependsOn tasks. named(" prepareAll${ matchingTaskName} " )
587+ }
581588 }
582589
583590 doFirst {
@@ -625,10 +632,16 @@ tasks.register("reloadEnv", Exec) {
625632 if (activeProfile) {
626633 // Find the task and config that matches this profile
627634 matchingTask = findTaskNameByProfile. call(activeProfile)
628- matchingTaskName = matchingTask. taskName
629- matchingConfig = matchingTask. config
630- // Dynamically depend on the correct prepareAll task
631- dependsOn tasks. named(" prepareAll${ matchingTaskName} " )
635+ if (matchingTask == null ) {
636+ // This may be called even for non-debug profiles during config stage.
637+ // The execution stage needs these and handles if activeProfile is not available.
638+ activeProfile = null ;
639+ } else {
640+ matchingTaskName = matchingTask. taskName
641+ matchingConfig = matchingTask. config
642+ // Dynamically depend on the correct prepareAll task
643+ dependsOn tasks. named(" prepareAll${ matchingTaskName} " )
644+ }
632645 }
633646
634647 doFirst {
0 commit comments