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
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Defining repositories


We must configure an Ivy repository to publish our configured publication. We can choose a local directory or a repository manager, such as Artifactory or Nexus.

Publishing to a local directory

If we have a directory where we want to publish our publications, we must add it to the publishing configuration block. Inside the block, we add a repositories configuration block containing one or more named repositories. For the combination of each publication and repository, Gradle creates a task with the publish<publicationName>To<repositoryName>Repository name pattern.

We define a simple directory repository in the next example build file with the name localRepo:

apply plugin: 'ivy-publish'
apply plugin: 'java'

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

repositories {
  jcenter()
}

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

publishing {

  publications {
    publishJar(IvyPublication) {
      module = 'sample'

     ...