redhat-developer / redhat-developer/vscode-java

[Question] What does actually happen when a project (with a pom.xml) is built?

未关闭
#1,354 1 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

Maven question
主要语言
TypeScript
星标
2.3k
派生
547
平均合并
20 小时 1 分钟
30 天内合并 PR
11

描述

I have some difficulties understanding what really happens when the Java Language Server starts upon opening my project on VS Code and when I save a modified .java file afterward.

My question concerns specifically the building of the project, and I'm asking it because I've witnessed behavior that I couldn't quite explain.

My project is a Maven project and thus, has a pom.xml file. In this file, I use some plugins in the <build> node that do some heavy work (in my case, installing npm dependencies for my frontend and building it).

<!-- An excerpt of my pom.xml file -->
<?xml version="1.0" encoding="UTF-8" ?>
<project /* ... */>
  <build>
    /* ... */
    <plugins>
      <plugin>
        <groupId>com.github.eirslett</groupId>
        <artifactId>frontend-maven-plugin</artifactId>
        <version>1.9.1</version>
        <executions>
          <execution>
            /* install nodejs and npm */
          </execution>
          <execution>
            /* npm ci */
          </execution>
          <execution>
            /* npm run build */
          </execution>
        </executions>
      </plugin>
      /* other plugins */
    </plugins>
  /* ... */
  </build>
</project>

When I open the project with VS Code, the Java Language Server starts and eventually builds the project. This build phase takes a hefty amount of time to complete but envetually does so. After that, each time I save a .java file, the Java Language Server hops in and starts building the project again (as it is somewhat expected). This build also takes a huge amount of time before completing.

When commenting the <plugin> node in my `pom.xml that do the heavy work, the building of the project runs incredibly faster.

Of this, I've come to the conclusion that the Java Language Server detects that I'm using a Maven project thanks to the presence of the pom.xml file and delegates the building of the project to M2Eclipse which, in turn, does something like mvn compile, meaning that each build will execute all the goals registered on the <build> node.

Am I right in this assertion? And if so, would there be any way to compile the project as a "simple" Java Application (something like IntelliJ's Application configuration)?

I know that I could use Maven profiles to scope the execution of those plugins' goals, and prevent their execution when developping but I'd like to be sure to understand what is happening under the hood.

Environment
  • Operating System: WSL
  • JDK version: 11
  • Visual Studio Code version: 1.43.2
  • Java extension version: 0.59.0

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

跟踪 Java Language Server 如何处理包含 pom.xml 的 Maven 项目,包括 M2Eclipse 是否会在启动期间以及保存 Java 文件时调用已配置的插件执行。记录观察到的构建流程,以及是否支持简单的 Java 编译模式,并将 issue 中的 Maven 插件示例作为预期场景。

由索引模型根据 Issue 内容生成。

评估

技术栈
java, vscode
领域
build-system, developer-experience
Issue 类型
文档
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
需要澄清
新手友好度
25/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。