mvn-compile
compile the main source code of a Maven project
TLDR
SYNOPSIS
mvn compile [options]
DESCRIPTION
mvn compile runs the compile phase of the Maven default lifecycle, executing all phases that come before it (validate, initialize, generate-sources, process-resources, ...) and finally invoking maven-compiler-plugin to compile src/main/java into target/classes. Resources from src/main/resources are copied during the process-resources phase, so they are available on the classpath after compile completes.The compiler version and target language level are governed by the maven-compiler-plugin configuration in pom.xml or by the maven.compiler.source, maven.compiler.target, and maven.compiler.release properties. Use -T for parallel multi-module builds, and -pl/-am to compile only the relevant module of a large reactor.
PARAMETERS
-P profile
Activate one or more comma-separated Maven profiles.-DskipTests
Skip test compilation in subsequent phases. Tests are still compiled if mvn test runs without this flag.-Dmaven.compiler.release N
Set the --release flag passed to javac, controlling the target JDK API level.-o, --offline
Run in offline mode; never reach out to remote repositories.-U, --update-snapshots
Force updates of snapshot dependencies and plugins.-pl MODULES
Restrict the reactor build to a comma-separated list of modules.-am, --also-make
Together with -pl, also build dependencies of the selected modules.-q, --quiet
Print only errors and the final result.-X, --debug
Enable verbose debug output (full stack traces, effective POM).-T N
Build in parallel using N threads (or 1C for one per core).
CAVEATS
Test sources in src/test/java are compiled in a separate phase (test-compile) and are not produced by mvn compile alone. Generated sources from annotation processors are written to target/generated-sources/annotations and must be on the source path for IDE awareness.
SEE ALSO
mvn(1), mvn-package(1), mvn-install(1), javac(1)
