-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.gradle
More file actions
145 lines (112 loc) · 4.06 KB
/
Copy pathbuild.gradle
File metadata and controls
145 lines (112 loc) · 4.06 KB
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
buildscript {
repositories {
jcenter()
}
dependencies {
// The gradle-docker plugin we want to use isn't yet in gradle plugin portal, se we
// pull it from jcenter
classpath 'se.transmode.gradle:gradle-docker:1.2'
}
}
plugins {
// Use the Spring Boot Gradle plugin, which automatically applies the dependency management plugin
// and configures it to import the spring-boot-starter-parent bom.
id 'org.springframework.boot' version '2.0.4.RELEASE'
// Versioning plugin
id 'pl.allegro.tech.build.axion-release' version '1.8.1'
}
// The Java plugin allows us to compile and package our code into a jar file
apply plugin: 'java'
apply plugin: 'io.spring.dependency-management'
// Support for packaging our application as a Docker image
apply plugin: 'docker'
// Define the namespace for our build artifacts (replace with your own group)
group 'atc'
// Explicitly declare that we're using JDK 1.10
sourceCompatibility = 1.10
// Use Maven Central to resolve all 3rd party dependencies
repositories {
mavenCentral()
}
// Using the dependency management plugin, import the dependencies for
// Spring Cloud release train 'Finchley.SR1'
dependencyManagement {
imports {
mavenBom 'org.springframework.cloud:spring-cloud-dependencies:Finchley.SR1'
}
}
dependencies {
// Enable Spring MVC
compile group: 'org.springframework.boot', name: 'spring-boot-starter-web'
// Production metrics for Spring Boot
compile group: 'org.springframework.boot', name: 'spring-boot-starter-actuator'
// Service registration via Eureka
compile group: 'org.springframework.cloud', name: 'spring-cloud-starter-netflix-eureka-server'
// Feign declarative REST client
compile group: 'org.springframework.cloud', name: 'spring-cloud-starter-openfeign'
// Enable distributed tracing with Sleuth
compile group: 'org.springframework.cloud', name: 'spring-cloud-starter-zipkin'
// Enable JSON logging
runtime(group: 'net.logstash.logback', name: 'logstash-logback-encoder', version: '4.11') {
exclude group: 'ch.qos.logback', module: 'logback-core'
}
testCompile group: 'junit', name: 'junit', version: '4.12'
}
// Versioning with the Axion release plugin
scmVersion {
// Treat uncommitted changes as trigger for version increment
ignoreUncommittedChanges = false
// All versions will start with "v"
tag {
prefix = 'v'
versionSeparator = ''
}
// Our versioning scheme is major.minor.rcX. If we're on a branch named "release/*", increment the release
// candidate number, otherwise increment the minor version number.
versionIncrementer 'incrementMinorIfNotOnRelease', [releaseBranchPattern: 'release.*']
branchVersionIncrementer = [
'master' : 'incrementMinor',
'feature' : 'incrementMinor',
'release/.*': 'incrementPrerelease'
]
// Decorators
versionCreator 'simple'
branchVersionCreator = [
'feature/.*': 'versionWithBranch'
]
checks {
// Allow for releasing a new version if there are uncommitted changes
uncommittedChanges = false
}
}
project.version = scmVersion.version
// Add the version number to the manifest
jar {
manifest {
attributes( "Implementation-Title": project.name,
"Implementation-Version": project.version.toString() )
}
}
// Configure the spring boot jar
springBoot {
buildInfo()
}
// Build the docker container for this application
task buildDocker( type: Docker, dependsOn: build ) {
push = false
applicationName = rootProject.name
dockerfile = file( 'Dockerfile' )
doFirst {
// Rename the app jar to "app.jar" so that the Dockerfile does not require renames
copy {
from "${project.buildDir}/libs"
into stageDir
include "${rootProject.name}-${version}.jar"
rename( "${rootProject.name}-${version}.jar", "app.jar" )
}
}
}
// Configure the Gradle wrapper
task wrapper( type: Wrapper ) {
gradleVersion = '4.9'
}