If I run ./gradlew clean or ./gradlew tasks --all, it is always running my compile task(which I overwrote in the gradle build script like the below
Gradle does not know that your source was not changed. For any unknown status it marks the task as not up-to-date. Since your task is 100% replacement of compile, then it is your responsibility to provide the status of the task.
Writing Custom Task Classes chapter provides details on how to get started with incremental tasks.
Run your project with --info flag to see why Gradle is marking compile task as not up-to-date.
Hope it helps.