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.
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() } dependencies { compile 'org.springframework:spring-context:4.1.4.RELEASE' } publishing { publications { publishJar(MavenPublication) { artifactId = 'sample' from components.java } } }
From the command line...