Gradle command line build OK, IntelliJ stuck looking for stale dependency version
Answered
When i compile, build, deploy my gradle project from the command line everything is ok.
However, IntelliJ compilation fails. The error indicates IntelliJ is looking for a specific dated snapshot version of a dependency, not just the snapshot version specified in build.gradle.
From build.gradle:
// container provided libraries
compileOnly 'log4j:log4j:1.2.17@jar',
....
'net.careweb:util.document:1.3.3570-SNAPSHOT@jar',
Error:
Could not find util.document-1.3.3570-SNAPSHOT.jar (net.careweb:util.document:1.3.3570-SNAPSHOT:20211011.140734-2).
Searched in the following locations:
file:/Users/ivanaatcareweb/.m2/repository/net/careweb/util.document/1.3.3570-SNAPSHOT/util.document-1.3.3570-20211011.140734-2.jar
The jar it should find is in the .m2 repo as util.document-1.3.3570-SNAPSHOT.jar
How do i fix this?
Please sign in to leave a comment.
How did you install that snapshot version?
May be related to https://youtrack.jetbrains.com/issue/IDEA-185913 It would be nice to confirm this. Is it possible to get a reproducible project?
The snapshot version is from a another locally built gradle project. So it is functionally the same setup as the link you posted, but in our case IntelliJ is only looking for the one version, not for all historic versions. I cannot send you the projects because they are work projects.
Here is the similar issue: IDE Gradle integration is searching for dated version instead of SNAPSHOT version in the local repository: https://youtrack.jetbrains.com/issue/IDEA-267513
How do you publish them to Maven local repository? Do they have xml metadata information?
Please try if it helps to enable the Settings (Preferences on macOS) | Build, Execution, Deployment | Build Tools | Maven | 'Always update snapshots' option.
Please also try the 'Refresh Gradle dependencies' action: https://stackoverflow.com/a/47557700/2000323 in Gradle tool window. If you use Gradle version less than 6 please try also this suggestion https://stackoverflow.com/a/32654639/2000323 https://stackoverflow.com/a/62085606/2000323
Please attach IDE logs zipped (use Help | Collect Logs and Diagnostic Data action to gather them), I will check them if there are any suspicions messages. For uploading you can use https://uploads.jetbrains.com or any file sharing service. Thanks.
Thank you Andrey, your first advice to check 'Always update snapshots' fixed part of the problem. The project now builds inside IntelliJ.
However, it 'cannot' find all the dependencies, but they are all there including the xml metadata (maven-metadata-local.xml).
That is, obviously the dependencies are found, otherwise the build would fail, but some dependencies are not listed in 'External Libraries' and show up as red markings all over the code. The missing dependencies are mentioned in the logs, example:
I have tried:
This builds the project but does not solve the problem of missing dependencies.
I have uploaded the log files, maybe you can find the cause.
Hi Andrey, no need to go through the logs, this solution worked:
https://stackoverflow.com/a/62272439/1085370
(refreshing gradle dependecies by right-clicking the project in the gradle-window > Refresh Gradle Dependencies)
Thanks for the information!