我创建了一个新的 Maven 原型(prototype),以便它生成我的自定义项目结构。为此,我创建了一个项目,其中包含要生成的 archetype-metadata.xml 和 pom.xml。
在 META-INF/maven 下我有 archetype-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>
这按预期工作,我能够使用此原型(prototype)创建一个新的 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并就解决方法进行了一些讨论。
关于java - 是否可以在自定义的 Maven 原型(prototype)中提供动态目录结构,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42062039/