Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

saving non-Java file under source folder leads to rebuild #3120

Open
angelozerr opened this issue Mar 28, 2024 · 4 comments
Open

saving non-Java file under source folder leads to rebuild #3120

angelozerr opened this issue Mar 28, 2024 · 4 comments
Assignees

Comments

@angelozerr
Copy link

When I create a foo.ts file in src folder, and I save it, there is a workspace/didChangeWatchedFiles which seems retrigger the project build.

It is because JDT LS returns this following glob pattern:

{
    "globPattern": "**/src/**"
}

@rgrunber told me that you did that perhaps to support generated files. I wonder if you should avoid triggering a build if it is not a java files?

Here my LSP traces:

[Trace - 4:24:49 PM] Sending notification 'workspace/didChangeWatchedFiles'.
Params: {
    "changes": [
        {
            "uri": "file:///c%3A/Users/azerr/git/intellij-quarkus/projects/lsp4mp/projects/maven/microprofile-health-3/src/main/foo.ts",
            "type": 2
        }
    ]
}


[Trace - 4:24:50 PM] Received notification 'textDocument/publishDiagnostics'.
Params: {
    "uri": "file:///C:/Users/azerr/git/intellij-quarkus/projects/lsp4mp/projects/maven/microprofile-health-3/",
    "diagnostics": []
}


[Trace - 4:24:50 PM] Received notification 'textDocument/publishDiagnostics'.
Params: {
    "uri": "file:///C:/Users/azerr/git/intellij-quarkus/projects/lsp4mp/projects/maven/microprofile-health-3/pom.xml",
    "diagnostics": []
}


[Trace - 4:24:50 PM] Received request 'window/workDoneProgress/create - (55)'.
Params: {
    "token": "78f4c054-433c-4ceb-8434-fe76c972e3c5"
}


[Trace - 4:24:50 PM] Sending response 'window/workDoneProgress/create - (55)'. Processing request took 0ms
No result returned.


[Trace - 4:24:50 PM] Received notification '$/progress'.
Params: {
    "token": "78f4c054-433c-4ceb-8434-fe76c972e3c5",
    "value": {
        "kind": "begin",
        "title": "Building",
        "message": "Building"
    }
}


[Trace - 4:24:50 PM] Received notification '$/progress'.
Params: {
    "token": "78f4c054-433c-4ceb-8434-fe76c972e3c5",
    "value": {
        "kind": "report",
        "message": "Building - 0% ",
        "percentage": 0
    }
}


[Trace - 4:24:50 PM] Received notification '$/progress'.
Params: {
    "token": "78f4c054-433c-4ceb-8434-fe76c972e3c5",
    "value": {
        "kind": "report",
        "message": "Building - 75% Refreshing '/microprofile-health-3'.",
        "percentage": 75
    }
}


[Trace - 4:24:50 PM] Received notification '$/progress'.
Params: {
    "token": "78f4c054-433c-4ceb-8434-fe76c972e3c5",
    "value": {
        "kind": "report",
        "message": "Building - 77% Refreshing '/microprofile-health-3'.",
        "percentage": 76
    }
}


[Trace - 4:24:50 PM] Received notification '$/progress'.
Params: {
    "token": "78f4c054-433c-4ceb-8434-fe76c972e3c5",
    "value": {
        "kind": "end",
        "message": "Building"
    }
}


[Trace - 4:29:50 PM] Received request 'window/workDoneProgress/create - (56)'.
Params: {
    "token": "fbd7a42c-2eb2-47b7-b0bf-e5868cf7ddd1"
}


[Trace - 4:29:50 PM] Sending response 'window/workDoneProgress/create - (56)'. Processing request took 0ms
No result returned.


[Trace - 4:29:50 PM] Received notification '$/progress'.
Params: {
    "token": "fbd7a42c-2eb2-47b7-b0bf-e5868cf7ddd1",
    "value": {
        "kind": "begin",
        "title": "Building",
        "message": "Building"
    }
}


[Trace - 4:29:50 PM] Received notification '$/progress'.
Params: {
    "token": "fbd7a42c-2eb2-47b7-b0bf-e5868cf7ddd1",
    "value": {
        "kind": "report",
        "message": "Building - 0% ",
        "percentage": 0
    }
}


[Trace - 4:29:50 PM] Received notification '$/progress'.
Params: {
    "token": "fbd7a42c-2eb2-47b7-b0bf-e5868cf7ddd1",
    "value": {
        "kind": "end",
        "message": "Building"
    }
}

@rgrunber rgrunber self-assigned this Mar 28, 2024
@rgrunber
Copy link
Contributor

rgrunber commented Mar 28, 2024

I'm able to reproduce. Here's what I see so far :

The reason the build is triggered seems like a side effect.

The code ends up there and that method triggers the diagnostics clearing + the rebuild at :

Maybe we need to find a way to avoid that side effect. I'll need to look further to figure out how that triggers the rebuild. I'm thinking of examples like Protobuf, where being able to trigger rebuilds from changes to non-Java files is needed, but if this doesn't contribute to that, then we should prevent it from happening.

@rgrunber
Copy link
Contributor

Nevermind. @snjeza pointed out that this is an incremental autobuild. No other classfiles get rebuilt (I checked timestamps). Simply the non-Java file gets updated (copied) into the output folder.

I think we can probably close this, although it's a bit strange for the autobuild side effect to be purely a result of refreshing the parent in a utility method that simply returns the resource of a uri.

@huangfeiyu
Copy link

@rgrunber I am wonder may the side effect caused dead loop. Say in a maven project, front engineer put some front source files (less, ts etc) in src/main/webapp/, and use maven plugin frontend-maven-plugin to build the front files, the target directory of the front build may still in src/main/webapp/, if the target file trigger auto build too, there is ever ending build.

@rgrunber
Copy link
Contributor

rgrunber commented May 3, 2024

A similar issue was reported at redhat-developer/vscode-java#3639 . Although that one seems different in that the file being refreshed is in the target folder, though it is a non-source file generated by the build.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants