Introduction to Apache-Maven

Apache-Maven is a tool that can be used for building and managing any Java-based project. Based on the concept of a project object model (POM), Apache-Maven can manage a project's build, reporting and documentation from a central piece of information.

This package is known to build and work properly using an LFS-8.3 platform.

Package Information

Additional Downloads

Apache-Maven Dependencies


A JDK (Java Binary or OpenJDK-10.0.2)

User Notes: http://wiki.linuxfromscratch.org/blfs/wiki/ApacheMaven

Installation of Apache-Maven

First fix two issues which prevent building with Java 10:

sed -e '/-surefire-/a<version>2.21.0</version>' \
    -e '/<commonsLang/s/3\.5/3.7/'              \
    -i pom.xml

Install Apache-Maven by running the following commands:

install -vdm 755 ../apache-maven-bin     &&
tar -xf ../apache-maven-3.5.4-bin.tar.gz \
    --strip-components=1                 \
    --directory ../apache-maven-bin      &&

PATH=../apache-maven-bin/bin:$PATH &&

mvn -DdistributionTargetDir=build \

The test are run as part of the compilation above.

Now, as the root user:

install -vdm 755            /opt/maven-3.5.4 &&
cp -Rv apache-maven/build/* /opt/maven-3.5.4 &&
ln -sfvn maven-3.5.4 /opt/maven

You can know reset the PATH variable and clean the source directory:

rm -rf ../apache-maven-bin

Command Explanations

tar ../apache-maven-3.5.4-bin.tar.gz ... PATH=.../bin:$PATH: Extracts the Apache-Maven binary and let the system know about the binary location.

mvn ... package: Compiles and tests the package, and packages it to its final format.

-DdistributionTargetDir=build: Specifies the location where the built binary should be packaged. The content of this directory is ready to be copied to its final location.

ln -sfvn maven-3.5.4 /opt/maven: Creates a convenience symlink.

-Dmaven.repo.local=...: Specifies a maven local repository for this build, instead of the default ~/.m2/repository. You may want to use this if several users are to use Apache-Maven.

Configuring Apache-Maven

Config Files

The user settings file ~/.m2/settings.xml and the global settings file /opt/maven/conf/settings.xml

Configuration Information

The default configuration file shipped with Apache-Maven should be sufficent for common tasks. You may want to copy the global settings file to your user one and modify it to suit your needs.

You should add the mvn command to PATH. For example:

cat > /etc/profile.d/maven.sh << "EOF"
# Begin /etc/profile.d/maven.sh

pathappend /opt/maven/bin

# End /etc/profile.d/maven.sh


Installed Programs: mvn, mvnDebug, and mvnyjp
Installed Library: libjansi.so in /opt/maven/lib/jansi-native
Installed Directory: /opt/maven-3.5.4

Short Descriptions


is the Apache-Maven Java-based project builder and manager


turns on mvn debug mode


runs mvnunder the supervision of the YourKit Java Profiler

Last updated on 2017-09-11 12:14:03 +0200