-
-
Notifications
You must be signed in to change notification settings - Fork 353
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
Improve Intellij Idea support #351
Improve Intellij Idea support #351
Conversation
Improves the Intellij Idea support in various ways : * Cherrypicks the idea conf that needs deleting rather than deleting the whole .idea directory. That directory contains elements of configuration like VCS reference that were annoying to set again every time mill regenerated idea config. * Attempts to retrieve libraries that the build depends on by inspecting the classloader of the top module * Attempts at grouping jars and sources together in order to have both in the same idea files, which appears to give better jump to definition * Hacks the library names for the libraries the build depends on, in order to match Intellij's ammonite support and not show red to the user about the library that has successfuly been resolved. Also allows to jump to the library sources from the magic import.
@@ -34,7 +35,8 @@ object GenIdeaImpl { | |||
|
|||
val jdkInfo = extractCurrentJdk(pwd / ".idea" / "misc.xml").getOrElse(("JDK_1_8", "1.8 (1)")) | |||
|
|||
rm! pwd/".idea" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this change makes the user's life more comfortable by not asking them to reset various pieces of mill-unrelated configuration
@@ -81,6 +83,19 @@ object GenIdeaImpl { | |||
res.items.toList.map(_.path) | |||
} | |||
|
|||
val buildDepsPaths = Try(evaluator |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
attempts to retrieve magic imports
Tuple2(".idea"/'libraries/s"$name.xml", libraryXmlTemplate(name, url)) | ||
} | ||
|
||
val buildLibraries = buildLibraryPaths.map{path => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
buildLibraryPaths
is contained by allResolved
@@ -43,8 +43,6 @@ object GenIdeaTests extends TestSuite { | |||
millSourcePath / "generated" / ".idea_modules" /"mill-build.iml", | |||
"gen-idea/idea/libraries/scala-library-2.12.4.jar.xml" -> | |||
millSourcePath / "generated" / ".idea" / "libraries" / "scala-library-2.12.4.jar.xml", | |||
"gen-idea/idea/libraries/scala-library-2.12.4-sources.jar.xml" -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sources are grouped in the same file as the jar
@rockjam feel free to review this one, i might not get to it soon |
|
||
// Hack so that Intellij does not complain about unresolved magic | ||
// imports in build.sc when in fact they are resolved | ||
def sbtLibraryNameFromPom(pom : Path) : String = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I should maybe remove this, Intellij seems to be flaky as hell with this. It worked on a java library, doesn't seem to work on scala ones ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to ed958b7. Should they want to, this allows users to avoid the magic appearing in RED by defining their artifacts with ":" rather than "::" (which implies adding _2.12
to the artifact name) .
Note that the magic imports being red does not have any consequence on whether the artifact is actually indexed by IntelliJ and the ide's ability to resolve names coming from this artifact.
looks good i guess |
Thank you very much. @Baccata |
Improves the Intellij Idea support in various ways :
Hacks the library names for the libraries the build depends on, in order to match Intellij's ammonite support and not show red to the user about libraries that have successfuly been resolved. Also allows to jump to the library sources from the magic import.IntelliJ's magic import resolution (and its ability to not show it as red) is not robust. This seems like a problem to solve on the Intellij sideSolves #347