"Could not resolve all dependencies" because of maven local repository


(Thibault Delor) #1

I currently work on two projects, one on Maven, one on Gradle. My Gradle project refuse to compile :

What went wrong:
   Execution failed for task ':compileJava'.
   > Could not resolve all dependencies for configuration ':compile'.
      > Artifact 'javax.transaction:jta:1.1@jar' not found.

In my gradle project I need to add the maven local repository because I need some jars that are compiled and installed there. My problem happen when my maven repository is full of pom file but without corresponding jars. If I empty the maven local repository, I can compile, everything works fine. That is really annoying.


Thorny issue of being unable to resolve jar to local .m2 repostory
(Jon Austen) #2

That looks similar to an error I had a few days ago. In my case it was because I was using “testCompile” in my dependencies section instead of “compile” and so my .java main classes couldn’t find the dependency since I only provided them for the “test” sub-project.


(Peter Niederwieser) #3

It’s the expected behavior. I’d assume that declaring the local Maven repo last will solve the problem.


(Thibault Delor) #4

I don’t see what can be the benefits of this behavior. Make the build failed while it could succeed… Maybe a warning like “this repository has an inconsistent state (explanation…) for dependency X, skipping it”.

I think I understand the reason of why it has been implemented like that, and I think that maven work like that with remote repositories. The thing is, maven have a different behaviour for its local repository and is aware that the local repository may be not in a final state.

So, Gradle is not aware of that and fails for my build. IMHO, the rule #1 for dependency resolution should be “Never fail to resolve a dependency unless you really cannot resolve it or the user configuration avoids you to do it.”


(Peter Niederwieser) #5

I didn’t say it’s necessarily the best conceivable behavior, just that it’s the currently expected behavior (because the local repo isn’t treated specially). In a sense, Gradle already handles this case better than Maven (!) because it allows you to specify the ‘artifactUrls’ for a repository.

How did you get into this state? As a result of a failed Maven build?