Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Implementation:Apache Spark Build Mvn

From Leeroopedia


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.xml and 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_OPTS for 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_HOME environment variable -- required
  • MAVEN_OPTS override -- optional

Outputs:

  • Maven execution results (exit code)
  • Downloaded Maven in build/apache-maven-<version>/
  • Exported MAVEN_OPTS environment 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

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment