创建Maven ArcheType。设置文件名 [英] Creating Maven ArcheType . Setting file name

查看:467
本文介绍了创建Maven ArcheType。设置文件名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个Archetype,用户可以在其中提供artifactId。然后我想拿这个artifactId并创建两个文件。这是一个例子。

I want to create an Archetype in which user can provide artifactId. Then I want to take this artifactId and create two files. Here is an example.

artifactId= box

FILE 1: copy-box.txt
FILE 2 : Box.java

创建copy-box.txt非常简单。但是如何使用B资本创建Box.java。

Creating copy-box.txt is quite easy. But how to create Box.java with B capital.

推荐答案

我查看了在原型资源的文件名中创建替换的代码。 (可以找到这里)。在我看来,参数的值取自上下文,这意味着它们不被评估。在我看来,目前在文件名中直接使用评估机制是不可能的(可悲的,但却是真的)。​​

I looked through the code that creates the replacement in the filenames of the archetype resources. (can be found here). It appears to me that the values of the arguments are taken from the context, which means that they are not evaluated. In my opinion, for the moment it is not possible (sad, but true) to use the evaluation mechanism directly in the file names.

但是,只需实现FilesetArchetypeGenerator界面,可以对原型生成做出很好的贡献。

However, by simply implementing the FilesetArchetypeGenerator interface, a good contribution can be made to the archetypes generation.

这篇关于创建Maven ArcheType。设置文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆