开发者

How to use custom lifecycle for m2eclipse-type project?

When using m2eclipse ... if you right-click on a maven project and select Properties from the popup menu, you enter the project preferences dialog, which has a Maven->Lifecycle section allowing 开发者_如何学运维to customize which build phases should be bound to the build lifecycle, whenever the project is refreshed or clean-built. However, these customizations are coarse-grained and get lost upon "project-configuration-update" (same, if you put file "org.maven.ide.eclipse.prefs", where these settings are saved under version control ... upon project import, the file will be overwritten).

Searching for a solution, I found this answer from pascal-thivent where he describes "how to create a new Maven builder in project preferences..." which didn't quite help in my case, because the "Create-New-Builder-Dialog" in my Eclipse setup unfortunately cannot find such a Maven Builder. And the existing builder has the "Edit-Builder" button disabled.


With Maven all build information is stored inside pom.xml and most detailed configuration is maven plugin configuration.

All configuration inside Eclipse IDE should be done using m2e Eclipse plugin. Well, I don't know where to find all possible configuration. But sometime some option are available as Eclipse warning while editing pom.xml

Here is example of my current settings. It generated by m2e.

    <pluginManagement>
        <plugins>
            <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself. -->
            <plugin>
                <groupId>org.eclipse.m2e</groupId>
                <artifactId>lifecycle-mapping</artifactId>
                <version>1.0.0</version>
                <configuration>
                    <lifecycleMappingMetadata>
                        <pluginExecutions>
                            <pluginExecution>
                                <pluginExecutionFilter>
                                    <groupId>ro.isdc.wro4j</groupId>
                                    <artifactId>
                                        wro4j-maven-plugin
                                    </artifactId>
                                    <versionRange>
                                        [1.4.0,)
                                    </versionRange>
                                    <goals>
                                        <goal>jshint</goal>
                                    </goals>
                                </pluginExecutionFilter>
                                <action>
                                    <ignore></ignore>
                                </action>
                            </pluginExecution>
                            <pluginExecution>
                                <pluginExecutionFilter>
                                    <groupId>
                                        com.github.searls
                                    </groupId>
                                    <artifactId>
                                        jasmine-maven-plugin
                                    </artifactId>
                                    <versionRange>
                                        [1.2.0.0,)
                                    </versionRange>
                                    <goals>
                                        <goal>
                                            generateManualRunner
                                        </goal>
                                    </goals>
                                </pluginExecutionFilter>
                                <action>
                                    <ignore></ignore>
                                </action>
                            </pluginExecution>
                        </pluginExecutions>
                    </lifecycleMappingMetadata>
                </configuration>
            </plugin>

        </plugins>
    </pluginManagement>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜