LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

mvn-generate-sources

runs source code generation plugins

TLDR

Generate sources
$ mvn generate-sources
copy
Generate with profile
$ mvn generate-sources -P [profile]
copy
Generate offline
$ mvn generate-sources -o
copy

SYNOPSIS

mvn generate-sources [options]

DESCRIPTION

mvn generate-sources invokes Maven's generate-sources lifecycle phase, which (along with all earlier phases — validate, initialize) runs any plugin executions bound to it. This is where code generators belong: JAXB / XJC, gRPC / Protocol Buffers, Avro, Antlr, OpenAPI, Modello, JOOQ, etc. Generated sources usually land under target/generated-sources/plugin/ and are added to the compile source roots automatically when the next phase, process-sourcescompile, runs.Because Maven runs every preceding phase as well, mvn generate-sources is rarely the most useful command on its own — most users invoke mvn compile or mvn package and let generation happen as a side effect. Use this phase explicitly when you want generated code available for IDE refresh without compiling the whole project.

PARAMETERS

-P profile[,profile...]

Activate one or more build profiles defined in pom.xml or settings.xml.
-o, --offline
Work offline (do not contact remote repositories).
-U, --update-snapshots
Force a check for updated SNAPSHOT dependencies and plugin releases.
-X, --debug
Enable debug-level Maven output.
-pl modules, --projects modules
Restrict the build to the listed reactor modules (comma-separated).
-am, --also-make
Build also the projects required by the ones selected with -pl.
-T N[C], --threads N[C]
Use N threads, optionally per CPU core (e.g. -T 1C).
-Dproperty=value
Pass a system property to the build.

CAVEATS

Generated sources are wiped by mvn clean. Plugins must be bound to generate-sources in pom.xml or activated by a profile; otherwise nothing happens. Multiple plugins generating into the same root can collide.

SEE ALSO

Copied to clipboard
Kai