Eclipse does not resolve dependencies - eclipse

I have declared dependencies in several subproject to another specific subproject like
dependencies {
...
implementation project(':projectx')
...
}
However all subprojects can not resolve this dependency, however ctrl+click works an jumps direcly to the class.
I am confused, but I guess this might be an Eclipse problem. Any idea? Are there any infos from my side are missing?

Downgrading from Gradle 7.5.1 to 7.4.2 solved the exact same problem for me. Windows -> Preferences -> Gradle -> Specific Gradle Version

Related

How to make Gradle add Lombok to its Project and external dependencies libraries?

I created a Java project in Eclipse Neon. I used Buildship 1.0.21 to import the project as a Gradle project and ran the wrapper and init commands to generate the build, settings and wrapper files.
The project has an empty source folder because I am trying to solve a similar problem on a more complicated project and taking the divide and conquer approach - just add Lombok dependency.
Here is my build.gradle as instructed on the lombok website:
apply plugin: 'java'
dependencies {
compileOnly "org.projectlombok:lombok:1.16.12"
}
and gradle-wrapper.properties if needed:
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.2.1-bin.zip /* <--- tried other versions too */
and I ran the jar file to install it on my eclipse. If I add the jar manually via "Java Build Path" it works but I want Gradle to handle this for me. When I refresh the project nothing happens - there is no lombok jar under "Projects and External Dependencies" and code relying on lombok will give errors.
There is another project I have which does have it there and I don't know what I did differently but I know it's possible.
I managed to solve this after trial and error. The build.gradle file must add the jcenter repository:
repositories {
jcenter()
}
Why this is the case and why this is not mentioned anywhere I don't know. But for now this is what works.

Intellij sbt won't resolve dependencies' dependencies

I have a Intellij Scala project, that depends on another lib, which in turn depends on some other libs (gson, log4j...), but somehow Intellij won't add those transitive dependencies to my project, so when I run my main method, jvm always complains no class found. I also tried sbt update and sbt update-classifier, they won't resolve down the dependency path as well. How can I have sbt resolve all levels of dependencies?
If all works in SBT command lines but not in Idea then remove the .idea folder and reload the SBT project in Idea.
I should warn that you will loose the project configs (such as run configs) by doing that.
I finally figure out what was wrong, it was the sbt-s3-resolver plugin I was using couldn't resolve maven style dependencies, I used an another plugin which supports maven libs and it worked. But I still couldn't figure out why it worked before.

IntelliJ Scala configuration issue

So, I downloaded Scala and configured paths, I can run Scala console from terminal, Scala plugin is installed and "hello world" is running...
The problem is that, when I write a "hello world" program:
object First {
def main(args: Array[String]): Unit = {
println(12)
}
}
it says: Cannot resolve symbol println
As I said, I can run this program and it prints out 12... Also, if I create a List or an array it "cannot resolve symbol" but everything runs with no problem at all...
In most cases I've found, there was problem with Java set up, but that's not the case here...
Within File->Project Structure, make sure that there is a scala library in Project Settings\Libraries
Or, make sure that you have added scala-compiler.jar, scala-library.jar to your project.
If it is still acting strange, try File->Invalidate Cache/Restart
I had a similar issue with IntelliJ for an SBT project I started, with a correctly installed Scala 2.11 library, etc. Invalidate Cache fixed it so that IntelliJ could find the symbols.
Ensure, that you have scala-library.jar and scala-compiler in your project libraries.
Then try invalidating cache (File->Invalidate Caches/Restart->Invalidate and Restart).
If it's still not working, try reloading all your maven projects. You can either reimport them manually or go to Maven Projects->Reimport All Maven Projects (blue arrows).
I had similar issue and the last thing worked for me.
I hope it helps :)
I have the same issue when I use the idea 15, and fixed it in these 2 steps:
File -> Project Structure -> Libraries -> + -> Scala SDK -> your version -> OK
Maven Projects -> choose your scala project -> Lifecycle -> clean -> compile
Done
Don't know if this will help, but it worked with my environment. Navigate to:
File > Project Structure > Modules
Then, when I tried to apply a minor change, I got a message about how the Content Roots was being shared between two different Modules (a conflict). After removing the conflicting Content Root(s) from one of the Modules, IntelliJ started resolving symbols correctly.
You will see Content Roots on the right-hand side of the dialog box under module "Sources" tab.
I have no idea if the conflict in "Content Root" was what kept IntelliJ from resolving symbols, but fixing this error cleared everything up without having to change anything else.
if your version IntelliJ IDEA 2016.3.4
Worksheet configuration error:: Can't find Scala module to run
project structure > Modules > + > new modules > scala > scala
I had this problem - it turned out to be caused by me upgrading Java on my Mac, so that my JDK's path (/Library/Java/JavaVirtualMachines/jdk1.8.0_172.jdk/Contents/Home) was no longer valid. I went into my Project Structure settings and updated the path to /Library/Java/Home, then the project could see the proper Java libraries.

Eclipse won't resolve new Gradle dependencies

I'm new to Gradle and have the Gradle Eclipse plugin (running Spring Tool Suite). Whenever I add a new dependency in the Gradle build file, like this for example:
dependencies {
...
compile 'javax.validation:validation-api:1.1.0.Final'
compile 'org.hibernate:hibernate-validator:5.0.1.Final'
...
}
Eclipse can't resolve the imports in the classes that need these. What am I missing here?
Is there some "update project" command I need to run?
I see... I needed to right-click the build.gradle file -> Gradle -> Refresh Dependencies.

Update my gradle dependencies in eclipse

I have a simple gradle project in my eclipse. I update the build.gradle to include a few apache http jars...
dependencies {
compile group: 'commons-collections', name: 'commons-collections', version: '3.2'
compile 'org.apache.httpcomponents:httpclient:4.2.3'
compile "org.apache.httpcomponents:httpmime:4.2.3"
testCompile group: 'junit', name: 'junit', version: '4.+'
}
However in my code, where I reference some Apache HTTP stuff I get:
The import org.apache.http cannot be resolved
Any tips on what I need to do to make Eclipse see the new dependencies in my build.gradle?
I tried doing a clean but that does not work. My gradle plugin is:
Gradle IDE 3.3.0.201307040643-RELEASE org.springsource.ide.eclipse.gradle.feature.feature.group GoPivotal, Inc.
You have to select "Refresh Dependencies" in the "Gradle" context menu that appears when you right-click the project in the Package Explorer.
Follow those steps to update Gradle project in Eclipse:
First, please check you have include eclipse gradle plugin. apply plugin : 'eclipse'
Then go to your project directory in Terminal. Type gradle clean and then gradle eclipse.
Then go to project in eclipse and refresh the project (Go to Project Explorer, select root of the project and hit F5 to refresh, or right click and select refresh in context menu).
Looking at the Eclipse plugin docs I found some useful tasks that rebuilt my classpath and updated the required dependencies.
First try gradle cleanEclipse to clean the Eclipse configuration completely. If this doesn;t work you may try more specific tasks:
gradle cleanEclipseProject to remove the .project file
gradle cleanEclipseClasspath to empty the project's classpath
Finally gradle eclipse to rebuild the Eclipse configuration
You have to make sure that "Dependency Management" is enabled. To do so, right click on the project name, go to the "Gradle" sub-menu and click on "Enable Dependency Management". Once you do that, Gradle should load all the dependencies for you.
I tried all above options but was still getting error, in my case issue was I have not setup gradle installation directory in eclipse, following worked:
eclipse -> Window -> Preferences -> Gradle -> "Select Local
Installation Directory"
Click on Browse button and provide path.
Even though question is answered, thought to share in case somebody else is facing similar issue.
Cheers !
In my case, I solved weird issues in Spring Tools Suite (essentially Eclipse) after I tried to upgrade Spring Boot and the changes didn't seem to be taking effect.
Right click on your project -> Gradle -> Refresh Gradle Project