Why can't Gradle see this Maven co-ordinate in the local m2 repository?

458 views Asked by At

I have a few locally built JAR files from an internal library. Tonight's task is to convert an existing (working) Maven project to use a Gradle build. I can successfully link with Apache-commons3 in the same repository and as far as I can see the Maven coordinates are formed in the same way.

Starting small, I attempted to compile a small main program with the locally built "Util.jar":

  dependencies{

    //          -- local lib --
compile group: 'lib.java8', name: 'util',  version: '00.08.007'

    //          -- apache commons --
compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.3.2'
  }

In the repository folder area, the file versions between the local library JAR and Apache appear congruent to me. First the library ...

 Directory of r:\.repo\maven\.m2\repository\local\lib\java8\util\00.08.007

    07-Jun-2015  21:20            20,585 util-00.08.007.jar
    27-Apr-2015  21:03             1,829 util-00.08.007.pom

And the Apache-commons entry in the same repository:

 Directory of r:\.repo\maven\.m2\repository\local\org\apache\commons\commons-lang3\3.3.2

 16-Dec-2014  21:48           412,739 commons-lang3-3.3.2.jar
 16-Dec-2014  21:48                40 commons-lang3-3.3.2.jar.sha1
 16-Dec-2014  21:48            20,377 commons-lang3-3.3.2.pom
 16-Dec-2014  21:48                40 commons-lang3-3.3.2.pom.sha1
 09-May-2015  23:12               261 _maven.repositories
 17-Sep-2014  19:31               199 _remote.repositories

To my eye the file name-versionNumber-s of both examples are structured alike. However the

gradle assemble

Goal reports errors on the locally compiled library JAR.

gradle assemble ...

  :compileJava

  FAILURE: Build failed with an exception.

  * What went wrong:
  Could not resolve all dependencies for configuration ':compile'.
  > Could not find lib.tmacs.java8:util:00.08.007.
    Searched in the following locations:
        https://repo1.maven.org/maven2/lib/java8/util/00.08.007/util-00.08.007.pom
        https://repo1.maven.org/maven2/lib/java8/util/00.08.007/util-00.08.007.jar
    Required by:
        :dataexample:00.00.001-SNAPSHOT

  BUILD FAILED

I am stumped. In each case the repository file matched coordinated in the same way.

QUESTION:

  1. What does Gradle look for that (working) Maven projects don't?
  2. Can I access the existing Util.jar with Gradle and How?
  3. How do I fix the Maven POM that builds the Util.jar library so that both new Gradle projects and existing Maven POM projects can build with the same JAR??

Finally, am I asking the right questions, or am I completely off track?

1

There are 1 answers

0
Michael Schaefers On

Gradle has already given you the answer:

Searched in the following locations:

https://repo1.maven.org/maven2/lib/java8/util/00.08.007/util-00.08.007.pom

https://repo1.maven.org/maven2/lib/java8/util/00.08.007/util-00.08.007.jar

You need to instruct gradle where to look for your artifacts. See this question or this one. The keyword of interest there is mavenLocal().

All information about defining repositories can be found in the docs