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

Scala library is not bundled when the plugin is defined as a nested project #133

Open
odisseus opened this issue Nov 26, 2024 · 4 comments

Comments

@odisseus
Copy link

Steps to reproduce

  1. Download and extract the example project: plugin-repo.zip
  2. Run sbt clean packageArtifact.
  3. Check the contents of myAwesomePlugin/target/plugin directory. It will contain the JAR with the plugin code (and the dependency JARs if you add any), but the scala-library dependency will be missing.
  4. Run sbt runIDE and open any project. You will get a classloader error. The message can sometimes be quite obscure, but it is always caused by the missing Scala library.
  5. For comparison, re-define the project so that its base directory is in . (this can be done by uncommenting a few lines in build.sbt. After running sbt clean packageArtifact, observe that the target/plugin directory contains both the plugin JAR and the Scala library.

Adding ThisBuild / bundleScalaLibrary := true doesn't seem to have any effect.

This issue might be related to #106.

@vasilmkd
Copy link
Contributor

Hi there, thanks for the report.

packageLibraryMappings := { // non top level projects shouldn't have excessive scala-library mappings

You can experiment with setting packageLibraryMappings := Seq.empty, or adjusting the default values. Mapping to None means that the library dependency will be ignored in the final output.

@OndrejSpanel
Copy link

It seems to me many things do not work when I try to build a plugin in a subproject instead of root project. To start, it seems many settings need to be placed in ThisBuild, therefore affecting even modules which have no relation to the plugin,

I was not able to make even this working:

lazy val myPlugin = project.enablePlugins(SbtIdeaPlugin)

This works fine:

lazy val myPlugin = project.in(file(".")).enablePlugins(SbtIdeaPlugin)

The result of the plugin build was incomplete, done partly in myPlugin directory and partly in root directory.

If one wants to publish the plugin from a repository which also builds and publishes other things, it seems to me the only workable solution at the moment is to create a branch or a fork with completely different and independent build.sbt dedicated just to a plugin.

Maybe there are some settings how to make this work, but my impression is the only really supported scenario is when the whole build.sbt is dedicated to the plugin which is located at the build root?

@unkarjedy
Copy link
Member

unkarjedy commented Jan 13, 2025

but my impression is the only really supported scenario is when the whole build.sbt is dedicated to the plugin which is located at the build root?

I can confirm it with 100% certainty, but my impression is the same.
Right now it's supposed that the whole SBT project is dedicated to a single IntelliJ plugin.

It might be helpful to improve it.
In particular, it might be useful to support multiple plugins in a single project
(e.g. to split Scala Plugin to sub-plugins, e.g. Scala, Play, else...)
But it will most likely require significant refactoring, and I don't think we will find resources for that.

@OndrejSpanel
Copy link

But it will most likely require significant refactoring, and I don't think we will find resources for that.

Thanks. It is not a big issue, the dedicated build.sbt is workable. I am hitting more serious issues anyway, e.g. difficulties with using native OpenGL and LWJGL library. The whole process is quite complicated and when anything goes wrong, one does not get much useful information, e.g. why some particular jars are missing.

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

4 participants