Code -- How to rewrite command-line?

How to rewrite multiple lines of the command line?
Seeing multiple lines rewritten in the console when executing tasks.

It’s a little unclear what you’re asking but you can do

task multipleExecs {
   doLast {
      exec {
         commandLine 'echo foo'.split(' ')
      }
      exec {
         commandLine 'echo bar'.split(' ')
      } 
   }
} 

Or perhaps

task multipleExecs {
   doLast {
      ['echo foo', 'echo bar'].each {
         exec {
            commandLine it.split(' ')
         } 
      }
   }
} 

4 progress bars(dynamic) in the terminal when the project is built. i don’t know how to refresh
some lines(>1) on the terminal via Java or Kotlin

I’m guessing that you realise each line is a separate task running in parallel. To update a single line you can call methods on the Logger obtained via Task.getLogger() (eg Logger.info(…) or Logger.lifecycle(…))