How do Java and Maven builders work together in eclipse?

*爱你&永不变心* 提交于 2019-12-17 23:18:31

问题


do I understand correctly, that Java builder recompiles sources on scr path to the output path, which usually happens after each "ctrl + s" if automatic building is activated or via "ctrl + b" or throws validation errors from javac.

As to Maven2Bulder. I just cloned m2e-core git repository and there is the corresponding class org.eclipse.m2e.core.internal.builder.MavenBuilder, which is quite complicated stuff.

<projectDescription>
    <name>modeshape-example-repositories</name>
    <comment></comment>
    <projects>
    </projects>
    <buildSpec>
        <buildCommand>
            <name>org.eclipse.jdt.core.javabuilder</name>
            <arguments>
            </arguments>
        </buildCommand>
        <buildCommand>
            <name>org.eclipse.m2e.core.maven2Builder</name>
            <arguments>
            </arguments>
        </buildCommand>
    </buildSpec>
    <natures>
        <nature>org.eclipse.m2e.core.maven2Nature</nature>
        <nature>org.eclipse.jdt.core.javanature</nature>
    </natures>
</projectDescription>

I thought it gets pom.xml, m2eclipse variables about repo location and settings.xml or some profile information and goal/target of the current Run configuration and it just runs mvn with this pieces of information, but it does much much more and it can produce unexpected behavior.

Btw, is it only used when a developer actually Run As > some maven goal ... ?


回答1:


The main purpose of the Maven builder is to ensure the correctness of your POM file and pull down the dependencies that you need. It will go out and check for new dependencies if you save your POM file, and it will report errors when it cannot find dependencies.

Additionally, the maven builder will run a maven build up to the goal that you have set in Preferences -> Maven->Goal to run after updating project configuration after you do a Project->Clean... on your project from eclipse or make changes to the POM file and save it from within eclipse.

The Java Builder is still in charge of building the project and reporting compiler errors in the Problems view, for providing the input for the built in jUnit runner in eclipse, etc.



来源:https://stackoverflow.com/questions/6832789/how-do-java-and-maven-builders-work-together-in-eclipse

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!