Skip to content

Commit d849e0e

Browse files
committed
Initial commit
0 parents  commit d849e0e

18 files changed

+13687
-0
lines changed

.gitignore

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
.gradle*
2+
build/
3+
target/
4+
5+
### STS ###
6+
.apt_generated
7+
.classpath
8+
.factorypath
9+
.project
10+
.settings
11+
.springBeans
12+
.sts4-cache
13+
14+
### IntelliJ IDEA ###
15+
.idea
16+
*.iws
17+
*.iml
18+
*.ipr
19+
/out/
20+
21+
### NetBeans ###
22+
/nbproject/private/
23+
/nbbuild/
24+
/dist/
25+
/nbdist/
26+
/.nb-gradle/
27+
28+
node_modules/
29+
.vuepress/dist/

.travis.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
git:
2+
depth: false
3+
quiet: true
4+
language: java
5+
jdk: openjdk8
6+
env:
7+
global:
8+
- secure: f/ddrLmA5Vvp0WGRDuaCGDbhlCSMMZkQvoTfRs7CWJb2eI3Op6+lwUevV2e7hCorhtFW8XAm+OGF1GcD8wLgJuj8sYtgTzTjSfz9O6ToaV6Cq2E8zb046ScS0QWIc5TTHYYlCmR3F+iPKctWpN6QxUg+ichB0Z5Lcts/ffHYctoumG/7g8ZNjKQHswu2BEXRRylU6kYWX3OLe2H5reQB+UEGx2ViBWbuty7+rnwuWmkryZ3wzB1s0uMQsrQoxLNrTqwXVp/faCSd4hwoqaJdHyoJNt531pGVlL0Xq85x5XSOIpfbWYJuKsRY+2RFTdHQUoIkmebWw5epQsrR4PGdbfJ5Vreu0CRbIh4XRR4sVx6zuqaROO0WL0k4jTXE7pU/6iBuJzNCvnLBfCzhE3dArsLxRkUlsRx0WPuSiUhKHaXjWSdUS5D60iERHTkX6mY3cyeRxQP5eWb59Sya64xQrbU3IV29Xlx5DCIdYb20h4NmOBxV045t8hBl/Hw24Vv+6AilVOnRbIO8TqAXJVIDlGFCfUgSiE6AL3rOQ+Ais7OnT06CHp2D9FXiqSCa7iyP43wr/5d8m2973r3JWAJYC2QQgoz3GNXPLBltm676nQR0tBJKaR6uuMsPJ9IuYIF6nPIGCWdrkk2H7rkpO7y0GWBPthUMGTUoXUkuxATX1MM=
9+
addons:
10+
apt:
11+
packages:
12+
- sudo
13+
- lsof
14+
- curl
15+
- bash
16+
- python-py
17+
install: true
18+
before_install:
19+
- sudo pip install --upgrade httpie >/dev/null
20+
- source <(curl -s https://raw.githubusercontent.com/daggerok/bash-functions/master/main.bash)
21+
- stop_any 80
22+
script:
23+
- ./gradlew
24+
- bash ./build/libs/*.war &
25+
- wait_for 8080
26+
- http :8080/actuator/
27+
- http :8080/actuator/health
28+
- stop_any 80
29+
cache:
30+
npm: true
31+
packages: true
32+
directories:
33+
- ./node_modules
34+
- ~/.gradle
35+
notifications:
36+
email: false
37+
before_deploy:
38+
- ./gradlew npm_run_build
39+
deploy:
40+
provider: pages
41+
skip-cleanup: true
42+
local_dir: ./.vuepress/dist
43+
github-token: $GITHUB_TOKEN # a token generated on github allowing travis to push code on you repository
44+
keep-history: true
45+
on:
46+
branch: master

.vuepress/config.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
const base = !process.env.BASE_HREF ? '/' : process.env.BASE_HREF;
2+
3+
module.exports = {
4+
head: [
5+
['link', { rel: 'icon', href: '/favicon.ico' }]
6+
],
7+
base,
8+
themeConfig: {
9+
repo: 'daggerok/spring-boot-gradle-kotlin-dsl-example',
10+
lastUpdated: 'Last Updated', // string | boolean
11+
'/': {
12+
sidebar: 'auto'
13+
},
14+
sidebarDepth: 2,
15+
navbar: true,
16+
}
17+
};

README.md

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
# [spring-boot + gradle-kotlin-dsl](https://github.com/daggerok/spring-boot-gradle-kotlin-dsl-example) [![Build Status](https://travis-ci.org/daggerok/spring-boot-gradle-kotlin-dsl-example.svg?branch=master)](https://travis-ci.org/daggerok/spring-boot-gradle-kotlin-dsl-example)
2+
3+
## Spring Boot
4+
5+
### plugins definition
6+
7+
_build.gradle.kts_
8+
9+
```kotlin
10+
plugins {
11+
id("org.jetbrains.kotlin.jvm").version("1.3.21")
12+
id("org.jetbrains.kotlin.plugin.spring").version("1.3.21")
13+
id("org.springframework.boot").version("2.2.0.BUILD-SNAPSHOT")
14+
}
15+
16+
apply(plugin = "war")
17+
apply(plugin = "io.spring.dependency-management")
18+
19+
repositories {
20+
mavenCentral()
21+
maven(url = "https://repo.spring.io/snapshot")
22+
maven(url = "https://repo.spring.io/milestone")
23+
}
24+
```
25+
26+
_settings.gradle.kts_
27+
28+
```kotlin
29+
pluginManagement {
30+
repositories {
31+
gradlePluginPortal()
32+
maven(url = "https://repo.spring.io/snapshot")
33+
maven(url = "https://repo.spring.io/milestone")
34+
gradlePluginPortal()
35+
}
36+
resolutionStrategy {
37+
eachPlugin {
38+
if (requested.id.id == "org.springframework.boot") {
39+
useModule("org.springframework.boot:spring-boot-gradle-plugin:${requested.version}")
40+
}
41+
}
42+
}
43+
}
44+
```
45+
46+
### kotlin
47+
48+
_build.gradle.kts_
49+
50+
```kotlin
51+
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
52+
kotlinOptions {
53+
freeCompilerArgs += "-Xjsr305=strict"
54+
jvmTarget = JavaVersion.VERSION_1_8.toString()
55+
}
56+
}
57+
```
58+
59+
### override parent versions
60+
61+
_build.gradle.kts_
62+
63+
```kotlin
64+
val kotlinVersion = "1.3.21"
65+
val junitJupiterVersion = "5.4.0"
66+
67+
extra["kotlin.version"] = kotlinVersion
68+
extra["junit-jupiter.version"] = junitJupiterVersion
69+
```
70+
71+
---
72+
**NOTE**
73+
74+
we need this because we wanna use spring 2.2.0-BUILD-SNAPSHOT version
75+
76+
---
77+
78+
## war
79+
80+
_build.gradle.kts_
81+
82+
```kotlin
83+
plugins {
84+
id("war")
85+
}
86+
87+
tasks.withType<BootWar>().configureEach {
88+
launchScript()
89+
}
90+
```
91+
92+
_ServletInitializer.kt_
93+
94+
```kotlin
95+
class ServletInitializer : SpringBootServletInitializer() {
96+
override fun configure(application: SpringApplicationBuilder): SpringApplicationBuilder {
97+
return application.sources(SptingBootGradleKotlinDslExampleApplication::class.java)
98+
}
99+
}
100+
```
101+
102+
## NodeJS
103+
104+
_build.gradle.kts_
105+
106+
```kotlin
107+
plugins {
108+
id("com.moowork.node") version "1.2.0"
109+
}
110+
111+
node {
112+
download = true
113+
version = "10.9.0"
114+
npmVersion = "6.8.0"
115+
}
116+
117+
tasks.create("start")
118+
tasks["start"].dependsOn("npm_start")
119+
tasks["build"].dependsOn("npm_run_build")
120+
```
121+
122+
## links and resources
123+
124+
- [from groovy to kotlin DSL gradle migration guide (nice but little bit old)](https://github.com/jnizet/gradle-kotlin-dsl-migration-guide)

build.gradle.kts

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
2+
import org.gradle.api.tasks.testing.logging.TestLogEvent.*
3+
import org.springframework.boot.gradle.tasks.bundling.BootJar
4+
import org.springframework.boot.gradle.tasks.bundling.BootWar
5+
6+
plugins {
7+
id("war")
8+
id("idea")
9+
id("com.moowork.node") version "1.2.0"
10+
id("org.jetbrains.kotlin.jvm") version "1.3.21"
11+
id("org.jetbrains.kotlin.plugin.spring") version "1.3.21"
12+
id("org.springframework.boot") version "2.2.0.BUILD-SNAPSHOT"
13+
}
14+
15+
group = "com.github.daggerok"
16+
version = "1.0.0-SNAPSHOT"
17+
18+
val gradleVersion = "5.2.1"
19+
val kotlinVersion = "1.3.21"
20+
val junitJupiterVersion = "5.4.0"
21+
22+
extra["kotlin.version"] = kotlinVersion
23+
extra["junit-jupiter.version"] = junitJupiterVersion
24+
25+
apply(plugin = "io.spring.dependency-management")
26+
27+
tasks.withType<Wrapper>().configureEach {
28+
gradleVersion = gradleVersion
29+
distributionType = Wrapper.DistributionType.BIN
30+
}
31+
32+
java {
33+
sourceCompatibility = JavaVersion.VERSION_1_8
34+
}
35+
36+
sourceSets {
37+
main {
38+
java.srcDir("src/main/kotlin")
39+
}
40+
test {
41+
java.srcDir("src/test/kotlin")
42+
}
43+
}
44+
45+
tasks.withType<KotlinCompile>().configureEach {
46+
kotlinOptions {
47+
freeCompilerArgs += "-Xjsr305=strict"
48+
jvmTarget = JavaVersion.VERSION_1_8.toString()
49+
}
50+
}
51+
52+
repositories {
53+
mavenCentral()
54+
maven(url = "https://repo.spring.io/snapshot")
55+
maven(url = "https://repo.spring.io/milestone")
56+
}
57+
58+
dependencies {
59+
implementation("org.springframework.boot:spring-boot-starter-hateoas")
60+
implementation("org.springframework.boot:spring-boot-starter-webflux")
61+
implementation("org.springframework.boot:spring-boot-starter-actuator")
62+
//implementation("org.springframework.boot:spring-boot-starter-web") // tomcat
63+
implementation("org.springframework.boot:spring-boot-starter")
64+
implementation("org.jetbrains.kotlin:kotlin-reflect")
65+
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
66+
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
67+
68+
annotationProcessor("org.projectlombok:lombok")
69+
testAnnotationProcessor("org.projectlombok:lombok")
70+
annotationProcessor("org.springframework.boot:spring-boot-configuration-processor")
71+
testAnnotationProcessor("org.springframework.boot:spring-boot-configuration-processor")
72+
73+
runtimeOnly("org.springframework.boot:spring-boot-devtools")
74+
75+
testImplementation("org.springframework.boot:spring-boot-starter-test")
76+
testImplementation("io.projectreactor:reactor-test")
77+
78+
testImplementation("junit:junit")
79+
testImplementation(platform("org.junit:junit-bom:$junitJupiterVersion"))
80+
testImplementation("org.junit.jupiter:junit-jupiter-api")
81+
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine")
82+
testRuntimeOnly("org.junit.vintage:junit-vintage-engine")
83+
testRuntime("org.junit.platform:junit-platform-launcher")
84+
}
85+
86+
tasks.withType<BootJar>().configureEach {
87+
launchScript()
88+
}
89+
90+
tasks.withType<BootWar>().configureEach {
91+
launchScript()
92+
}
93+
94+
tasks.withType<Test> {
95+
useJUnitPlatform()
96+
testLogging {
97+
showExceptions = true
98+
showStandardStreams = true
99+
events(PASSED, SKIPPED, FAILED)
100+
}
101+
}
102+
103+
defaultTasks("build")
104+
105+
node {
106+
download = true
107+
version = "10.9.0"
108+
npmVersion = "6.8.0"
109+
}
110+
111+
tasks.create("start")
112+
tasks["start"].dependsOn("npm_start")
113+
tasks["build"].dependsOn("npm_run_build")

favicon.ico

1.12 KB
Binary file not shown.

gradle/wrapper/gradle-wrapper.jar

54.9 KB
Binary file not shown.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-bin.zip
4+
zipStoreBase=GRADLE_USER_HOME
5+
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)