7

I'm having build error with following build.gradle.

apply plugin: 'java'
apply plugin: 'idea'

sourceCompatibility = 1.7
version = '1.0'

repositories {
    mavenLocal()
    mavenCentral()
}

dependencies {
    compile 'org.foo.group:my-artifact:0.0.1-final'
}

group, artifact and version are correct. I've tried it with a maven project and the build was successful, but in gradle project it gives me following error:

:jar UP-TO-DATE
:assemble UP-TO-DATE
:compileTestJava UP-TO-DATE
:processTestResources UP-TO-DATE
:testClasses UP-TO-DATE
:test

FAILURE: Build failed with an exception.

* What went wrong:
Could not resolve all dependencies for configuration ':testRuntime'.
> Could not find org.foo.group:my-artifact:0.0.1-final.
  Required by:
      :my-gradle-project:1.0

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
tlin-deploy-tool
BUILD FAILED
mhshams
  • 16,384
  • 17
  • 55
  • 65
  • This happens if the local Maven repo contains the module's POM, but not its artifact. Is this the case? – Peter Niederwieser Jul 04 '13 at 17:47
  • @Peter: No that's not the issue. even if you remove the artifact from local repo, it will raise the same error. – mhshams Jul 05 '13 at 16:07
  • 1
    For reference, if you're facing the situation described by @PeterNiederwieser chances are that you hit [Dependency in Maven local with POM and no JAR file results in dependency resolve failure](https://issues.gradle.org/browse/GRADLE-2709) – Alberto Feb 17 '15 at 14:14

1 Answers1

10

I'm not sure what went wrong, but try to check if maven and gradle are using the same .m2 repository path. It should be clearly displayed with these options:

  • mvn -X
  • gradle --debug

For gradle, this particular message will be shown when a jar can't be found from MavenLocal; the .m2 repository path will be shown:

23:44:08.152 [DEBUG] [org.gradle.api.internal.artifacts.repositories.resolver.ExternalResourceResolver] Resource not reachable for org.foo.group#my-artifact;0.0.1-final: res=MissingResource: /home/wisent/.m2/repository/org/foo/group/my-artifact/0.0.1-final/my-artifact-0.0.1-final.jar

ceilfors
  • 2,617
  • 23
  • 33