This repository has been archived by the owner on Mar 25, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle
76 lines (67 loc) · 2.05 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
plugins {
id 'groovy'
}
group 'pl.smiesznadomena.chunkygroovybot'
version '1.0-SNAPSHOT'
repositories {
mavenCentral()
jcenter()
}
compileGroovy {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
dependencies {
compile 'org.codehaus.groovy:groovy-all:3.0.7'
compile ('net.dv8tion:JDA:4.2.0_223') {
exclude module: 'opus-java' // We don't need voice support in this project
}
testCompile group: 'junit', name: 'junit', version: '4.12'
}
// single jar with all deps
task fatJar(type: Jar) {
manifest {
attributes 'Implementation-Title': 'Discord bot for chunky community',
'Implementation-Version': project.version,
'Main-Class': 'pl.smiesznadomena.chunkygroovybot.ChunkyGroovyBot'
}
@SuppressWarnings(["deprecated", "unused"])
baseName = project.name
from {
configurations.compile.collect {
if(it.isDirectory()) {
return it
} else {
if(it.name.endsWith('.pom')) {
return null
}
zipTree(it)
}
}
}
with jar
}
task generateDockerFile {
final dockerFile = new File("Dockerfile")
if(dockerFile.exists()) {
dockerFile.delete()
}
dockerFile.createNewFile()
final properties = new Properties()
properties.load(new File("Dockerfile.properties").newReader())
final modified = []
new File("Dockerfile.template").eachLine {line ->
def modifiedLine = line
properties.each { key, value ->
modifiedLine = modifiedLine.replaceAll("$key", "$value")
}
modifiedLine = modifiedLine.replaceAll("project_version", version as String)
if(!properties.contains('jar_name')) {
modifiedLine = modifiedLine.replaceAll('jar_name', "$project.name-$project.version")
}
// println modifiedLine
logger.info(modifiedLine)
modified << modifiedLine
}
dockerFile.write(modified.join('\n'))
}