Build your customized maven in Arm architecture


A new project is launched and this project will deploy on the arm64 architecture server, which is not the same as the x86 platform. luckily, our product is written by java, which is a cross-platform language. what we need to do is build java in the ARM environment. 

To do this, we need Maven with a specific version of java and set up Maven source from closely location instead of Apache’s official source. 

CI/CD pipeline has already implemented, all of the codes have complied, built, and pushed to the Docker registry automatically. therefore, we need a docker version of Maven.

This is what you will learn from the article. 



FROM arm64v8/alpine:3.9
RUN mkdir /usr/local/jdk
COPY ./jdk-8u271-linux-aarch64.tar.gz /usr/local/jdk

RUN tar -zxvf /usr/local/jdk/jdk-8u271-linux-aarch64.tar.gz -C /usr/local/jdk
RUN rm -rf /usr/local/jdk/jdk-8u271-linux-aarch64.tar.gz

RUN mkdir /usr/local/maven
COPY ./apache-maven-3.6.3-bin.tar.gz /usr/
RUN tar -zxvf /usr/apache-maven-3.6.3-bin.tar.gz -C /usr/local/maven
RUN rm -rf /usr/apache-maven-3.6.3-bin.tar.gz

ENV JAVA_HOME /usr/local/jdk/jdk1.8.0_271

ENV M2_HOME /usr/local/maven/apache-maven-3.6.3
ADD settings.xml /usr/local/maven/apache-maven-3.6.3/conf

Maven Settings:

  1. specify local repository location
<settings xmlns=""
  <!-- localRepository
   | The path to the local repository maven will use to store artifacts.
   | Default: ${user.home}/.m2/repository

  <localRepository>/data/maven-cache/repository</localRepository>#this is local Repository
  1. Local source
      <name>Human Readable Name for this Mirror.</name>
 # Local source
       <name>voiceai maven</name>