0

I usually use IntelliJ and SBT for my Scala projects, and am forced to use Eclipse with Gradle for a new project, both tools I'm finding to not be well suited to developing Scala.

I'm using Scala IDE 4.6.1, and sometimes when I import an existing Gradle Scala project I've cloned from a Git repo, it refuses to pull in the external dependencies listed in my build.gradle listed in the dependencies {... } block. My steps for import are:

    1. File->Import... ->Gradle/Existing Gradle Project- > Next ->
    1. I Select the cloned parent dir as the project root directory
    1. Click next and insure my Local Installation Directory is set to the proper place for Gradle: (C:\Program Files (x 86)\Gradle 4.6)
    1. Click Finish, and once everything is brought in, I right click the project folder in the project explorer, select the gradle folder, and click "refresh gradle project"

Sometimes this works, and sometimes it doesn't. When it works, it brings in 3 folders into the project: JRE System Library, Scala Library Container, and Referenced Libraries.

When it doesn't work, Referenced Libraries is missing, and the code red lines all the external dependencies of the project. Any ideas on how to fix?

NateH06
  • 3,154
  • 7
  • 32
  • 56
  • When it doesn't work, is there a red exclamation mark on the project folder? If so, there should be an error in the _Problems_ view why the project cannot be built. – howlger Mar 17 '19 at 09:48
  • @howgler No exclamation mark, but a red square `X` in the left corner of the weird icon cluster thing they have going on there. There are 500 problems, and the problems all say `Not found: `, which makes sense, it's not importing the external dependencies. – NateH06 Mar 17 '19 at 21:19

1 Answers1

0

Got the fix. So, if experiencing the above issues after following those steps:

  • Be sure in the project itself the .project file looks like the following:
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
  <name>YOUR PROJECT NAME</name>
  <comment></comment>
  <projects>
  </projects>
  <buildSpec>
      <buildCommand>
          <name>org.scala-ide.sdt.core.scalabuilder</name>
          <arguments>
          </arguments>
      </buildCommand>
      <buildCommand>
          <name>org.eclipse.buildship.core.gradleprojectbuilder</name>
          <arguments>
          </arguments>
      </buildCommand>
  </buildSpec>
  <natures>
      <nature>org.scala-ide.sdt.core.scalanature</nature>
      <nature>org.eclipse.jdt.core.javanature</nature>
      <nature>org.eclipse.buildship.core.gradleprojectnature</nature>
  </natures>
</projectDescription>
  • Then, derived from this answer in another thread, from your command line, navigate to just under the top level of the project folder and execute gradle cleanEclipse eclipse

Now the "External Libraries and Dependencies" OR "Referenced Libraries" should be viewable as a dropdown.

  • Now, in Eclipse, under the gradle tasks area, it may or may not say there are no gradle projects in the workspace. Even if your projects are viewable in the lefthand projects pane, you will have to re-import them following the steps 1-4 outlined in the original question.

Wait for it to finish and that should do it.

NateH06
  • 3,154
  • 7
  • 32
  • 56