【发布时间】:2018-12-13 06:56:03
【问题描述】:
这是我的场景
我有一个 POM 文件,它使用我们开发的自定义插件让我们说 mycutom-plugin 并且该插件使用另一个名为 asciidoctor-maven-plugin 的插件
所以我会在这里记下我的担忧
1. 我在 asciidoctor-maven-plugin 中有一个参数(asciidoctor.sectnumlevels)作为配置属性,请参阅下面的 xml,此参数值由正在使用此插件的父 POM 传递。
现在,当我没有从正在使用的插件的父 POM 传递值时,我想要从 mycutom-plugin 的 POM 为 ${asciidoctor.sectnumlevels} 设置一个默认值
<plugin>
<groupId>org.asciidoctor</groupId>
<artifactId>asciidoctor-maven-plugin</artifactId>
<version>${asciidoctor-maven-plugin.version} </version>
.......
<attributes>
<toc2>left</toc2>
......
<sectnumlevels>${asciidoctor.sectnumlevels}</sectnumlevels>
</attributes>
</configuration>
<executions>
<execution>
<phase>none</phase>
<goals>
<goal>process-asciidoc</goal>
</goals>
</execution>
</executions>
</plugin>
请看我如何在父 POM 中定义属性
<properties>
<asciidoctor.sectnumlevels>4</asciidoctor.sectnumlevels>
</properties>
此外,我还测试了下面的解决方案,但是这种方式采用默认值,但是当我将 POM 中的值作为属性插件端传递时,它不会覆盖
<profiles>
<profile>
<id>asciidoctor.param.default</id>
<activation>
<activeByDefault>true</activeByDefault>
<property>
<name>!asciidoctor.sectnumlevels</name> <!--if not defined from parent POM-->
</property>
</activation>
<properties>
<asciidoctor.sectnumlevels>3</asciidoctor.sectnumlevels> <!--set default value-->
</properties>
</profile>
</profiles>
【问题讨论】:
标签: maven maven-plugin