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 { jcenter() ...

Get Gradle Dependency Management now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.