For a java project, create two seperate task : one for to complie src dir and another to complie test dir

Hello,
I am having a legacy project which follows directory structure like:
ROOT
|
|
|------src
|
|------test

Hence I using sourceSets to identify the srouce codes for both src and test.
But I want to write two seperate task: one to complie src directory and another to complie test directory

How can I achive so?

When using the java plugin, it already creates source sets for the application and the tests. You can reconfigure those default source sets and all the default compile/build tasks will continue to function.

https://docs.gradle.org/current/userguide/java_plugin.html#sec:changing_java_project_layout