Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Example build.gradle file for Spring Boot with Kotlin
group 'com.example.profile'
version '1.0-SNAPSHOT'
buildscript {
ext.kotlin_version = '1.0.0-beta-3595'
ext.spring_boot_version = '1.3.1.RELEASE'
ext.spring_dmp_version = '0.5.2.RELEASE'
ext.spring_cloud_netflix_version = '1.0.4.RELEASE'
ext.rx_kotlin_version = '0.30.1'
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.springframework.boot:spring-boot-gradle-plugin:$spring_boot_version"
classpath "io.spring.gradle:dependency-management-plugin:$spring_dmp_version"
}
}
apply plugin: 'java'
apply plugin: 'kotlin'
apply plugin: 'spring-boot'
apply plugin: 'io.spring.dependency-management'
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-netflix:$spring_cloud_netflix_version"
}
}
jar {
baseName = 'profile-service'
version = '0.1.0'
}
repositories {
jcenter()
mavenCentral()
}
sourceSets {
main {
kotlin {
srcDir "src/main/kotlin"
}
}
test {
kotlin {
srcDir "test/main/kotlin"
}
}
main.java.srcDirs += 'src/main/kotlin'
}
springBoot {
// Tell Spring Boot where the 'main' method resides
mainClass = 'com.example.profileservice.ProfileServiceApplicationKt'
}
dependencies {
// Kotlin language
compile("org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version")
// Spring Boot modules
compile("org.springframework.boot:spring-boot-starter-web")
compile("org.springframework.boot:spring-boot-starter-data-jpa")
compile("org.springframework.boot:spring-boot-starter-actuator")
// Spring Cloud modules
compile("org.springframework.cloud:spring-cloud-starter-eureka")
compile("org.springframework.cloud:spring-cloud-starter-feign")
compile("org.springframework.cloud:spring-cloud-starter-hystrix")
// Use h2 as in-memory database
compile("com.h2database:h2:1.4.184")
// Use Kotlin specific version of reactive extensions
compile("io.reactivex:rxkotlin:$rx_kotlin_version")
// Tools that allow us to easily test our Spring Boot app
testCompile("org.springframework.boot:spring-boot-starter-test")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.