Marc-Christian Schulze
Marc-Christian Schulze

Reputation: 3264

Dynamically add projects to maven build reactor?

I wrote a maven plugin that generates Java source code based on some definition language.
The generated source code should be split up into several jar files (interfaces, implementation, etc.).
I would like to build my project containing the definition language together with the generated sources but I'm not sure what the best way is.
I thought of extending my maven plugin to generate for each jar a new maven project and add them dynamically to the current running maven build reactor.

Is it possible to add new maven projects to the build reactor while the build is running? or Could I generate new maven projects while maven is parsing the directory structure for building the reactor? (Maybe in the validate phase?)

Does anyone have a better idea how to compile the generated maven projects in the same reactor?

Many thanks in advance

Upvotes: 1

Views: 331

Answers (1)

jtahlborn
jtahlborn

Reputation: 53694

personally, i would recommend just using one project with multiple artifacts

  • generate the sources
  • compile all the sources
  • use multiple assembly plugin configs to split the resulting class files into multiple jars

i believe you could generate these various jars with different classifiers and then depend on them as independent resources in other maven modules/projects.

Upvotes: 1

Related Questions