Create or parse java and kotlin clases into gradle task

I has some config class written on java. This config contains some colors field. And i want read this fields in compile time and generate style.xml based on these fields. This config file located on src/main/java. How i can create instance this class(config)or parse .java file during custom gradle task executed?