Java和Maven构建器如何在eclipse中一起工作? [英] How do Java and Maven builders work together in eclipse?

查看:139
本文介绍了Java和Maven构建器如何在eclipse中一起工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我明白了解,Java构建器会重新编译输出路径的scr路径中的源,通常会在每个ctrl + s之后发生自动构建,或者通过ctrl + b或者从javac引发验证错误。



至于Maven2Bulder。我刚刚克隆了m2e-core git仓库,并且有相应的类org.eclipse.m2e.core.internal.builder.MavenBuilder,这是相当复杂的东西。

 < 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>

我以为它得到了pom.xml,m2eclipse变量关于repo位置和settings.xml或一些个人资料信息和目标运行配置的目标/目标,它只是运行mvn与这些信息,但它做得更多,它可以产生意想不到的行为。



Btw,是否只在开发者实际运行As>某些maven目标时使用?

解决方案

Maven构建器的主要用途是确保您的POM文件的正确性,并拉下所需的依赖项。如果您保存POM文件,它将出去检查新的依赖关系,并且在找不到依赖关系时会报告错误。



此外,maven构建器将运行一个maven构建,以达到您在首选项 - >中设置的目标。 Maven->在eclipse之后执行 Project-> Clean ... 项目后,更新项目配置后运行的目标更改POM文件并将其从eclipse中保存。



Java Builder仍然负责在问题视图中构建项目并报告编译器错误,以提供在eclipse等内置jUnit转换器的输入。


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 ... ?

解决方案

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.

这篇关于Java和Maven构建器如何在eclipse中一起工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆