Multiproject build - custom task - run as last in specific subproject

I have a multi project build as following

Root project - Main

Root project 'Main' - Root project
+--- Project ':A' - module /A
+--- Project ':B' - module /B
+--- Project ':C' - module /C
+--- Project ':D' - module /D

in build.gradle of main i have

subprojects {
	task doit() {
		group = 'My tasks'
		description = 'Deploy project'

I need to ensure that if and only if task doIt() runs on all projects (activated with gradle doit), it will run on project B as last.
If task doit is run on project A (gradle A:doit) , it should not run automatically on project B

I have looke at mustRunAfter and finalizedBy but cannot see how to make it fit