Skip to content

Commit c3d2fb5

Browse files
committed
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
1 parent a9b88d6 commit c3d2fb5

File tree

1 file changed

+74
-0
lines changed

1 file changed

+74
-0
lines changed

spring-boot-docs/src/main/asciidoc/build-tool-plugins.adoc

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,80 @@ you may find that it includes unnecessary dependencies.
568568

569569

570570

571+
[[build-tool-plugins-gradle-publishing-artifacts-to-a-maven-repository]]
572+
=== Publishing artifacts to a Maven repository using Gradle
573+
If you are <<build-tool-plugins-gradle-dependencies-without-versions, declaring
574+
dependencies without versions>> and you want to publish artifacts to a Maven repository
575+
you will need to configure the Maven publication with details of Spring Boot's
576+
dependency management. This can be achieved by configuring it to publish poms that
577+
inherit from `spring-boot-starter-parent` or that import dependency management from
578+
`spring-boot-dependencies`. The exact details of this configuration depend on how you're
579+
using Gradle and how you're trying to publish the artifacts.
580+
581+
582+
583+
[[build-tool-plugins-gradle-publishing-artifacts-to-a-maven-repository-inherit]]
584+
==== Configuring Gradle to produce a pom that inherits dependency management
585+
The following is an example of configuring Gradle to generate a pom that inherits
586+
from `spring-boot-starter-parent`. Please refer to the
587+
http://www.gradle.org/docs/current/userguide/userguide.html[Gradle User Guide] for
588+
further information.
589+
590+
[source,groovy,indent=0,subs="verbatim,attributes"]
591+
----
592+
uploadArchives {
593+
repositories {
594+
mavenDeployer {
595+
pom {
596+
project {
597+
parent {
598+
groupId "org.springframework.boot"
599+
artifactId "spring-boot-starter-parent"
600+
version "{spring-boot-version}"
601+
}
602+
}
603+
}
604+
}
605+
}
606+
}
607+
----
608+
609+
610+
611+
[[build-tool-plugins-gradle-publishing-artifacts-to-a-maven-repository-import]]
612+
==== Configuring Gradle to produce a pom that imports dependency management
613+
The following is an example of configuring Gradle to generate a pom that imports
614+
the dependency management provided by `spring-boot-dependencies`. Please refer to the
615+
http://www.gradle.org/docs/current/userguide/userguide.html[Gradle User Guide] for
616+
further information.
617+
618+
[source,groovy,indent=0,subs="verbatim,attributes"]
619+
----
620+
uploadArchives {
621+
repositories {
622+
mavenDeployer {
623+
pom {
624+
project {
625+
dependencyManagement {
626+
dependencies {
627+
dependency {
628+
groupId "org.springframework.boot"
629+
artifactId "spring-boot-dependencies"
630+
version "{spring-boot-version}"
631+
type "pom"
632+
scope "import"
633+
}
634+
}
635+
}
636+
}
637+
}
638+
}
639+
}
640+
}
641+
----
642+
643+
644+
571645
[[build-tool-plugins-other-build-systems]]
572646
== Supporting other build systems
573647
If you want to use a build tool other than Maven or Gradle, you will likely need to develop

0 commit comments

Comments
 (0)