-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle
123 lines (101 loc) · 3.24 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
buildscript {
println("Using profile: ${profile}")
File f = new File("${rootProject.projectDir}/gradle-${profile}.properties")
if (f.exists()) {
println("Loading $f.absolutePath")
Properties props = new Properties()
props.load(f.newDataInputStream())
for (String s : props.stringPropertyNames()) {
setProperty(s, props.getProperty(s))
}
}
ext.cfg = project.properties
repositories {
maven { url "${cfg.repository}" }
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
ext {
isRelease = Boolean.valueOf("${release}")
branch = "$git rev-parse --abbrev-ref HEAD".execute().in.text.trim()
branchShort = branch.replaceFirst(".*/", "")
basetag = basetag ?: branch.matches("(release|hotfix)/.*") ? "${branchShort}.BUILD" : null
commit = "$git rev-parse HEAD".execute().in.text.trim()
commitShort = commit.substring(0, 7)
gitDescribe = "$git describe --match=${basetag} --always --dirty".execute().in.text.trim()
snapshotVersion = "${branchShort}-SNAPSHOT"
releaseVersion = "${gitDescribe}"
scmRevision = "${gitDescribe}"
buildNumber = buildNumber ?: System.currentTimeMillis()
buildTimestamp = buildTimestamp ?: new Date().format("${buildTimestampFormat}")
}
project.group = 'io.jrevolt.launcher'
project.version = isRelease ? releaseVersion : snapshotVersion
println "Building ${project.version} (${gitDescribe}, build: ${buildNumber}, timestamp:${buildTimestamp})"
apply plugin: 'java'
apply plugin: 'spring-boot'
apply plugin: 'maven'
apply plugin: 'maven-publish'
[compileJava, compileTestJava]*.options*.compilerArgs = ['-parameters']
buildDir = "${rootProject.projectDir}/.build/${project.name}"
sourceSets {
main { [java, resources]*.srcDir 'src/main/java'; }
test { [java, resources]*.srcDir 'src/test/java'; }
}
configurations {
deploy
}
springBoot {
backupSource = false
}
bootRepackage {
customConfiguration = "deploy"
}
dependencies {
compile("org.springframework.boot:spring-boot-starter:${springBootVersion}")
compile("org.springframework.boot:spring-boot-loader:${springBootVersion}")
deploy("org.springframework.boot:spring-boot-loader:${springBootVersion}")
//compile("org.apache.commons:commons-lang3:3.1")
//compile("commons-io:commons-io:2.4")
testCompile("org.springframework.boot:spring-boot-starter-test:${springBootVersion}")
}
repositories {
maven { url "${cfg.repository}" }
}
jar {
manifest {
attributes(
"Specification-Version": "${project.version}",
"Implementation-Version": "${project.version}",
"SCM-Branch": "${branch}",
"SCM-Revision": "${scmRevision}",
"Build-Number": "${buildNumber}",
"Build-Timestamp": "${buildTimestamp}",
"Build-Timestamp-Format": "${buildTimestampFormat}",
)
}
}
task sourceJar(type: Jar) {
from sourceSets.main.allJava
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
artifact sourceJar {
classifier "sources"
}
}
}
repositories {
maven {
url Boolean.valueOf("${release}") ? "$cfg.releases" : "$cfg.snapshots"
credentials {
username "$cfg.deploymentUserName"
password "$cfg.deploymentPassword"
}
}
}
}