-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
126 lines (106 loc) · 4.42 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
import java.time.ZonedDateTime
import java.time.format.DateTimeFormatter
plugins {
id 'com.adarshr.test-logger'
id "com.diffplug.gradle.spotless"
id 'com.github.ben-manes.versions'
id 'io.spring.dependency-management'
id 'org.springframework.boot'
id 'java'
id 'scala'
}
apply from: "${project.rootDir}/gradle/ext/javacOptions.gradle"
apply from: "${project.rootDir}/gradle/ext/scalacOptions.gradle"
apply from: "${project.rootDir}/utils.gradle"
def appVersion = rootProject.file('VERSION.txt').text.trim()
def timestampFormatter = DateTimeFormatter.ISO_OFFSET_DATE_TIME
group = 'com.hhandoko'
version = appVersion
sourceCompatibility = JavaVersion.VERSION_11
processResources {
// Similar to property expansion, to hardcode application info at compile-time
filesMatching("**/application.properties") {
// Replace ${APP_VERSION} with hardcoded application version string}
filter { line ->
line.contains('${APP_VERSION}') ? line.replace('${APP_VERSION}', appVersion) : line
}
// Replace ${BUILD_TIMESTAMP} with hardcoded current timestamp
filter { line ->
line.contains('${BUILD_TIMESTAMP}') ? line.replace('${BUILD_TIMESTAMP}', ZonedDateTime.now().format(timestampFormatter)) : line
}
// Replace ${COMMIT_HASH} with latest git commit hash
filter { line ->
line.contains('${COMMIT_HASH}') ? line.replace('${COMMIT_HASH}', gitShortHash()) : line
}
}
}
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
repositories {
mavenCentral()
}
dependencies {
annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor'
annotationProcessor 'org.projectlombok:lombok'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
compileOnly 'org.projectlombok:lombok'
compileOnly "org.springframework:spring-context-indexer:${springVersion}"
implementation "org.graalvm.sdk:graal-sdk:${graalSdkVersion}"
implementation "org.scala-lang:scala-library:${scalaVersion}"
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.boot:spring-boot-starter-mustache'
implementation('org.springframework.boot:spring-boot-starter-web') {
exclude group: 'org.springframework.boot', module: 'spring-boot-starter-tomcat'
}
implementation 'org.springframework.boot:spring-boot-starter-undertow'
implementation scala("com.typesafe.scala-logging:scala-logging:${scalaLoggingVersion}")
implementation scala("io.circe:circe-core:${circeVersion}")
implementation scala("io.circe:circe-generic:${circeVersion}")
implementation scala("io.circe:circe-parser:${circeVersion}")
implementation scala("org.typelevel:cats-effect:${catsEffectVersion}")
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation scala("net.ruippeixotog:scala-scraper:${scalaScraperVersion}")
testImplementation scala("org.scalatest:scalatest:${scalatestVersion}")
}
configurations.all {
// Ensure that version conflict in dependencies throws error at compile-time rather that fail at runtime
resolutionStrategy {
failOnVersionConflict()
preferProjectModules()
}
}
bootRun {
// Pass `local` as active profile configuration in `bootRun` for better development experience
def profile = 'local'
environment 'BOOT_ENV', profile
systemProperty 'spring.profiles.active', profile
}
// Code formatter Gradle plugin
// See: https://github.com/diffplug/spotless
// https://github.com/diffplug/spotless/tree/master/plugin-gradle
spotless {
// Use Google Java's styleguide
// See: https://google.github.io/styleguide/javaguide.html
java {
googleJavaFormat()
importOrder 'java', 'javax', 'scala', '', '\\#', 'com.hhandoko', '\\#com.hhandoko'
}
// Use customer scalafmt rule as defined in `.scalafmt.conf`
// scalafmt does not support import orders (yet), so import configuration needs to be setup by each developer
// following the rules above (as per Java rules).
// See: https://scalameta.org/scalafmt/
scala {
scalafmt(gradleScalaFmtVersion).configFile('.scalafmt.conf')
}
}
test {
}
// Pretty-print test output Gradle plugin, supports parallel test execution
// See: https://github.com/radarsh/gradle-test-logger-plugin
testlogger {
theme 'mocha'
slowThreshold 2000 // ms
}