【问题标题】:Usage of maven Build Helper Maven Pluginmaven Build Helper Maven Plugin的使用
【发布时间】:2012-05-30 21:13:08
【问题描述】:

我正在尝试使用 maven 插件将 maven java 项目的源文件夹添加到 Eclipse。

当尝试使用 org.codehaus.mojo 插件时,我收到以下错误

未能在项目应用程序框架上执行目标 org.codehaus.mojo:build-helper-maven-plugin:1.7:add-source (default-cli):目标 org.codehaus.mojo 的参数“源”: build-helper-maven-plugin:1.7:add-source 丢失或无效 -> [帮助 1]

通过阅读http://mojo.codehaus.org/build-helper-maven-plugin/usage.html 上的文档,这应该是正确的吗? 文件夹 target/sources/mygeneratedfiles 存在。

<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>
            </goals>
            <configuration>
                <sources>
                    <source>target/sources/mygeneratedfiles</source>
                </sources>
            </configuration>
        </execution>
    </executions>
</plugin>

【问题讨论】:

  • 要添加源文件夹,您应该在目标文件夹之外添加一个源文件夹。也许您可以提供更多您想要实现的细节。
  • @khmarbaise 我需要添加一个生成的文件夹。请查看修改
  • 问题是从什么样的工具生成什么样的文件夹?你在使用某种生成插件吗?
  • @khmarbaise 是一个maven生成的文件夹——它的路径是target/sources/mygeneratedfiles 文件夹是Maven生成的
  • 您没有回答问题,但无论如何问题似乎是 build-helper 插件在错误的阶段执行。

标签: maven m2e


【解决方案1】:

问题在于,由于“相对较新”的生命周期映射规则,构建助手插件通常太旧而无法与最新的 maven 版本(与 m2e eclipse 插件结合使用)一起使用。

我通过为 orgeclipse.m2e 插件的 build-helper-maven-plugin 添加生命周期映射配置解决了这个问题。见下文:

        <plugin>
            <groupId>org.eclipse.m2e</groupId>
            <artifactId>lifecycle-mapping</artifactId>
            <version>1.0.0</version>
            <configuration>
                <lifecycleMappingMetadata>
                    <pluginExecutions>
                        <pluginExecution>
                            <pluginExecutionFilter>
                                <groupId>org.codehaus.mojo</groupId>
                                <artifactId>build-helper-maven-plugin</artifactId>
                                <versionRange>[1.0,)</versionRange>
                                <goals>
                                    <goal>add-source</goal>
                                    <goal>add-test-source</goal>
                                    <goal>add-resource</goal>
                                    <goal>add-test-resource</goal>
                                    <goal>maven-version</goal>
                                    <goal>parse-version</goal>
                                </goals>
                            </pluginExecutionFilter>
                            <action>
                                <execute>
                                    <runOnConfiguration>true</runOnConfiguration>
                                    <runOnIncremental>true</runOnIncremental>
                                </execute>
                            </action>
                        </pluginExecution>
                    </pluginExecutions>
                </lifecycleMappingMetadata>
            </configuration>
        </plugin>

【讨论】:

    猜你喜欢
    • 2014-12-07
    • 1970-01-01
    • 1970-01-01
    • 2017-11-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多