-
-
Notifications
You must be signed in to change notification settings - Fork 346
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
GenIdea: Scala 3 module don't work when scala-library
is before scala3-library
entry in iml
config
#2867
Comments
Thanks for the report! So the exception stacktrace is shown in IDEA when you build the whole project? It seems to come from IDEA itself, not Mill, and should reported there, too. Maybe we generate the settings not the way they expect, but we have no control over any copy processes IDEA thinks it has to run. About the other issue:
It looks like just re-ordering these two entries and making the
Can you confirm this also works for you? I'd favor this solution over yours, as your fix refers to some application level library we don't control and therefore also can't guarantee to exists. |
Correct, when doing "Build Project" from IDEA. Removing
Confirmed reordering also works. I also favor this solution. That application library was just a default added by IDEA when creating Scala project from IDEA (vs import). It is irrelevant otherwise. |
I came across the same issues with mill 0.11.6 and IDEA 2023.3.1. I can confirm that the proposed reordering resolves the issues. Will |
Having more than one issue in one ticket is a bad idea, as it always makes working on it harder. First when you review it, later, when you're looking for open tasks, then again when you want to address is via a link, and so on. Next time, please open each issue in it's own ticket. I think the main issue is the order of the Scala library path entries. A proposed solution is to always have the Scala 3 entry before the Scala 2 entry, which was reported to fix the issue in #2867 (comment) and #2867 (comment). |
scala-library
comes before scala3-library
entry in module config
scala-library
comes before scala3-library
entry in module configscala-library
is before scala3-library
entry in iml
config
Some more details about the implementation. When I played with the implementation last year, I noticed a fix is not as trivial as re-ordering the Once I find the branch/stash again, I can share my work on this issue. |
Hello! I am from the IntelliJ Scala Plugin team. We had a similar issue with SBT projects some time ago: Here are some insights from our fix for SBT:
Below is an example of a simple SBT project structure. The file contents are as follows: <component name="libraryTable">
<library name="sbt: org.scala-lang:scala3-library_3:3.3.3:jar" external-system-id="SBT">
<CLASSES>
<root url="jar://$USER_HOME$/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala3-library_3/3.3.3/scala3-library_3-3.3.3.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$USER_HOME$/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala3-library_3/3.3.3/scala3-library_3-3.3.3-sources.jar!/" />
</SOURCES>
</library>
</component> <component name="libraryTable">
<library name="sbt: org.scala-lang:scala-library:2.13.12:jar" external-system-id="SBT">
<CLASSES>
<root url="jar://$USER_HOME$/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala-library/2.13.12/scala-library-2.13.12.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$USER_HOME$/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala-library/2.13.12/scala-library-2.13.12-sources.jar!/" />
</SOURCES>
</library>
</component> <component name="libraryTable">
<library name="sbt: scala-sdk-3.3.3" type="Scala">
<properties>
<language-level>Scala_3_3</language-level>
<scaladoc-extra-classpath>
<root url="file://$USER_HOME$/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/fasterxml/jackson/core/jackson-annotations/2.15.1/jackson-annotations-2.15.1.jar" />
<root url="file://$USER_HOME$/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/fasterxml/jackson/core/jackson-core/2.15.1/jackson-core-2.15.1.jar" />
<root url="file://$USER_HOME$/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/fasterxml/jackson/core/jackson-databind/2.15.1/jackson-databind-2.15.1.jar" />
<root url="file://$USER_HOME$/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/fasterxml/jackson/dataformat/jackson-dataformat-yaml/2.15.1/jackson-dataformat-yaml-2.15.1.jar" />
<root url="file://$USER_HOME$/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/fasterxml/jackson/datatype/jackson-datatype-jsr310/2.12.1/jackson-datatype-jsr310-2.12.1.jar" />
<root url="file://$USER_HOME$/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/vladsch/flexmark/flexmark-ext-anchorlink/0.62.2/flexmark-ext-anchorlink-0.62.2.jar" />
<root url="file://$USER_HOME$/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/vladsch/flexmark/flexmark-ext-autolink/0.62.2/flexmark-ext-autolink-0.62.2.jar" />
<root url="file://$USER_HOME$/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/vladsch/flexmark/flexmark-ext-emoji/0.62.2/flexmark-ext-emoji-0.62.2.jar" />
<root url="file://$USER_HOME$/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/vladsch/flexmark/flexmark-ext-gfm-strikethrough/0.62.2/flexmark-ext-gfm-strikethrough-0.62.2.jar" />
<root url="file://$USER_HOME$/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/vladsch/flexmark/flexmark-ext-gfm-tasklist/0.62.2/flexmark-ext-gfm-tasklist-0.62.2.jar" />
<root url="file://$USER_HOME$/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/vladsch/flexmark/flexmark-ext-ins/0.62.2/flexmark-ext-ins-0.62.2.jar" />
<root url="file://$USER_HOME$/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/vladsch/flexmark/flexmark-ext-superscript/0.62.2/flexmark-ext-superscript-0.62.2.jar" />
<root url="file://$USER_HOME$/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/vladsch/flexmark/flexmark-ext-tables/0.62.2/flexmark-ext-tables-0.62.2.jar" />
<root url="file://$USER_HOME$/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/vladsch/flexmark/flexmark-ext-wikilink/0.62.2/flexmark-ext-wikilink-0.62.2.jar" />
<root url="file://$USER_HOME$/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/vladsch/flexmark/flexmark-ext-yaml-front-matter/0.62.2/flexmark-ext-yaml-front-matter-0.62.2.jar" />
<root url="file://$USER_HOME$/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/vladsch/flexmark/flexmark-jira-converter/0.62.2/flexmark-jira-converter-0.62.2.jar" />
<root url="file://$USER_HOME$/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/vladsch/flexmark/flexmark-util-ast/0.62.2/flexmark-util-ast-0.62.2.jar" />
<root url="file://$USER_HOME$/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/vladsch/flexmark/flexmark-util-builder/0.62.2/flexmark-util-builder-0.62.2.jar" />
<root url="file://$USER_HOME$/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/vladsch/flexmark/flexmark-util-collection/0.62.2/flexmark-util-collection-0.62.2.jar" />
<root url="file://$USER_HOME$/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/vladsch/flexmark/flexmark-util-data/0.62.2/flexmark-util-data-0.62.2.jar" />
<root url="file://$USER_HOME$/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/vladsch/flexmark/flexmark-util-dependency/0.62.2/flexmark-util-dependency-0.62.2.jar" />
<root url="file://$USER_HOME$/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/vladsch/flexmark/flexmark-util-format/0.62.2/flexmark-util-format-0.62.2.jar" />
<root url="file://$USER_HOME$/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/vladsch/flexmark/flexmark-util-html/0.62.2/flexmark-util-html-0.62.2.jar" />
<root url="file://$USER_HOME$/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/vladsch/flexmark/flexmark-util-misc/0.62.2/flexmark-util-misc-0.62.2.jar" />
<root url="file://$USER_HOME$/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/vladsch/flexmark/flexmark-util-options/0.62.2/flexmark-util-options-0.62.2.jar" />
<root url="file://$USER_HOME$/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/vladsch/flexmark/flexmark-util-sequence/0.62.2/flexmark-util-sequence-0.62.2.jar" />
<root url="file://$USER_HOME$/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/vladsch/flexmark/flexmark-util-visitor/0.62.2/flexmark-util-visitor-0.62.2.jar" />
<root url="file://$USER_HOME$/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/vladsch/flexmark/flexmark-util/0.62.2/flexmark-util-0.62.2.jar" />
<root url="file://$USER_HOME$/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/vladsch/flexmark/flexmark/0.62.2/flexmark-0.62.2.jar" />
<root url="file://$USER_HOME$/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/nl/big-o/liqp/0.8.2/liqp-0.8.2.jar" />
<root url="file://$USER_HOME$/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/antlr/antlr4-runtime/4.7.2/antlr4-runtime-4.7.2.jar" />
<root url="file://$USER_HOME$/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/jetbrains/annotations/15.0/annotations-15.0.jar" />
<root url="file://$USER_HOME$/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/jsoup/jsoup/1.17.2/jsoup-1.17.2.jar" />
<root url="file://$USER_HOME$/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/nibor/autolink/autolink/0.6.0/autolink-0.6.0.jar" />
<root url="file://$USER_HOME$/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala3-tasty-inspector_3/3.3.3/scala3-tasty-inspector_3-3.3.3.jar" />
<root url="file://$USER_HOME$/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scaladoc_3/3.3.3/scaladoc_3-3.3.3.jar" />
<root url="file://$USER_HOME$/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/yaml/snakeyaml/2.0/snakeyaml-2.0.jar" />
<root url="file://$USER_HOME$/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/ua/co/k/strftime4j/1.0.5/strftime4j-1.0.5.jar" />
</scaladoc-extra-classpath>
<compiler-classpath>
<root url="file://$USER_HOME$/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala-library/2.13.12/scala-library-2.13.12.jar" />
<root url="file://$USER_HOME$/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala3-library_3/3.3.3/scala3-library_3-3.3.3.jar" />
<root url="file://$USER_HOME$/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/net/java/dev/jna/jna/5.3.1/jna-5.3.1.jar" />
<root url="file://$USER_HOME$/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/jline/jline-reader/3.19.0/jline-reader-3.19.0.jar" />
<root url="file://$USER_HOME$/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/jline/jline-terminal-jna/3.19.0/jline-terminal-jna-3.19.0.jar" />
<root url="file://$USER_HOME$/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/jline/jline-terminal/3.19.0/jline-terminal-3.19.0.jar" />
<root url="file://$USER_HOME$/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/modules/scala-asm/9.5.0-scala-1/scala-asm-9.5.0-scala-1.jar" />
<root url="file://$USER_HOME$/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala3-compiler_3/3.3.3/scala3-compiler_3-3.3.3.jar" />
<root url="file://$USER_HOME$/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala3-interfaces/3.3.3/scala3-interfaces-3.3.3.jar" />
<root url="file://$USER_HOME$/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/tasty-core_3/3.3.3/tasty-core_3-3.3.3.jar" />
<root url="file://$USER_HOME$/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-sbt/compiler-interface/1.9.3/compiler-interface-1.9.3.jar" />
<root url="file://$USER_HOME$/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-sbt/util-interface/1.9.2/util-interface-1.9.2.jar" />
</compiler-classpath>
<compiler-bridge-binary-jar>file://$USER_HOME$/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala3-sbt-bridge/3.3.3/scala3-sbt-bridge-3.3.3.jar</compiler-bridge-binary-jar>
</properties>
<CLASSES />
<JAVADOC />
<SOURCES />
</library>
</component> Note that |
In case you have any other questions related to IntelliJ Scala Plugin welcome to our If you have any issue to report, please use |
Also, maybe you could take a look at |
@unkarjedy Thank you very much for you comments. I think the idea of introducing a scala-sdk entry looks like a nice solution. I'd tried to fix this before, but the fact the the compiler info was attached to one of the scala libraries was hard to fix without major reorganizations. Once I find the time, I will revisit this issue and try to come up with a solution based on your insights. |
@unkarjedy Is there somewhere some documentation about the xml formats? E.g. the what the |
No, there is no such documentation. The serialisation format of XML files is an implementation detail.
To my knowledge, there is no documentation on this as well. Anyway, AFAIU the prefix is not mandatory. |
On the Mill site, in the section "IntelliJ IDEA Support" there is this paragraph:
I don't know the profile of average Mill user and how frequently they have mixed Kotlin/Scala projects. Maintaining BTW BSP-IntelliJ integration is not mentioned in the README |
Thank you @unkarjedy for all the insights. I agree that BSP should be the preferred IDE integration. An yet, in polyglot projects, you still have more options when you directly generate But I see that IDEA is using BSP for more languages nowadays, so I'm happy to revisit that. And I encourage users who find things work well to report back and update the documentation. |
Previously, we attached the compiler setup to the scala-library entry. This doen't work well for Scala 3 projects, since there are multiple scala-library entries present, one for Scala 2 and one for Scala 3. If the Scala 2 version comes first, IJ uses the wrong compiler setup. This change splits the scala-library from the compiler setup. The compiler setup now becomes a dedicated synthetic `scala-SDK` library entry for each Scala module. The scala-library no longer has any special semantic and is just an ordinary jar. Only one scala-SDK entry is added to each Scala module resulting in a proper setup. Fix #2867 Pull request: #3154
Fixed in |
build.sc:
milltest/src/Main.scala:
Using Mill 0.11.5:
./mill mill.idea.GenIdea/idea
Probably caused by #2638, so downgrade Mill to 0.11.1:
./mill mill.scalalib.GenIdea/idea
.idea/mill_modules/milltest.iml
and replacewith
The text was updated successfully, but these errors were encountered: