forked from osu-mist/hr-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
106 lines (92 loc) · 3.75 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
// https://docs.gradle.org/current/userguide/groovy_plugin.html
apply plugin: 'groovy'
// https://docs.gradle.org/current/userguide/codenarc_plugin.html
apply plugin: 'codenarc'
// https://docs.gradle.org/current/userguide/idea_plugin.html
apply plugin: 'idea'
// https://plugins.gradle.org/plugin/com.github.johnrengelman.shadow
apply plugin: 'com.github.johnrengelman.shadow'
// https://docs.gradle.org/current/dsl/org.gradle.api.plugins.ExtraPropertiesExtension.html
project.ext.buildTime = new Date()
// https://docs.gradle.org/current/userguide/organizing_build_logic.html#sec:external_dependencies
buildscript {
repositories {
maven {
url 'https://plugins.gradle.org/m2/'
}
}
dependencies {
classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.3'
}
}
// https://docs.gradle.org/current/userguide/artifact_dependencies_tutorial.html#N10621
repositories {
mavenCentral()
flatDir {
dirs 'bin'
}
}
// https://docs.gradle.org/current/userguide/artifact_dependencies_tutorial.html#N105E1
dependencies {
testCompile "junit:junit:4.12"
testCompile "io.dropwizard:dropwizard-testing:${dropwizardVersion}"
codenarc "org.codenarc:CodeNarc:${codenarcVersion}"
compile 'org.yaml:snakeyaml:1.16'
compile "org.codehaus.groovy:groovy:${groovyVersion}"
compile "io.dropwizard:dropwizard-core:${dropwizardVersion}"
compile "io.dropwizard:dropwizard-auth:${dropwizardVersion}"
compile "io.dropwizard:dropwizard-client:${dropwizardVersion}"
compile "de.thomaskrille:dropwizard-template-config:1.4.0"
compile "io.dropwizard:dropwizard-jdbi:${dropwizardVersion}"
compile ':ojdbc6:'
}
codenarc {
configFile = new File("config/codenarc/codenarc.groovy")
}
// https://docs.gradle.org/current/userguide/java_plugin.html#N12B9A
// https://docs.gradle.org/current/dsl/org.gradle.api.tasks.bundling.Jar.html
jar {
baseName = project.archivesBaseName
appendix = project.ext.buildTime.getTime()
version = 'git log -n1 --format=format:%h'.execute().getText()
extension = 'jar'
archiveName = "${baseName}-${appendix}-${version}.${extension}"
}
// https://github.com/johnrengelman/shadow
shadowJar {
baseName = jar.baseName
appendix = jar.appendix
version = jar.version
classifier = 'all'
extension = jar.extension
archiveName = "${baseName}-${appendix}-${version}-${classifier}.${extension}"
manifest {
attributes 'Main-Class': "${mainClass}"
}
mergeServiceFiles()
}
// downloads files stored in contrib repository if getContribFiles is yes
task cloneContribFiles(type: Exec) {
commandLine './cloneContribFiles.sh', "${contribRepo}${archivesBaseName}-contrib.git", "${getContribFiles}", "${contribCommit}"
}
compileGroovy.dependsOn cloneContribFiles
// write build properties to file
task writeBuildProperties << {
Properties properties = new Properties()
properties.setProperty('name', jar.baseName)
properties.setProperty('time', project.ext.buildTime.format('yyyy-MM-dd HH:mm:ssXX'))
properties.setProperty('unixTime', jar.appendix)
properties.setProperty('commit', jar.version)
properties.setProperty('documentation', 'swagger.yaml')
FileWriter fileWriter = new FileWriter("${projectDir}/src/main/resources/build.properties")
properties.store(fileWriter, 'build properties')
}
processResources.dependsOn writeBuildProperties
// https://docs.gradle.org/current/dsl/org.gradle.api.tasks.javadoc.Groovydoc.html
build.dependsOn shadowJar, groovydoc, cloneContribFiles
// FIXME: use ShadowJar (java -jar build/libs/web-api-skeleton-all.jar server configuration.yaml)
task run(type: JavaExec, dependsOn: build) {
main = "${mainClass}"
classpath = sourceSets.main.runtimeClasspath
args = ['server', 'configuration.yaml']
}