Using Local Maven Repository with Gradle

Gradle is capable of using Maven to find artifacts, including your own local maven repository.

To get this working I had to put the following stuff in my build.gradle.

usePlugin 'maven'  // Maven plugin to install artifact in local Maven repo.

def localMavenRepo = new File('c:/work/.m2/repository').toURL().toString()

repositories {
    // Use local Maven repo location. We don't need this if we only want to install
    // an artifact, but we do need it if we want to use dependencies from the local
    // repository.
    mavenRepo urls: localMavenRepo
    
}

dependencies {
    compile 'com.itextpdf:itextpdf:5.0.0'
    groovy 'org.codehaus.groovy:groovy:1.6.7'  // group:name:version is a nice shortcut notation for dependencies.
    testCompile 'junit:junit:4.7'
}
blog comments powered by Disqus