forked from mediathekview/MLib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
120 lines (104 loc) · 3.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
apply plugin: 'java'
apply plugin: 'maven'
apply from: "${project.rootDir}/gradle/eclipse.gradle"
import java.nio.file.Files
sourceCompatibility = 1.8
targetCompatibility = 1.8
group = 'de.mediathekview'
version = '3.0.1'
ext {
propsFile = file('src/main/resources/version.properties').absoluteFile
if (!propsFile.exists()) {
Files.createFile(propsFile.toPath())
}
repoZugangFile = file('scripte/deploy/RepoZugang.properties').absoluteFile
if (!repoZugangFile.exists()) {
Files.createFile(repoZugangFile.toPath())
}
}
def loadVersionProperties() {
Properties props = new Properties()
props.load(propsFile.newDataInputStream())
return props
}
def loadRepoZugangProperties() {
Properties props = new Properties()
props.load(repoZugangFile.newDataInputStream())
return props
}
compileJava {
options.encoding = "UTF-8"
options.compilerArgs = ['-Xlint:all']
}
compileTestJava {
options.encoding = "UTF-8"
options.compilerArgs = ['-Xlint:all']
}
repositories {
mavenLocal()
maven {
url "https://repo.mediathekview.de/repository/maven-public/"
}
}
uploadArchives {
repositories.mavenDeployer {
Properties props = loadRepoZugangProperties()
def nexusUser = props.getProperty('repoUser')
def nexusPw = props.getProperty('repoPw')
repository(url: "https://repo.mediathekview.de/repository/maven-releases/") {
authentication(userName: nexusUser, password: nexusPw)
}
snapshotRepository(url: "https://repo.mediathekview.de/repository/maven-snapshots/") {
authentication(userName: nexusUser, password: nexusPw)
}
}
}
build.dependsOn(install)
dependencies {
compile 'org.apache.commons:commons-lang3:3.5'
compile 'com.fasterxml.jackson.core:jackson-core:2.7.0'
compile 'com.jidesoft:jide-oss:3.6.16'
compile 'org.tukaani:xz:1.5'
compile 'com.squareup.okhttp3:okhttp:3.6.0'
compile 'fm.void.jetm:jetm:1.2.3'
}
task updateVersion {
doLast {
Properties props = loadVersionProperties()
def oldVersion = props.getProperty('VERSION')
String buildDate = new Date().format('dd.MM.yyyy HH:mm:ss')
if (!oldVersion.equals(project.version)) {
logger.lifecycle "==mlib======================"
logger.lifecycle "Version: $project.version"
logger.lifecycle "Baudatum: $buildDate"
logger.lifecycle "==mlib======================"
props.setProperty('VERSION', project.version)
props.setProperty('DATE', buildDate)
props.store(propsFile.newWriter(), null)
}
}
}
processResources.dependsOn updateVersion
/**
* <b>You don't have to call this. Travis will do it for you if a new releass (tag) will be build!<b/>
* Call this so: './gradlew build release -PnexusUser=[NEXUS_USER] -PnexusPw=[NEXUS_PASSWORD]'
*/
task release(dependsOn: 'uploadArchives') {
doLast {
println 'Released Version '+version
}
}
/**
* <b>You don't have to call this. Travis will do it for you if you push to develop!<b/>
* Call this so: './gradlew build releaseSnapshot -PnexusUser=[NEXUS_USER] -PnexusPw=[NEXUS_PASSWORD]'
*/
task releaseSnapshot(dependsOn: 'uploadArchives') {
doLast {
println 'Released Snapshot Version '+version
}
}
gradle.taskGraph.whenReady {taskGraph ->
if (taskGraph.hasTask(releaseSnapshot)) {
version = version+'-SNAPSHOT'
}
}