I have a multi-module Maven project where some modules have to be built as a Docker image. I tried to put all of the configuration in the parent POM like so:
Parent POM:
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>0.3.5</version>
<configuration>
<baseImage>java</baseImage>
<imageName>${project.artifactId}</imageName>
<entryPoint>["java", "-jar", "/${project.build.finalName}.jar"]</entryPoint>
<resources>
<resource>
<targetPath>/</targetPath>
<directory>${project.build.directory}/${project.build.finalName}-executable</directory>
<include>${project.build.finalName}.jar</include>
<include>lib/*.jar</include>
</resource>
</resources>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
Child POM:
<build>
<plugins>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
But when I run mvn docker:build
on the child project I get an error because the project.build.directory
property was resolved to the target directory of the parent POM, instead of the child's target directory.
Is it possible to delay the expansion of the properties in the parent POM? Or to reference the project.*
properties of the child from the parent POM?
答案 0 :(得分:0)
问题是我还使用了版本的属性(如:Maven version with a property)。只有从聚合器POM运行Maven时才有效(种类)。 切换到显式版本(并使用maven-release-plugin更新它们)解决了这个问题。