在Intellij“根据原型创建项目”向导中显示自定义原型属性

时间:2018-11-20 13:29:30

标签: java maven intellij-idea intellij-plugin maven-archetype

我有一个自定义的Maven原型来定义公司内部的项目结构。 此原型具有一些必需的其他属性。例如,系统代码

<archetype-descriptor>
    <requiredProperties>        
        <requiredProperty key="system-code"/>
        ...
    </requiredProperties>
    ...
</archetype-descriptor>

如果我通过命令行运行工件:

$ mvn archetype:generate -DarchetypeGroupId=... -DarchetypeArtifactId=... -DarchetypeVersion=...

请求了custom属性,因此用户在运行mvn archetype:generate插件之前不需要知道该属性是否存在。

$ Define value for property 'system-code':

当我从Intellij-idea中的原型创建新项目时,我想做的事情类似。遵循其他SO问题的建议,我创建了artifact-catalog并将插件maven artifacts catalog添加到Idea。到目前为止,一切工作正常,我可以根据原型创建一个新项目。

enter image description here

但是,在原型属性对话框中,没有自定义属性系统代码的痕迹,在某些情况下,用户不必知道此属性是必需的。

enter image description here

如果我继续创建项目,我希望也许会在命令行中请求system-code属性,但事实并非如此,并且由于缺少system-code属性,所以属性创建失败了。

[ERROR] Property system-code is missing.

如果我在属性对话框中手动添加了 system-code 属性,则所有功能均按预期方式运行,但是正如我所说,我认为对于用户而言,这并不容易理解。

所以,问题是,是否有人知道在Intellij-idea新项目创建向导中以某种方式显示原型自定义属性是否可行?

预先感谢

2 个答案:

答案 0 :(得分:1)

很遗憾,目前IntelliJ IDEA doesn't support,您可以在YouTrack中watch/vote发布该问题。

答案 1 :(得分:0)

您可以在创建期间使用向导手动添加属性。

我正在使用IntelliJ IDEA 2019.1.3

Make sure the required property is indicated in the archetype-metadata.xml file

在列出属性的屏幕中,您可以单击加号以添加Maven属性,匹配archetype-metadata.xml文件中列出的名称并添加此属性的值

Properties screen and add maven proerty popup

单击“确定”会将此属性添加到列表中,并且将使用设计的自定义属性来构建项目。

我希望这会有所帮助

相关问题