Skip to content

Commit

Permalink
GenIdea: Put module dependencies after library dependencies (#2925)
Browse files Browse the repository at this point in the history
This is to have explicitly configured lib dependencies before (unwanted)
transitive ones from module dependencies.

Pull request: #2925
  • Loading branch information
lefou authored Dec 14, 2023
1 parent e45e15b commit 0770d3d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
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>

0 comments on commit 0770d3d

Please sign in to comment.