Subby
Subby

Reputation: 5480

MavenLocal unable to find repo using Gradle

I performed mvn clean install on a Java project which I wish to use as part of my Android project.

If I was using maven, I would do:

<dependency>
    <groupId>com.abc.project</groupId>
    <artifactId>my-work-sdk</artifactId>
    <version>2.0.0-SNAPSHOT</version>
</dependency>

But since I'm using gradle, I tried doing:

compile group: 'com.abc.project', name: 'my-work-sdk', version: '2.0.0-SNAPSHOT'

But I get:

Error: Failed to resolve: com.abc.project:my-work-sdk:2.0.0-SNAPSHOT

I have added mavenLocal() as a repository to the root-level build.gradle file:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.1.2'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

Upvotes: 3

Views: 4437

Answers (2)

Ben Green
Ben Green

Reputation: 4121

These are the steps I think you need to take from your comments:

  1. mvn install your my-work-sdk project.
  2. In your gradle build.gradle project, add the mavenLocal repository:

    repositories {
        mavenLocal()
    }
    

If this is a multi project build, and you want the mavenLocal() repository to be accessible by all subprojects, as well as the root project, it should go under allProjects like so:

allProjects {
    repositories {
        mavenLocal()
    }
}

Alternatively, if you only want the mavenLocal repo to be accessible from the subprojects, you can replace allProjects with subprojects. This should be all you need to do.

Upvotes: 2

Crazyjavahacking
Crazyjavahacking

Reputation: 9687

You have to explicitly set Maven local as Gradle repository:

repositories {
    mavenLocal()
}

If it is used in buildscript:

buildscript {
    repositories {
        mavenLocal()
    }
}

Upvotes: 2

Related Questions