简体   繁体   中英

In Eclipse, changes to library not recognized in current project

In a project dependency (library) to the current project, changes to the library are not reflected in the main project.

Example - edit the library, add a method to a class. Compile/install the library (via Maven). In the main project, build, refresh, close/reopen the project, restart Eclipse, whatever you like. The new method is flagged as an error (method xxx is undefined for the type blah).

The main project is a Gradle project and it builds and runs fine from the command line, so it's only Eclipse that isn't seeing the updated library for some reason. I've re-ran "./gradlew eclipse" and refreshed, closed/opened the project, exited/restarted Eclipse multiple times. I've deleted the contents of the build directory and refreshed/closed/opened/restarted. Even upgraded to the latest version of Eclipse (2020-03).

I've also verified that the Eclipse "Project and External Dependencies" is pointing to the right library in $HOME/.m2/repository/... and the library is indeed getting updated from the Maven compile/install.

It's like Eclipse is caching the definition of the class somewhere and it's not noticing that the jar file is being updated to refresh the information and get the new methods. I've scoured the internet for about an hour on topics related to this and have come up blank.

  1. Delete the dependency jar manually from the repo.
  2. Check that all other methods from the dependency library are as well shown as 'undefined'. If it doesn't, the issue should be with the cache. Somehow your cache is not invalidated properly. Restarting your machine would be the most lame but worthy solution.
  3. If all other methods are as well shown as 'undefined', rebuild the dependency library and re-import it in the current module.
  4. If the method still shows as 'undefined', go for the basic checks once again, right from type case.

Let me know how it goes.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM