【发布时间】:2010-05-10 12:41:09
【问题描述】:
我正在尝试构建一个这样的原型结构,一个带有一些自定义文件夹的 web 应用程序,用于我们的 web 框架。特别是一些动态文件夹,其中也会包含一些原型带来的文件。
└───src
└───main
└───webapp
└───WEB-INF
├───cfg
│ ├───log4j
│ └───resources
│ └───extensions
│ ├───${shortName}-business
│ └───${shortName}-layout
└───lib
我向我的archetype-metadata.xml 添加了一个必需的属性,以便为项目提供一个短名称,该名称用于生成唯一文件夹等。
<requiredProperties>
<requiredProperty key="shortName" />
</requiredProperties>
我在fileSet中使用的属性shortName:
<fileSet>
<directory>[..]/resources/extensions/${shortName}-business</directory>
</fileSet>
<fileSet>
<directory>[..]/resources/extensions/${shortName}-layout</directory>
</fileSet>
生成原型的命令:
mvn archetype:generate -B \
-DgroupId=com.stackoverflow \
-DartifactId=stackoverflow-question -DarchetypeGroupId=com.stackoverflow \
-DarchetypeArtifactId=stackoverflow-archetype -DarchetypeVersion=1.0 \
-DshortName=soq
我假设得到以下文件夹结构:
..\
├───soq-business
└───soq-layout
但我将这个名称 ${shortName}-business 作为文件夹,而不是用属性替换它。
..\
├───${shortName}-business
└───${shortName}-layout
我怎样才能做到这一点?此时如何在不知道文件夹名称的情况下将文件放在soq-business下面?
【问题讨论】: