Compile another Maven project using Maven Compiler API (CompilerMojo)

89 views Asked by At

I'm working on a Maven project that injects and runs some tests in another Maven projects. I already managed to inject them, however, I'm struggling to programmatically compile the other Maven project given its path. I tried Java Compiler API and Maven Compiler API but couldn't manage to do so.

Does any one know any way to programmatically compile a Maven project given its path from another Maven project?

1

There are 1 answers

0
queeg On

I am not aware of direct API calls. Yet I think your goal is achievable, and it would come with the advantage of separating JVMs...

Make 'another Maven project' excecute a command that essentially calls maven to compile 'a Maven project'. If need be, use the AntRun Plugin and Ant's exec task for this.