Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/306.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 无法为集合和复杂对象指定maven plugin.xml参数元数据_Java_Maven - Fatal编程技术网

Java 无法为集合和复杂对象指定maven plugin.xml参数元数据

Java 无法为集合和复杂对象指定maven plugin.xml参数元数据,java,maven,Java,Maven,我正在尝试为内部maven 3插件生成plugin.xml元数据文件。maven插件在为顶级参数生成元数据方面做得非常出色,但似乎无法检测和表达用作参数(如所需属性)的复杂对象的配置要求 @Mojo(name = "feature") public class FeatureMojo extends AbstractMojo { @Parameter(required = true) private List<Feature> features; @Par

我正在尝试为内部maven 3插件生成plugin.xml元数据文件。maven插件在为顶级参数生成元数据方面做得非常出色,但似乎无法检测和表达用作参数(如所需属性)的复杂对象的配置要求

@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;
}
@Mojo(name=“feature”)
公共类特性Mojo扩展了AbstractMojo{
@参数(必需=真)
私有列表功能;
@参数(必需=真)
隐私特征;
}
公共类功能{
@参数(必需=真)
私有字符串名称;
}
当前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>

特征
local.example.mojo.Feature
真的
真的
特征
java.util.List
真的
真的
有办法绕过这个限制吗


我不反对手工生成plugin.xml,如果这可以在插件描述符中表示,并且只是生成器中的一个限制。

您只能指定顶级对象。接下来,为您的特性提供一个名为的getter和setter。所有这些都是让它像这样工作所必需的:

<configuration>
  <features>
    <feature>
      <name>NAME</name>
    </feature>
  </features>
</configuration>

名称
不可能像这样在实例中检查对name的要求,最好是在Mojo中添加一个validate方法,在这里检查这些额外的要求


另外,我会删除
私有功能。一般来说,选择单个或多个,决不能同时选择两者。

公平地说,这是一个不幸的限制。也许我会调查一下。nake Feature参考只是为了证明两种方法都没有产生期望的结果。通常还有改进的余地,但我不希望通过参数注释来解决这个问题,因为Feature是参数,name只是这个实例的一个字段,而不是一个参数。