是否可以在自定义的 Maven 原型中提供动态目录结构

Is it possible to give dynamic directory structure in customized maven archetype

我创建了一个新的 Maven 原型,以便它生成我的自定义项目结构。为此,我创建了一个项目,其中要生成 archetype-metadata.xml 和 pom.xml。

在META-INF/maven下我有原型-metadata.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>

和archetype-resources/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} 的目录。即有点像 -

 <fileSet filtered="true" encoding="UTF-8">
     <directory>com/test/${artifactId}</directory>
      <includes>
         <include>.classpath</include>
          <include>.project</include>
      </includes>
  </fileSet>

我已经试过了answer,但是我做不到。

是否可以给出这样的动态目录结构?

似乎这是一个错误,几年前就应该修复了。可能现在又出现了错误?

https://issues.apache.org/jira/browse/ARCHETYPE-191

另请参阅 Maven archetype not using properties to create module names,其中包含一些关于解决方法的讨论。