Reputation: 1380
On a maven project I have the tag:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.0.BUILD-SNAPSHOT</version>
</parent>
What is Gradle's syntax for that?
This is my build.gradle currently. Im thinking this would need to be added on the build script, maybe replacing what I currently have. If possible, please explain why I would need to add it. I am trying to translate a pom.xml to gradle.
buildscript {
ext {
springBootVersion = '1.5.9.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.5.9.RELEASE")
}
}
plugins {
id 'org.springframework.boot' version '1.5.9.RELEASE'
id 'java'
}
repositories {
mavenCentral()
}
/*Runtime dependencies*/
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
compile("io.springfox:springfox-swagger2:2.6.1")
compile("io.springfox:springfox-swagger-ui:2.6.1")
compile('org.springframework.boot:spring-boot-starter')
compile("org.springframework.boot:spring-boot-starter-web")
compile("org.springframework.boot:spring-boot-starter-data-rest")
}
Upvotes: 14
Views: 16463
Reputation: 101
What is the equivalent of following Gradle
parent syntax, in Maven
apply plugin : "io.spring.dependency-management"
dependencyManagement {
imports {
mavenBom "org.springframework.boot:spring-boot-starter-parent:${springBootVersion}"
}
}
Upvotes: 8
Reputation: 910
In Gradle you only have a parent->child relationship in a multi-module project. You do not have a child->parent definition as you have in Maven.
So you usually have a parent folder where you have a settings.gradle that contains the references to its children.
Like so (parent settings.gradle):
include 'sub-module-1'
include 'sub-module-2
Then you have two sub-folder sub-module-1 and sub-module-2 which contains their own build.gradle files.
But, coming back to your case, you don't need to have any of that when you are just using the spring-boot plugin org.springframework.boot plugin will configure all the necessary dependencies so you only need to add the optional dependencies you want.
Upvotes: 10