java是否可以在定制的maven原型中提供动态目录结构
我创建了一个新的maven原型,以便生成我定制的项目结构。为此,我创建了一个带有原型元数据的项目。xml和pom。要生成的xml
在META-INF/maven下,我有原型元数据。xml文件-
<?xml version="1.0" encoding="UTF-8"?>
<archetype-descriptor xsi:schemaLocation="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0 http://maven.apache.org/xsd/archetype-descriptor-1.0.0.xsd" name="test"
xmlns="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<fileSets>
<fileSet filtered="true" encoding="UTF-8">
<directory>com/test/MyProject</directory>
<includes>
<include>.classpath</include>
<include>.project</include>
</includes>
</fileSet>
</fileSets>
</archetype-descriptor>
以及原型资源/pom。xml-
<?xml version="1.0" encoding="UTF-8"?>
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>${groupId}</groupId>
<artifactId>${artifactId}</artifactId>
<version>${version}</version>
<packaging>jar</packaging>
</project>
这是预期的工作,我能够创建一个新的maven项目使用这个原型。 现在我想创建一个动态目录结构。和中一样,我想在文件集中创建一个名为${artifactId}的目录。i、 e.有点像-
<fileSet filtered="true" encoding="UTF-8">
<directory>com/test/${artifactId}</directory>
<includes>
<include>.classpath</include>
<include>.project</include>
</includes>
</fileSet>
我试过这个,但没能实现
有可能给出这样的动态目录结构吗
# 1 楼答案
这似乎是一个多年前就应该修复的错误。也许现在这个错误又出现了
https://issues.apache.org/jira/browse/ARCHETYPE-191
另见Maven archetype not using properties to create module names,其中有一些关于变通办法的讨论