sbabti zied
sbabti zied

Reputation: 850

what is the meaning of generating-sources in java building process

I was reading the maven documentation, and i found that one of the build life cycle is the phase : generate-sources . So i am asking, what is the meaning of generatin-sources ? thnx

Upvotes: 1

Views: 5534

Answers (1)

paulsm4
paulsm4

Reputation: 121849

From the Maven documentation:

https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html

The Modello plugin binds by default its goal modello:java to the generate-sources phase (Note: The modello:java goal generates Java source codes)

So if you happened to use a "model generator" (like Modello)...

... and if you happened to use Maven (as opposed a different build tool, such as Ant or Gradle)...

... then you'd use the Maven "generate-sources" phase to generate Java source code from your "model" file.

In most projects, you'll probably write your own source code, so you wouldn't need a "generate-sources" phase.


As Andreas noted above, another common use case for "generate-sources" is if your project needed to generate Java beans from JAXB XML files: https://www.baeldung.com/jaxb.

I hope that answers your question :)

Upvotes: 0

Related Questions