From c3d2fb5e5cc21b024ba7f1fbf2bb916f5b239e96 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Mon, 10 Nov 2014 12:33:25 +0000 Subject: [PATCH] Document details of configuring Gradle to produce valid poms If a Gradle build is using the Spring Boot Gradle plugin's support for declaring dependencies without versions then they will be unable to publish Maven artifacts from the build as the Gradle-generated pom will fail to validate. This is because Gradle doesn't apply the Boot-provided dependency versions to the dependencies in the generated pom. This can be addressed by configuring Gradle to generate a pom that either imports spring-boot-dependencies into its dependency management or that uses spring-boot-starter-parent as its parent. This commit updates the documentation to document the need for this configuration and to provide examples of how to do so. Closes gh-1806 --- .../src/main/asciidoc/build-tool-plugins.adoc | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/spring-boot-docs/src/main/asciidoc/build-tool-plugins.adoc b/spring-boot-docs/src/main/asciidoc/build-tool-plugins.adoc index 2edeb0a66b..0a1cea26e9 100644 --- a/spring-boot-docs/src/main/asciidoc/build-tool-plugins.adoc +++ b/spring-boot-docs/src/main/asciidoc/build-tool-plugins.adoc @@ -568,6 +568,80 @@ you may find that it includes unnecessary dependencies. +[[build-tool-plugins-gradle-publishing-artifacts-to-a-maven-repository]] +=== Publishing artifacts to a Maven repository using Gradle +If you are <> and you want to publish artifacts to a Maven repository +you will need to configure the Maven publication with details of Spring Boot's +dependency management. This can be achieved by configuring it to publish poms that +inherit from `spring-boot-starter-parent` or that import dependency management from +`spring-boot-dependencies`. The exact details of this configuration depend on how you're +using Gradle and how you're trying to publish the artifacts. + + + +[[build-tool-plugins-gradle-publishing-artifacts-to-a-maven-repository-inherit]] +==== Configuring Gradle to produce a pom that inherits dependency management +The following is an example of configuring Gradle to generate a pom that inherits +from `spring-boot-starter-parent`. Please refer to the +http://www.gradle.org/docs/current/userguide/userguide.html[Gradle User Guide] for +further information. + +[source,groovy,indent=0,subs="verbatim,attributes"] +---- + uploadArchives { + repositories { + mavenDeployer { + pom { + project { + parent { + groupId "org.springframework.boot" + artifactId "spring-boot-starter-parent" + version "{spring-boot-version}" + } + } + } + } + } + } +---- + + + +[[build-tool-plugins-gradle-publishing-artifacts-to-a-maven-repository-import]] +==== Configuring Gradle to produce a pom that imports dependency management +The following is an example of configuring Gradle to generate a pom that imports +the dependency management provided by `spring-boot-dependencies`. Please refer to the +http://www.gradle.org/docs/current/userguide/userguide.html[Gradle User Guide] for +further information. + +[source,groovy,indent=0,subs="verbatim,attributes"] +---- + uploadArchives { + repositories { + mavenDeployer { + pom { + project { + dependencyManagement { + dependencies { + dependency { + groupId "org.springframework.boot" + artifactId "spring-boot-dependencies" + version "{spring-boot-version}" + type "pom" + scope "import" + } + } + } + } + } + } + } + } +---- + + + [[build-tool-plugins-other-build-systems]] == Supporting other build systems If you want to use a build tool other than Maven or Gradle, you will likely need to develop