Book Image

Gradle Dependency Management

By : Hubert Klein Ikkink
Book Image

Gradle Dependency Management

By: Hubert Klein Ikkink

Overview of this book

Table of Contents (14 chapters)
Gradle Dependency Management
About the Author
About the Reviewers

Defining repositories

We must configure a Maven repository to publish our configured publication. We can choose a local directory or a repository manager, such as Artifactory or Nexus. Gradle also adds support installing the publication to our local Maven repository.

Publishing to the local Maven repository

Gradle already adds our local Maven repository as a destination for our publications. For each named publication, there is a publish<publicationName>ToMavenLocal task. Gradle also creates the publishToMavenLocal task, which will publish all publications to the local Maven repository.

We have the following example build file:

apply plugin: 'maven-publish'
apply plugin: 'java'

version = '2.1.DEVELOPMENT'
group = 'book.gradle'

repositories {

dependencies {
  compile 'org.springframework:spring-context:4.1.4.RELEASE'

publishing {

  publications {
    publishJar(MavenPublication) {
      artifactId = 'sample'



From the command line...