I have a Dockerfile containing the following line:
ENTRYPOINT ["java", "-Dconversion.rules.folder=/var/rules", "-jar", "/var/gateway-service-${project.version}.jar"]
I am configuring the maven-resources-plugin
as following:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<id>copy-docker-artifacts</id>
<goals>
<goal>copy-resources</goal>
</goals>
<phase>package</phase>
<configuration>
<resources>
<resource>
<directory>${project.build.directory}</directory>
<includes>
<include>${project.artifactId}.tar</include>
</includes>
</resource>
<resource>
<directory>${project.basedir}/src/main/docker</directory>
<filtering>true</filtering>
</resource>
</resources>
<outputDirectory>${project.build.directory}/docker</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
As you can see I am expecting the project.version
to be replaced. For some reason this is not true. I have then ran the build using debug mode and it outputs the following:
[INFO] Copying 1 resource
[DEBUG] Copying file Dockerfile
[DEBUG] file Dockerfile has a filtered file extension
[DEBUG] filtering ...\src\main\docker\Dockerfile to ...\target\docker\Dockerfile
[DEBUG] no use filter components
It seems to me that the filtering should be working, however the file in target
still contains ${project.version}
. What am I missing here?
I have also tried putting other, non-Dockerfile files into the same folder the Dockerfile is in, however no filtering is applied there either...
Are you using Spring Boot as parent project ?
If that is the case, value in your Dockfile will be using @key@
ENTRYPOINT ["java",
"-Dconversion.rules.folder=/var/rules",
"-jar",
"/var/[email protected]@.jar"]
SpringBoot works that way