我有一个需要从模型文件生成源的项目(这里称为 my-artifact)。我已经创建了一个 maven-plugin (my-code-generator),它的使用方法如下面的 pom.xml 摘录中所述。它从 my-artifact 的资源加载和处理 model.xml,并使用插件中存储的一些预定义模板生成代码。问题是 my-code-generator 如何访问这些模板,因为它们不在项目资源中,而是在其自己的资源中。
提前致谢
<plugin>
<groupId>my-group</groupId>
<artifactId>my-code-generator</artifactId>
<version>0.0.1-SNAPSHOT</version>
<configuration>
<modelfile>
src/main/resources/model .xml
</modelDir>
</configuration>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>generate-model</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</ phase>
<goals>
<goal>add-source</goal>
<sources>
<source>target/generated-sources</source>
</sources>
</configuration>
</execution>
</执行>
</插件>