-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle
234 lines (202 loc) · 6.44 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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
import org.apache.tools.ant.filters.ReplaceTokens
import java.nio.file.Files
apply plugin: 'java'
apply plugin: 'distribution'
apply plugin: 'maven'
apply from: "${project.rootDir}/gradle/eclipse.gradle"
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "gradle.plugin.com.github.jk1:gradle-license-report:0.3.12"
}
}
apply plugin: "com.github.jk1.dependency-license-report"
sourceCompatibility = 1.8
targetCompatibility = 1.8
group = 'de.mediathekview'
version = '1.0.0'
def jarName = 'MServerGUI.jar'
def mainClass = 'de.mediathekview.mserver.ui.gui.MServerGUI'
compileJava {
options.encoding = "UTF-8"
options.compilerArgs = ['-Xlint:all']
}
compileTestJava {
options.encoding = "UTF-8"
options.compilerArgs = ['-Xlint:all']
}
task copyRuntimeLibs(type: Copy) {
into "libs"
from configurations.testRuntime - configurations.runtime
}
task copyTestResources(type: Copy) {
from "${projectDir}/src/test/resources"
into "${buildDir}/classes/test"
}
processTestResources.dependsOn copyTestResources
repositories {
mavenLocal()
maven {
url "https://repo.mediathekview.de/repository/maven-public/"
}
}
dependencies {
compile 'de.mediathekview:MServer:4.0.0-SNAPSHOT'
compile 'org.controlsfx:controlsfx:8.40.13'
compile 'org.kordamp.ikonli:ikonli-core:1.9.0'
compile 'com.google.guava:guava:23.0'
testCompile "org.testfx:testfx-core:4.0.+"
testCompile "org.testfx:testfx-junit:4.0.+"
testCompile "junit:junit:4.12"
}
configurations.compile {
resolutionStrategy.dependencySubstitution {
def substituteIfExists = { String moduleName, String projectName ->
if(findProject(projectName)) {
assert !(project.hasProperty('org.gradle.configureondemand') && Boolean.valueOf(project.getProperty('org.gradle.configureondemand'))) : "org.gradle.configureondemand = true will cause problems when substituting a project"
logger.lifecycle "$project: Substituting module '$moduleName' with project $projectName"
substitute module(moduleName) with project(projectName)
}
}
substituteIfExists('de.mediathekview:MLib', ':MLib')
}
}
ext {
repoZugangFile = file('scripte/deploy/RepoZugang.properties').absoluteFile
if (!repoZugangFile.exists()) {
Files.createFile(repoZugangFile.toPath())
}
propsFile = file('src/main/resources/version.properties').absoluteFile
if (!propsFile.exists()) {
Files.createFile(propsFile.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
}
task updateVersion {
doLast {
Properties props = loadVersionProperties()
def oldVersion = props.getProperty('version')
if (!oldVersion.equals(project.version)) {
logger.lifecycle "==MServer GUI======================"
logger.lifecycle "Version: $project.version"
logger.lifecycle "==mserver======================"
props.setProperty('version', project.version)
props.store(propsFile.newWriter(), null)
}
}
}
processResources.dependsOn updateVersion
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)
licenseReport {
outputDir = "build/Copyright/"
excludes = [':MServerGUI', 'MediathekView:MLib', 'MediathekView:MServer']
configurations = ['compile']
}
processResources.dependsOn generateLicenseReport
[distZip, distTar]*.shouldRunAfter compileJava, jar
distTar.compression = Compression.GZIP
distTar.extension = 'tar.gz'
jar {
manifest {
attributes(
'Main-Class': mainClass,
'Class-Path': configurations.runtime.files.collect { "lib/$it.name" }.join(' ')
)
}
archiveName = jarName
}
distributions {
main {
baseName = 'MServerGUI'
contents {
into('lib') {
from configurations.compile
}
from('scripte/runScripts') {
filesMatching('**') {
filter(ReplaceTokens, tokens: [JARNAME: jarName])
}
}
from('build/libs') {
include '*.jar'
}
from('build') {
include 'Copyright/*'
}
}
}
}
/**
* This is how you pass arguments: "./gradlew run -Pargs=arg1,arg2,arg3
*/
task run(type: JavaExec, dependsOn: classes) {
main = mainClass
classpath = sourceSets.main.runtimeClasspath
if (project.hasProperty('args')) {
args(project.args.split(','))
}
}
/**
* HOWTO debug:
* 1. run "gradle debug"
* 2. Call your IDE to connect to a remote java application on port 5005.
*
* This is how you pass arguments: "./gradlew debug -Pargs=arg1,arg2,arg3
*/
task debug(type: JavaExec, dependsOn: classes) {
main = mainClass
classpath = sourceSets.main.runtimeClasspath
debug true
if (project.hasProperty('args')) {
args(project.args.split(','))
}
}
/**
* <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(release)) {
version = version+'-SNAPSHOT'
}
}