小编ano*_*ous的帖子

Maven:我的mojo如何访问自己的资源?

我有一个项目(这里称为my-artifact)需要从模型文件生成源.我已经创建了一个maven-plugin(my-code-generator),如下面的pom.xml摘录中所述.它从my-artifact的资源加载和处理model.xml,并使用插件中存储的一些预定义模板生成代码.问题是我的代码生成器如何访问这些模板,因为它们不在项目资源中,而是在自己的资源中.

提前致谢

<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>
        </ executions> …

maven-2 mojo maven-plugin

5
推荐指数
2
解决办法
2730
查看次数

标签 统计

maven-2 ×1

maven-plugin ×1

mojo ×1