question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Exclude compilation artifacts from searchable files

See original GitHub issue

IDEs usually provide a fast search feature, which allows you to search for some text in all the source files of your project. In the case of sbt projects, sbt generates a lot of small files in the target/ directory. When we import a project via BSP in an IDE, these compilation artifacts (the content of target/) are included in the scope of a search, making it slow, and showing irrelevant results.

I think the developer experience would be improved if we introduced a concept of paths excluded from the actual sources of the project, that IDEs could leverage.

Currently, importing a project in IntelliJ via the sbt import feature does exclude the target/ directories, but this is not the case when we import the same project via the BSP import feature (so, the sbt import does not suffer from this issue).


Here is a concrete example. I did sbt new scala/scala3.g8, and then imported the project (which uses sbt 1.5.5) in IntelliJ.

By default, IntelliJ imports the project via sbt, and the target/ directory is excluded from the indexed files, as you can see here:

Screenshot from 2021-07-30 11-16-01

Then, if I re-import the project via BSP, the target/ directory is not anymore excluded (it’s interesting to see that project/target/ is excluded, though…):

Screenshot from 2021-07-30 11-20-23

As a consequence, when I search something, IntelliJ also searches in the target/ directory:

Screenshot from 2021-07-30 11-22-07

Logs: bsp-protocol-trace-2021-07-30T11-17-14.log

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
povdercommented, Jul 28, 2022

This PR will fix this issue for the protocol itself: https://github.com/build-server-protocol/build-server-protocol/pull/269. Then, this sbt PR https://github.com/sbt/sbt/pull/6985 and intellij-scala PR https://github.com/JetBrains/intellij-scala/pull/627 will fix the problem for IntelliJ IDEA users.

1reaction
olafurpgcommented, Aug 9, 2021

I think it would be nice if BSP had a notion of declaring what directories should be excluded from the IDE. I recall that the Pants IntelliJ plugin works around this limitation by manually excluding Bloop directories when using Pants via BSP. It would be more natural if the protocol had a notion of “exclude directories”, which can cover more broad directories like target/ instead of only excluding the classes directories.

Read more comments on GitHub >

github_iconTop Results From Across the Web

TeamCity Artifacts; Exclude Individual Files - Stack Overflow
It is a horrible hack, but one way you could get it to work would be to set up a new build configuration...
Read more >
Exclude patterns for artifact paths : TW-5244 - YouTrack
Add the ability to exclude directories/files for the set of artifacts on General Settings->Artifact Paths. Examples would be "-test**.**" and "-.svn".
Read more >
How to: Exclude Files from the Build - MSBuild | Microsoft Learn
Exclude a file or directory from the inputs for a build​​ To exclude an item from the item list, use the Exclude attribute....
Read more >
Exclude files from pull request diffs | Bitbucket Cloud
Exclude files from appearing in the diff view of a pull request in Bitbucket Cloud by specifying patterns in the 'Excluded files' repository...
Read more >
Learning the Basics - Gradle User Manual
In Gradle and Ivy, a module can have multiple artifacts. Each artifact can have a different set of dependencies. File dependencies. Projects sometimes...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found