The antlr4 task has to execute before compiling java because ANTLR4 generates a few java files.
The problem is that it executes every time any task executes (For example when running the clean task), I want it to execute only before compiling java files.
I’m a bit surprised that it’'s always executed. I can’t seen an misconfiguration. One note. to ensure that the task is executed before your compileJava task you should use
It seems that the logic of your antlr4 task is accidently executed during the configuration phase. But from the task snippet you posted I can think of why this is the case.
are you sure the task is really executed and not just configured. With the snippet above, you’ll always get the logging message “antlr args…” as this is done in the configuration of the task. But I guess “org.antlr.v4.Tool” is only executed when the task is really triggered.
Sorry for posting this as a reply but I was unable to comment. Thanks a lot, I just checked, It wasn’t really executing, It was just printing the line during the configuration phase.