How to read maven pom.xml file configurations from Dockerfile

I’m migrating a java standalone maven project in docker. This maven project generates jar file with dynamic name.


Here version is dynamic.

Ex: app-1.1.jar, here app is project artifactId and 1.1 is version.

While creating docker image from dockerfile, I need to copy jar file into docker image.


FROM centos:7

RUN yum install -y 

ENV JAVA_HOME /usr/lib/jvm/java-1.8.0-openjdk/

ARG JAR_FILE=target/app-1.1.jar **//This jarfile name i need to read from pom.xml.**
ARG JAR_LIB_FILE=target/lib/

WORKDIR /opt/manager/app/

COPY ${JAR_FILE} app.jar

ENTRYPOINT ["java","-jar","app.jar"]

How to form fully qualified jarfile name by reading pom.xml file? app-1.1.jar

Source: Docker Questions