Skip to content

Fix intellij scalac settings #5220

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

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

hwielenberg
Copy link
Contributor

@hwielenberg hwielenberg commented May 28, 2025

This fixes an issue that the translation from mill module names to intelliJ module names sometimes uses . as a delimiter and sometimes -. Which causes intelliJ not to be able to link certain settings to the module.

The issue was that at one point all Segment.Cross were translated into Segment.Label. And those two use a different delimiter.

  def moduleName(p: Segments): String =
    p.value
      .foldLeft(new StringBuilder()) {
        case (sb, Segment.Label(s)) if sb.isEmpty => sb.append(s)
        case (sb, Segment.Cross(s)) if sb.isEmpty => sb.append(s.mkString("-"))
        case (sb, Segment.Label(s)) => sb.append(".").append(s)
        case (sb, Segment.Cross(s)) => sb.append("-").append(s.mkString("-"))
      }
      .mkString
      .toLowerCase()

This fix might be quite intrusive for existing projects as it renames the actual modules. The intended delimiter - was not used in most places. This could be avoided by using the delimiter . for cross modules as well.

I tested it with this setup. (Are there any automated tests for genIdea?)

@hwielenberg
Copy link
Contributor Author

I probably should have started with a fix for the main branch and not with a backport for 0.12 🤦

@lihaoyi
Copy link
Member

lihaoyi commented May 29, 2025

@hwielenberg you can run the gen-idea tests via ./mill 'integration.ide[gen-idea].packaged.daemon'

@hwielenberg hwielenberg force-pushed the fix_intellij_scalac_settings branch from b8842b2 to ec564e0 Compare May 29, 2025 10:54
@hwielenberg hwielenberg changed the base branch from 0.12.x to main May 29, 2025 10:54
</parameters>
<plugins></plugins>
</profile>
<profile name="mill 3" modules="moduleg-2.12.5,moduleg-2.13.6">
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has always used a -

@@ -16,6 +16,8 @@
<module fileurl="file://$PROJECT_DIR$/.idea/mill_modules/moduled.iml" filepath="$PROJECT_DIR$/.idea/mill_modules/moduled.iml"/>
<module fileurl="file://$PROJECT_DIR$/.idea/mill_modules/modulee.iml" filepath="$PROJECT_DIR$/.idea/mill_modules/modulee.iml"/>
<module fileurl="file://$PROJECT_DIR$/.idea/mill_modules/modulef.iml" filepath="$PROJECT_DIR$/.idea/mill_modules/modulef.iml"/>
<module fileurl="file://$PROJECT_DIR$/.idea/mill_modules/moduleg-2.12.5.iml" filepath="$PROJECT_DIR$/.idea/mill_modules/moduleg-2.12.5.iml"/>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix changes this and the file name itself from moduleg.2.12.5.iml to moduleg-2.12.5.iml

@hwielenberg
Copy link
Contributor Author

Is there a way to get the path to COURSIER_HOME in the test that works in all environments?

//running on ci
<plugin path="/home/runner/.cache/coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala3-compiler_3/3.7.0/scala3-compiler_3-3.7.0.jar"/>
// running locally
<plugin path="/Users/henning.wielenberg/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala3-compiler_3/3.7.0/scala3-compiler_3-3.7.0.jar"/>

//Instead of using
<plugin path="<!-- IGNORE -->org/scala-lang/scala3-compiler_3/3.7.0/scala3-compiler_3-3.7.0.jar"/>
//I'd rather do 
<plugin path="$$COURSIER_HOME$$org/scala-lang/scala3-compiler_3/3.7.0/scala3-compiler_3-3.7.0.jar"/>
expected.replace("$$COURSIER_HOME$$", coursierHome())

Copy link
Member

@lefou lefou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Please mark this as "ready for review" once you are done with refining.

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

Successfully merging this pull request may close these issues.

3 participants