-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
144 lines (120 loc) · 4.59 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
apply plugin: "groovy"
apply plugin: "application"
apply plugin: "propdeps"
apply plugin: "propdeps-maven"
apply plugin: 'propdeps-idea'
apply plugin: 'propdeps-eclipse'
group = "com.github.metridoc-job-cli"
mainClassName = "metridoc.cli.MetridocMain"
applicationName = "mdoc"
sourceCompatibility = "1.7"
targetCompatibility = "1.7"
archivesBaseName = "metridoc-job-cli"
version = new File("${projectDir}/VERSION").text.trim()
apply plugin: "metridoc"
sourceSets {
integTest {
groovy {
srcDir "src/integ/groovy"
}
resources {
srcDir "src/integ/resources"
}
}
}
buildscript {
repositories {
mavenLocal()
maven { url "http://dl.bintray.com/upennlib/metridoc" }
maven { url 'http://repo.springsource.org/plugins-release' }
}
dependencies {
classpath 'com.github.metridoc:metridoc-gradle-plugin:0.2.19',
'org.springframework.build.gradle:propdeps-plugin:0.0.1'
}
}
project.ext {
bintrayRepo = "http://dl.bintray.com/upennlib/metridoc-distributions"
}
repositories {
mavenLocal()
mavenCentral()
maven {
url "http://jcenter.bintray.com/"
}
maven {
url "http://dl.bintray.com/upennlib/metridoc"
}
}
dependencies {
//core libraries that are required to get the cli up and running
compile 'org.codehaus.groovy:groovy-all:2.0.8', 'org.apache.commons:commons-compress:1.5',
'commons-cli:commons-cli:1.2', 'org.slf4j:slf4j-simple:1.7.5'
//metridoc
provided 'com.github.metridoc:metridoc-tool-gorm:0.5.6'
//other helpful libraries
provided 'org.apache.commons:commons-email:1.3.1'
provided 'org.apache.poi:poi:3.8-beta3'
provided ('org.apache.poi:poi-ooxml:3.8-beta3') {
exclude module: 'poi'
exclude module: 'dom4j'
}
testCompile 'org.spockframework:spock-core:0.7-groovy-2.0'
integTestCompile 'org.codehaus.groovy:groovy-all:2.0.8',
"org.spockframework:spock-core:0.7-groovy-2.0"
}
task uploadDist(type: metridoc.gradle.GenericBintrayUpload, dependsOn: "distZip") {
artifactFile = distZip.archivePath
bintrayRepo = "https://api.bintray.com/content/upennlib/metridoc-distributions/${archivesBaseName}/$version/${distZip.archiveName}"
}
task copyDependenciesToLib(type: Copy, dependsOn: ["installApp"]) {
def destination = "$buildDir/install/$applicationName/lib"
if (project.hasProperty("dependenciesDestination")) {
destination = project.dependenciesDestination
}
into destination
from configurations.provided
}
//for a single test, you can run "gradle -DintegTests.single=<test name>"
task integTests(type: Test, dependsOn: "copyDependenciesToLib") {
testClassesDir = sourceSets.integTest.output.classesDir
classpath = sourceSets.integTest.runtimeClasspath
include "**/*Spec*"
exclude "**/Abstract*Spec*"
}
startScripts {
doLast {
File windowsScriptFile = file getWindowsScript()
File unixScriptFile = file getUnixScript()
windowsScriptFile.text = windowsScriptFile.text.replaceFirst(/CLASSPATH=[^\s]+/, 'CLASSPATH=%APP_HOME%\\\\lib\\\\*')
unixScriptFile.text = unixScriptFile.text.replaceFirst(/CLASSPATH=[^\s]+/, 'CLASSPATH=\\$APP_HOME/lib/*')
}
}
task createDependencyFile << {
def dependencyFile = new File(project.projectDir as File, "src/main/resources/DEPENDENCY_URLS")
def jcenterUrl = "http://jcenter.bintray.com"
def metridocUrl = "http://dl.bintray.com/upennlib/metridoc"
def mavenUrl = "http://repo1.maven.org/maven2"
dependencyFile.withPrintWriter("utf-8") { PrintWriter writer ->
configurations.provided.resolvedConfiguration.resolvedArtifacts.each {
def dep = it.resolvedDependency
String moduleGroup = dep.moduleGroup
def moduleVersion = dep.moduleVersion
def moduleName = dep.moduleName
def baseUrl = moduleName.contains("metridoc") ? metridocUrl : jcenterUrl
baseUrl = moduleName.contains("groovy-stream") ? mavenUrl : baseUrl
writer.println "$baseUrl/${moduleGroup.replaceAll(/\./, "/")}/$moduleName/$moduleVersion/" +
"$moduleName-${moduleVersion}.jar"
}
}
}
task testDependencyFile(dependsOn: "createDependencyFile") << {
new File(project.projectDir as File, "src/main/resources/DEPENDENCY_URLS").eachLine("utf-8") {String line ->
new URL(line).openConnection().with {
requestMethod = "HEAD"
inputStream.close()
assert responseCode >= 200 && responseCode < 300
}
}
}
installApp.dependsOn "createDependencyFile"