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

GenIdea: Put module dependencies after library dependencies #2925

Merged
merged 3 commits into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 16 additions & 9 deletions idea/src/mill/idea/GenIdeaImpl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -786,6 +786,11 @@ case class GenIdeaImpl(
</library>
</component>
}

/**
* @param libNames The library dependencies (external dependencies)
* @param depNames The dependency modules (internal dependencies)
*/
def moduleXmlTemplate(
basePath: os.Path,
scalaVersionOpt: Option[String],
Expand Down Expand Up @@ -871,22 +876,24 @@ case class GenIdeaImpl(
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />

{
for (dep <- depNames.sorted)
yield dep.scope match {
case None => <orderEntry type="module" module-name={dep.value} exported="" />
case Some(scope) =>
<orderEntry type="module" module-name={dep.value} exported="" scope={scope} />
}
}
{
for (name <- libNames.sorted)
yield name.scope match {
case None => <orderEntry type="library" name={name.value} level="project" />
case Some(scope) =>
<orderEntry type="library" scope={scope} name={name.value} level="project" />
}

}
{
// we place the module dependencies after the library dependencies, as IJ is leaking the (transitive)
// library dependencies of the module dependencies, even if they are not exported.
// This can result in wrong classpath when lib dependencies are refined.
for (dep <- depNames.sorted)
yield dep.scope match {
case None => <orderEntry type="module" module-name={dep.value} exported="" />
case Some(scope) =>
<orderEntry type="module" module-name={dep.value} exported="" scope={scope} />
}
}
</component>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</content>
<orderEntry type="inheritedJdk"/>
<orderEntry type="sourceFolder" forTests="false"/>
<orderEntry type="module" module-name="helloworld" exported=""/>
<orderEntry type="library" name="scala-library-2.13.6.jar" level="project"/>
<orderEntry type="module" module-name="helloworld" exported=""/>
</component>
</module>
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
</content>
<orderEntry type="inheritedJdk"/>
<orderEntry type="sourceFolder" forTests="false"/>
<orderEntry type="module" module-name="helloworld" exported=""/>
<orderEntry type="library" scope="PROVIDED" name="jcl-over-slf4j-1.7.25.jar" level="project"/>
<orderEntry type="library" scope="RUNTIME" name="logback-classic-1.2.3.jar" level="project"/>
<orderEntry type="library" name="logback-core-1.2.3.jar" level="project"/>
<orderEntry type="library" name="scala-library-2.12.5.jar" level="project"/>
<orderEntry type="library" name="slf4j-api-1.7.25.jar" level="project"/>
<orderEntry type="module" module-name="helloworld" exported=""/>
</component>
</module>