Maven原型:修改artifactId
在处理项目时,我的要求是创建一个模块 该命令类似于:Maven原型:修改artifactId,maven,maven-archetype,Maven,Maven Archetype,在处理项目时,我的要求是创建一个模块 该命令类似于: mvn archetype:generate \ -DarchetypeCatalog=local \ -DartifactId=test-module 并且目标应该具有以下文件结构 test-module |--pom.xml `--src `--main |--install | `--install.sh `--scripts `--test_module.sh
mvn archetype:generate \
-DarchetypeCatalog=local \
-DartifactId=test-module
并且目标应该具有以下文件结构
test-module
|--pom.xml
`--src
`--main
|--install
| `--install.sh
`--scripts
`--test_module.sh
我的全部目标是创建另一个派生自artifactId的变量(比如artifactidWithUnderline),将所有连字符-
替换为underscope\uuu
。以便我可以使用更新的变量创建文件
例如:
+------------------+---------------------------------+
|INPUT - artifactId|OUTPUT - artifactIdWithUnderscore|
+------------------+---------------------------------+
| test-module | test_module |
| temp | temp |
| test-temp-module | test_temp_module |
+------------------+---------------------------------+
我试图通过在archetype metadata.xml中添加以下条目来创建一个新变量artifactidWithUnderline
选项1:
<requiredProperty key="artifactIdWithUnderscore" >
<defaultValue>${StringUtils.replace(${artifactId}, "-", "_")}</defaultValue>
</requiredProperty>
<requiredProperty key="artifactIdWithUnderscore" >
<defaultValue>${artifactId.replaceAll("-", "_")}</defaultValue>
</requiredProperty>
<requiredProperty key="artifactIdWithUnderscore" >
<defaultValue>${artifactId}.replaceAll("-", "_")</defaultValue>
</requiredProperty>
选项2:
<requiredProperty key="artifactIdWithUnderscore" >
<defaultValue>${StringUtils.replace(${artifactId}, "-", "_")}</defaultValue>
</requiredProperty>
<requiredProperty key="artifactIdWithUnderscore" >
<defaultValue>${artifactId.replaceAll("-", "_")}</defaultValue>
</requiredProperty>
<requiredProperty key="artifactIdWithUnderscore" >
<defaultValue>${artifactId}.replaceAll("-", "_")</defaultValue>
</requiredProperty>
artifactId的上述值来自原型项目本身的POM
选项3:
<requiredProperty key="artifactIdWithUnderscore" >
<defaultValue>${StringUtils.replace(${artifactId}, "-", "_")}</defaultValue>
</requiredProperty>
<requiredProperty key="artifactIdWithUnderscore" >
<defaultValue>${artifactId.replaceAll("-", "_")}</defaultValue>
</requiredProperty>
<requiredProperty key="artifactIdWithUnderscore" >
<defaultValue>${artifactId}.replaceAll("-", "_")</defaultValue>
</requiredProperty>
请让我知道我如何才能做到这一点
编辑:
选项4:
<requiredProperty key="artifactIdWithUnderscore" >
<defaultValue>${__artifactId__.replaceAll("-", "_")}</defaultValue>
</requiredProperty>
选项2适合我:
<requiredProperty key="artifactIdWithoutDash">
<defaultValue>${artifactId.replaceAll("-", ".")}</defaultValue>
</requiredProperty>
${artifactId.replaceAll(“-”,“)}
我可以使用uuu artifactedwhithoutdash uuuush.sh有一个文件名来创建文件(在我的例子中是:一些.letters.uuuu artifactedwhithoutdash uuuuuu.cfg)你能给我们看看你的
原型.properties
文件吗?@MattEckert,我没有原型.properties
文件。使用archetype metadata.xml
。