Reputation: 13061
I would like to understand better how Maven deals with resources and in particular how plugins can reuse the Resources
infrastructure that Maven provides:
I have already read the resources section of Maven and looked at the Maven Resources Plugin.
Now I came across the Docker Maven Plugin from Spotify. Which contains the following configuration section:
<configuration>
<imageName>${docker.image.prefix}/${project.artifactId}</imageName>
<dockerDirectory>src/main/docker</dockerDirectory>
<resources>
<resource>
<targetPath>/</targetPath>
<directory>${project.build.directory}</directory>
<include>${project.build.finalName}.jar</include>
</resource>
</resources>
</configuration>
Looking at the Readme of the plugin I could not find any explanation which child elements are allowed for a <resource>
element. I am assuming that the <resource>
element is in fact related to Maven's org.apache.maven.model.Resource
class and that I can just reuse the documentation of Maven to understand who it works. But according to the Maven documentation I linked above, it seems that <include>
elements must be nested inside an <includes>
element which the above code listing does not do. Now I am confused.
To summarize: Where can I look to get a definitive answer if a plugin does not exactly document how its configuration works. Does there exist some kind of XML schema reference for plugins where I can lookup how particular elements work?
Upvotes: 1
Views: 3043
Reputation: 291
I think you want to set configs like:
<dockerDirectory>src/main/docker</dockerDirectory>
<dockerHost>https://192.168.99.100:2376</dockerHost>
<dockerCertPath>/Users/your_user/.docker/machine/machines/default</dockerCertPath>
these one you can use for example by following:
fixes this by:
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>0.4.13</version>
<configuration>
<imageName>yourImageName</imageName>
<dockerDirectory>src/main/docker</dockerDirectory>
<dockerHost>https://192.168.99.100:2376</dockerHost>
<dockerCertPath>/Users/your_user/.docker/machine/machines/default</dockerCertPath>
<resources>
<resource>
<targetPath>/</targetPath>
<directory>${project.build.directory}</directory>
<include>${project.build.finalName}.jar</include>
</resource>
</resources>
</configuration>
</plugin>
Important are these two tags:
<dockerHost>https://192.168.99.100:2376</dockerHost>
<dockerCertPath>/Users/your_user/.docker/machine/machines/default</dockerCertPath>
I am using a dockerfile, which path you have to define with this tag:
<dockerDirectory>src/main/docker</dockerDirectory>
Now you can build your jar and generate docker image via:
mvn package docker:build
Upvotes: 2