Java 和 Maven 构建器如何在 Eclipse 中协同工作?

发布于 2024-11-26 03:24:22 字数 1217 浏览 2 评论 0原文

我理解正确吗,Java构建器将scr路径上的源代码重新编译到输出路径,如果激活自动构建或通过“ctrl + b”或从javac抛出验证错误,这通常在每个“ctrl + s”之后发生。

至于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、有关存储库位置和 settings.xml 的 m2eclipse 变量或当前运行配置的一些配置文件信息和目标/目标,并且它只是使用这些信息运行 mvn,但它可以做更多的事情,并且可以产生意想不到的行为。

顺便说一句,它仅在开发人员实际运行为 > 时使用吗?一些专家目标...?

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

|煩躁 2024-12-03 03:24:22

Maven 构建器的主要目的是确保 POM 文件的正确性并拉取所需的依赖项。如果你保存 POM 文件,它会出去检查新的依赖项,当找不到依赖项时它会报告错误。

此外,maven 构建器将运行 Maven 构建,以达到您在 Preferences -> 中设置的目标。 Maven->更新项目配置后运行的目标,在您从 Eclipse 中对项目执行 Project->Clean... 或对 POM 文件进行更改并保存后日食之内。

Java Builder 仍然负责构建项目并在 Problems 视图中报告编译器错误,为 eclipse 中内置的 jUnit 运行器提供输入等。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文