使用默认值询问maven原型属性

sga*_*gan 15 maven-2 maven-archetype

我正在整理一个maven原型,它有一堆自定义属性,用于过滤各种原型资源.我在archetype-metadata.xml中指定了默认值,例如

<requiredProperties>
  <requiredProperty key="application-name">
    <defaultValue>Some Application</defaultValue>
  </requiredProperty>>  
</requiredProperties>
Run Code Online (Sandbox Code Playgroud)

但是,当我尝试使用原型创建项目时,它不允许我以交互方式更改这些项目.例如,它要求默认版本如下

Define value for property 'version': 1.0-SNAPSHOT: 
Run Code Online (Sandbox Code Playgroud)

允许输入版本,但如果没有输入则默认为1.0-SNAPSHOT.对于我的自定义属性,它仅在创建新项目之前显示它们

[INFO] Using property: application-name = Some Application
Run Code Online (Sandbox Code Playgroud)

如果我省略了archetype-metadata.xml中的默认值,那么它会提示我输入一个值,但是没有默认值.

是否可以提供默认值并仍然提示?

Fun*_*242 8

请查找提交设置的最终问题.在我的情况下,有一个最后的问题:

:
Confirm properties configuration:
groupId: ....
 Y: :
Run Code Online (Sandbox Code Playgroud)

如果我输入n,那么将使用archetype-metadata.xml中的默认值重新询问所有属性.

这是我的控制台部分:

Choose archetype:
1: file:///C:\Aktentasche\_daten\m3 -> maven-dsl-project-archet...
Choose a number: : 1
Downloading: file:///C:\Aktentasche\_daten\m3/net/sf/maven/plug...
data.xml
[INFO] Using property: groupId = net.sf.maven.plugins
[INFO] Using property: artifactId = dslexample
[INFO] Using property: version = 1.0.0-SNAPSHOT
[INFO] Using property: package = net.sf.maven.plugins
[INFO] Using property: eclipse_platform = helios
[INFO] Using property: tycho_version = 0.8.0
Confirm properties configuration:
groupId: net.sf.maven.plugins
artifactId: dslexample
version: 1.0.0-SNAPSHOT
package: net.sf.maven.plugins
eclipse_platform: helios
tycho_version: 0.8.0
 Y: :
Run Code Online (Sandbox Code Playgroud)

在这里,我必须为默认的交互式对话框输入n.


Ed *_*aub 8

简而言之,不,这是不可能的.这有一个JIRA问题.如果这对您来说是个问题,您可能需要投票支持.


sga*_*gan 0

我在 Maven 邮件列表上提出了这个问题,但没有得到回复。同时作为一种解决方法,当原型运行时,可以使用系统属性在命令行中覆盖它们

e.g. -Dapplication-name="Some Application"
Run Code Online (Sandbox Code Playgroud)