-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
107 lines (89 loc) · 3.33 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
import java.nio.file.Paths
plugins {
id 'java'
id 'com.github.johnrengelman.shadow' version '5.2.0'
}
group 'org.example'
version '1.0.0'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
implementation 'javax.inject:javax.inject:1'
compile 'com.google.cloud:google-cloud-speech:1.24.0'
compile 'com.google.cloud:google-cloud-storage:1.111.2'
compile 'commons-cli:commons-cli:1.4'
compile 'com.google.code.gson:gson:2.8.6'
compile 'commons-io:commons-io:2.6'
compile 'commons-fileupload:commons-fileupload:1.4'
compile 'org.apache.commons:commons-lang3:3.11'
implementation 'org.apache.commons:commons-text:1.9'
compile 'com.squareup.retrofit2:retrofit:2.9.0'
compile 'javax.servlet:javax.servlet-api:3.0.1'
compile 'com.google.firebase:firebase-admin:7.1.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
compile 'io.jsonwebtoken:jjwt-api:0.11.2'
runtime 'io.jsonwebtoken:jjwt-impl:0.11.2'
runtime 'io.jsonwebtoken:jjwt-gson:0.11.2'
implementation platform('com.google.cloud:libraries-bom:16.3.0')
compile 'com.google.cloud:google-cloud-logging'
implementation platform('com.amazonaws:aws-java-sdk-bom:1.11.860')
implementation 'com.amazonaws:aws-java-sdk-s3'
implementation 'org.slf4j:slf4j-api:1.7.5'
implementation 'org.slf4j:slf4j-simple:1.7.5'
testCompile group: 'junit', name: 'junit', version: '4.12'
}
shadowJar {
mergeServiceFiles()
}
jar {
manifest {
attributes 'Main-Class': 'server.DemoServer'
}
}
tasks.register("updateRevision") {
doLast {
def serverDir = new File((File) sourceSets.main.java.getSrcDirs().first(), "server")
def serverFile = new File(serverDir, "DemoServer.java")
def revision = bumpVersion(serverFile)
commitAndPush(serverFile, revision)
}
}
private static int bumpVersion(File serverFile) {
def content = serverFile.text
def matcher = content.replace('\n', ' ') =~ /.*int REVISION.=.(\d+)/
if (!matcher.find()) {
throw new GradleException("REVISION not found")
}
def revision = matcher.group(1).trim().toInteger()
def newRevision = revision + 1
serverFile.text = content.replace("int REVISION = $revision", "int REVISION = $newRevision")
return newRevision
}
private static void commitAndPush(File serverFile, int revision) {
exec("git", "add", serverFile.getAbsolutePath())
exec("git", "commit", "-m", "revision $revision")
exec("git", "tag", "r$revision")
def branch = exec("git", "rev-parse", "--abbrev-ref", "HEAD")
exec("git", "push", "origin", branch)
exec("git", "push", "--tags", "origin", branch)
}
private static String exec(String... command) {
def proc = command.execute()
def out = new StringBuffer()
def err = new StringBuffer()
proc.consumeProcessOutput(out, err)
def exitCode = proc.waitFor()
if (exitCode != 0) {
throw new GradleException("Fail to execute '$command': [$exitCode] ${err.toString()}")
}
return out.toString().trim()
}
task generateDocumentation(type: JavaExec) {
group = "Documentation"
description = "Generate API documentation"
classpath = sourceSets.main.runtimeClasspath
main = "doc.DocMain"
args(Paths.get(rootDir.absolutePath, "static-content", "docs").toAbsolutePath().toString(), "api.html")
}