Implementation:Apache Spark Build Mvn
| Property | Value |
|---|---|
| source | Repo: Apache Spark |
| domain | Build_Systems |
| type | External Tool Doc |
Overview
Shell wrapper script that auto-downloads and configures Apache Maven for building Spark from source.
Description
The build/mvn script is a shell wrapper that ensures the correct version of Maven is available for building Spark. It automatically downloads Maven if the installed version doesn't match the version specified in the root pom.xml. It also configures critical JVM memory settings via MAVEN_OPTS.
Key responsibilities of the script:
- Version Detection -- Parses the required Maven version from the project's
pom.xmland compares it against any locally installed Maven. - Auto-Download -- If the correct version is not present, downloads and extracts Maven into the
build/directory. - Environment Configuration -- Sets default
MAVEN_OPTSfor JVM memory tuning unless overridden by the user. - Pass-Through Execution -- Delegates all command-line arguments directly to the underlying Maven binary.
Usage
Use this script instead of calling mvn directly when building Spark. It handles Maven version management automatically.
Code Reference
| Property | Value |
|---|---|
| Source | Repository apache/spark, File build/mvn, Lines 1-176
|
| Signature | build/mvn [maven-arguments...]
|
| Key Functions | install_app(), version(), install_mvn()
|
Key environment variables:
| Variable | Default Value | Description |
|---|---|---|
MAVEN_OPTS |
-Xss128m -Xmx4g -XX:ReservedCodeCacheSize=128m |
JVM options for Maven process |
JAVA_HOME |
(must be set) | Path to the Java Development Kit |
SPARK_LOCAL_HOSTNAME |
(optional) | Override for local hostname resolution |
I/O Contract
Inputs:
- CLI arguments (passed through to Maven) -- required
JAVA_HOMEenvironment variable -- requiredMAVEN_OPTSoverride -- optional
Outputs:
- Maven execution results (exit code)
- Downloaded Maven in
build/apache-maven-<version>/ - Exported
MAVEN_OPTSenvironment variable
Usage Examples
Basic build (skip tests):
./build/mvn clean package -DskipTests
Build with Kubernetes support:
./build/mvn clean package -DskipTests -Pkubernetes
Build with custom memory settings:
MAVEN_OPTS="-Xmx8g" ./build/mvn clean package