Problem Statement
What is the default Maven build lifecycle phase that compiles and packages the application?
Explanation
Maven package phase executes the default lifecycle up to and including packaging. It compiles source code (compile phase), runs tests (test phase), and packages the compiled code into distributable format (JAR, WAR) defined in pom.xml. Package is commonly used in CI/CD pipelines for creating deployable artifacts.
Maven build lifecycle consists of phases executed sequentially: validate, compile, test, package, verify, install, deploy. Running mvn package automatically executes all previous phases. Compile phase only compiles code without packaging. Install copies package to local repository (~/.m2/repository), deploy uploads to remote repository.
Common Maven commands in CI/CD: mvn clean package (clean previous builds and package), mvn clean install (package and install to local repo), mvn clean deploy (package and deploy to remote repo), mvn verify (run integration tests). Understanding Maven lifecycle is essential for Java project automation.
