Edit Java source code before compile

I am new to gradle. I am looking forward to migrating from maven to gradle.
I had few requirements:

  1. Existing project is maven based, and is generating a fat jar/uber jar. I am planning to split this into multiple projects, and creating smaller/thinner jars/libraries
  2. I have to also edit the Java source code, automatically, like making the java source modifications based on certain conditions

Would Gradle be a good, scalable solution for these two requirements which I am looking into currently?
Also please provide some pointers around these two topics.