我如何使用 io.fabric8 docker-maven-plugin 提供的属性?
How can I use properties exactly as they are provided by the io.fabric8 docker-maven-plugin?
由 io.fabric8 填充的 Maven 属性 docker-maven-plugin 按原样使用时似乎没有被插入。
The docker-maven-plugin fills in some maven properties(some.host
和 some.port
)我尝试解决。
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>0.15.5</version>
<configuration>
<images>
<image>
<alias>...</alias>
<name>...</name>
<run>
<ports>
<port>+some.host:some.port:5432</port>
</ports>
<namingStrategy>alias</namingStrategy>
</run>
</image>
</images>
</configuration>
</plugin>
它们是这样使用的:
<properties>
<docker.host>${some.host}</docker.host>
<docker.port>${some.port}</docker.port>
</properties>
这导致两个空值。它们什么都不包含,而它们应该包含例如127.0.0.1
和 5555
.
如果我添加一些字符,值突然被正确插入(但当然这些值就没用了)
<properties>
<docker.host>${some.host}+abc</docker.host>
<docker.port>${some.port}+123</docker.port>
</properties>
导致 127.0.0.1+abc
和 5555+123
我试过的一些东西也不起作用:
<properties>
<dollar>$</dollar>
<docker.host>${dollar}{some.host}</docker.host>
<docker.port>${some.port}${}</docker.port>
</properties>
导致空值和 5555null
Roland Huß 指出使用 docker 的固定端口可以避免该问题。那应该是首选。
但为了完成,我将添加一个同样有效的解决方案:
欺骗 maven 创建一个空的 属性(例如,使用 groovy-maven-plugin)
<plugin>
<groupId>org.codehaus.gmaven</groupId>
<artifactId>groovy-maven-plugin</artifactId>
<version>2.0</version>
<executions>
<execution>
<id>set empty property</id>
<phase>initialize</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<source>
<![CDATA[
project.properties.setProperty('empty', '');
]]>
</source>
</configuration>
</execution>
</executions>
</plugin>
使用空 属性 让 maven 插入由 docker-maven-plugin
公开的属性
<docker.host>${some.host}${empty}</docker.host>
<docker.port>${some.port}${empty}</docker.port>
由 io.fabric8 填充的 Maven 属性 docker-maven-plugin 按原样使用时似乎没有被插入。
The docker-maven-plugin fills in some maven properties(some.host
和 some.port
)我尝试解决。
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>0.15.5</version>
<configuration>
<images>
<image>
<alias>...</alias>
<name>...</name>
<run>
<ports>
<port>+some.host:some.port:5432</port>
</ports>
<namingStrategy>alias</namingStrategy>
</run>
</image>
</images>
</configuration>
</plugin>
它们是这样使用的:
<properties>
<docker.host>${some.host}</docker.host>
<docker.port>${some.port}</docker.port>
</properties>
这导致两个空值。它们什么都不包含,而它们应该包含例如127.0.0.1
和 5555
.
如果我添加一些字符,值突然被正确插入(但当然这些值就没用了)
<properties>
<docker.host>${some.host}+abc</docker.host>
<docker.port>${some.port}+123</docker.port>
</properties>
导致 127.0.0.1+abc
和 5555+123
我试过的一些东西也不起作用:
<properties>
<dollar>$</dollar>
<docker.host>${dollar}{some.host}</docker.host>
<docker.port>${some.port}${}</docker.port>
</properties>
导致空值和 5555null
Roland Huß 指出使用 docker 的固定端口可以避免该问题。那应该是首选。
但为了完成,我将添加一个同样有效的解决方案:
欺骗 maven 创建一个空的 属性(例如,使用 groovy-maven-plugin)
<plugin> <groupId>org.codehaus.gmaven</groupId> <artifactId>groovy-maven-plugin</artifactId> <version>2.0</version> <executions> <execution> <id>set empty property</id> <phase>initialize</phase> <goals> <goal>execute</goal> </goals> <configuration> <source> <![CDATA[ project.properties.setProperty('empty', ''); ]]> </source> </configuration> </execution> </executions> </plugin>
使用空 属性 让 maven 插入由 docker-maven-plugin
公开的属性<docker.host>${some.host}${empty}</docker.host> <docker.port>${some.port}${empty}</docker.port>