forked from mediathekview/MServer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
387 lines (337 loc) · 11.5 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
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
import org.apache.tools.ant.filters.ReplaceTokens
import java.nio.file.Files
plugins {
id "com.github.jk1.dependency-license-report" version "1.17"
id "org.sonarqube" version "3.3"
}
apply plugin: 'java'
apply plugin: 'distribution'
apply plugin: 'maven'
apply plugin: 'signing'
apply from: "${project.rootDir}/gradle/eclipse.gradle"
sourceCompatibility = 1.8
targetCompatibility = 1.8
group = 'de.mediathekview'
archivesBaseName = "MServer"
version = '3.1.184'
def jarName = 'MServer.jar'
def mainClass = 'mServer.Main'
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
}
repositories {
mavenLocal()
mavenCentral()
maven {
url "https://oss.sonatype.org/content/repositories/snapshots/"
}
}
sourceSets {
developTest {
java {
compileClasspath += main.output + test.output
runtimeClasspath += main.output + test.output
srcDir file('src/test/developTest/java')
}
resources.srcDir file('src/test/developTest/resources')
}
integrationTest {
java {
compileClasspath += main.output + test.output
runtimeClasspath += main.output + test.output
srcDir file('src/test/integrationTest/java')
}
resources.srcDir file('src/test/integrationTest/resources')
}
performanceTest {
java {
compileClasspath += main.output + test.output
runtimeClasspath += main.output + test.output
srcDir file('src/test/performanceTest/java')
}
resources.srcDir file('src/test/performanceTest/resources')
}
}
configurations {
deployerJars
developTestCompile.extendsFrom testCompile
developTestRuntime.extendsFrom testRuntime
integrationTestCompile.extendsFrom testCompile
integrationTestRuntime.extendsFrom testRuntime
performanceTestCompile.extendsFrom testCompile
performanceTestRuntime.extendsFrom testRuntime
}
test {
}
task developTest(type: Test) {
testClassesDirs = sourceSets.developTest.output.classesDirs
classpath = sourceSets.developTest.runtimeClasspath
outputs.upToDateWhen { false }
beforeTest { descriptor ->
logger.lifecycle("Running test: " + descriptor)
}
}
task integrationTest(type: Test) {
testClassesDirs = sourceSets.integrationTest.output.classesDirs
classpath = sourceSets.integrationTest.runtimeClasspath
outputs.upToDateWhen { false }
beforeTest { descriptor ->
logger.lifecycle("Running test: " + descriptor)
}
}
task performanceTest(type: Test) {
logger.info("hier")
testClassesDirs = sourceSets.performanceTest.output.classesDirs
classpath = sourceSets.performanceTest.runtimeClasspath
outputs.upToDateWhen { false }
beforeTest { descriptor ->
logger.lifecycle("Running test: " + descriptor)
}
}
tasks.withType(Test) {
reports.html.destination = file("${reporting.baseDir}/${name}")
}
dependencies {
compile 'de.mediathekview:MLib:3.0.12'
compile 'commons-net:commons-net:3.8.0'
compile 'org.apache.commons:commons-compress:1.21'
compile 'org.apache.commons:commons-text:1.9'
compile 'org.tukaani:xz:1.9'
compile 'com.google.code.gson:gson:2.8.9'
compile 'org.glassfish.jersey.core:jersey-client:3.0.3'
compile 'org.glassfish.jersey.inject:jersey-hk2:3.0.3'
compile 'org.jsoup:jsoup:1.14.3'
compile 'javax.activation:activation:1.1.1'
compile 'com.google.guava:guava:31.0.1-jre'
compile 'org.apache.logging.log4j:log4j-core:2.17.1'
compile 'fm.void.jetm:jetm:1.2.3'
testCompile 'junit:junit:4.13.2'
testCompile 'org.mockito:mockito-core:4.2.0'
testCompile 'com.squareup.okhttp3:mockwebserver:4.9.3'
testCompile "org.hamcrest:hamcrest-all:1.3"
}
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 {
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
}
if (project.hasProperty('SONATYPE_USERNAME')) {
signing {
sign configurations.archives
}
uploadArchives {
repositories {
mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
authentication(userName: SONATYPE_USERNAME, password: SONATYPE_PASSWORD)
}
snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
authentication(userName: SONATYPE_USERNAME, password: SONATYPE_PASSWORD)
}
pom.project {
name project.name
packaging 'jar'
description 'The crawler for mediathekview/MediathekView'
url 'https://github.com/mediathekview/' + project.name
scm {
connection 'scm:git:git://github.com/mediathekview/MServer.git'
developerConnection 'scm:git:ssh://github.com:mediathekview/MServer.git'
url 'http://github.com/mediathekview/MServer/tree/master'
}
licenses {
license {
name 'GNU General Public License v3.0'
url 'https://www.gnu.org/licenses/gpl.html'
}
}
developers {
developer {
id 'Nicklas2751'
name 'Nicklas Wiegandt'
email '[email protected]'
}
developer {
id 'derreisende77'
name 'Christian F.'
url 'https://github.com/derreisende77'
}
developer {
id 'pidoubleyou'
name 'Peter W.'
url 'https://github.com/pidoubleyou'
}
developer {
id 'TheSasch'
name 'Sascha Wiegandt'
url 'https://github.com/thesasch'
}
developer {
id 'alex1702'
name 'Alexander Finkhäuser'
url 'https://github.com/alex1702'
}
}
}
}
}
}
task myJavadocs(type: Javadoc) {
source = sourceSets.main.allJava
failOnError = false
}
task javadocJar(type: Jar) {
classifier = 'javadoc'
from myJavadocs
}
task sourcesJar(type: Jar) {
classifier = 'sources'
from sourceSets.main.allSource
}
artifacts {
archives javadocJar, sourcesJar
}
}
build.dependsOn(install)
task updateVersion {
doLast {
Properties props = loadVersionProperties()
def oldVersion = props.getProperty('VERSION')
String buildDate = new Date().format('dd.MM.yyyy HH:mm:ss')
if (oldVersion != project.version) {
logger.lifecycle "==mserver======================"
logger.lifecycle "Version: $project.version"
logger.lifecycle "Baudatum: $buildDate"
logger.lifecycle "==mserver======================"
props.setProperty('VERSION', project.version)
props.setProperty('DATE', buildDate)
props.store(propsFile.newWriter(), null)
}
}
}
processResources.dependsOn updateVersion
licenseReport {
outputDir = rootProject.projectDir.toPath().resolve("build/Copyright/").toString()
excludes = [':MSearch', 'MediathekView:MLib']
configurations = ['compile']
}
processResources.dependsOn generateLicenseReport
[distZip, distTar]*.shouldRunAfter compileJava, updateVersion, 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 = 'MServer'
contents {
into('lib') {
from configurations.compile
}
from('dist') {
filesMatching('**/*.sh') {
filter(ReplaceTokens, tokens: [JARNAME: jarName])
}
filesMatching('**/*.txt') {
filter(ReplaceTokens, tokens: [JARNAME: jarName])
}
filesMatching('**/*.command') {
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 -PrepoPw=[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 -PrepoPw=[PASSWORD]'
*/
task releaseSnapshot(dependsOn: 'uploadArchives') {
doLast {
println 'Released Snapshot Version ' + version
}
}
gradle.taskGraph.whenReady { taskGraph ->
if (taskGraph.hasTask(releaseSnapshot)) {
version = version + '-SNAPSHOT'
}
}
sonarqube {
properties {
property "sonar.projectKey", "mediathekview_MServer"
}
}