![](/img/trans.png)
[英]Can i generate a maven plugin descriptor (plugin.xml) with gradle?
[英]Unable to specify maven plugin.xml parameter metadata for collections and complex objects
我正在嘗試為內部Maven 3插件生成一個plugin.xml元數據文件。 maven-plugin-plugin在為頂級參數生成元數據方面做得很好,但是似乎無法檢測和表達用作參數(例如所需屬性)的復雜對象的配置要求。
@Mojo(name = "feature")
public class FeatureMojo extends AbstractMojo {
@Parameter(required = true)
private List<Feature> features;
@Parameter(required = true)
private Feature feature;
}
public class Feature {
@Parameter(required = true)
private String name;
}
當前的plugin.xml輸出為:
<parameter>
<name>feature</name>
<type>local.example.mojo.Feature</type>
<required>true</required>
<editable>true</editable>
<description></description>
</parameter>
<parameter>
<name>features</name>
<type>java.util.List</type>
<required>true</required>
<editable>true</editable>
<description></description>
</parameter>
有沒有辦法解決這個限制?
如果這可以在插件描述符中表示,並且對生成器來說是一個限制,那么我不反對手工生成plugin.xml。
您只能指定頂級對象。 接下來,為您的功能指定name
器和設置器。 這是使它像這樣工作所必需的:
<configuration>
<features>
<feature>
<name>NAME</name>
</feature>
</features>
</configuration>
這樣就不可能檢查實例中名稱的要求,最好是在您檢查這些額外要求的Mojo中添加一個validate-method。
PS。 我將刪除private Feature feature;
。 通常,選擇單項或多項,不要兩者都選。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.