-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathbuild.gradle
More file actions
162 lines (140 loc) · 3.94 KB
/
build.gradle
File metadata and controls
162 lines (140 loc) · 3.94 KB
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
import static groovy.io.FileType.*
// Plugins
plugins {
id "com.jfrog.bintray" version "1.7.3"
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'checkstyle'
apply plugin: 'jacoco'
apply plugin: 'findbugs'
apply plugin: 'maven'
apply plugin: 'maven-publish'
sourceCompatibility = 1.7
// Project structure
sourceSets {
main {
java {
srcDir 'src/main/java'
}
}
test {
java {
srcDir 'src/test/java'
}
}
}
// Use jcenter
repositories {
jcenter()
}
// Dependencies
dependencies {
compile group: 'net.freehaven.tor.control', name: 'jtorctl', version: '0.2'
compile group: 'commons-net', name: 'commons-net', version: '3.3'
compile group: 'commons-codec', name: 'commons-codec', version: '1.10'
compile group: 'org.bouncycastle', name: 'bcprov-jdk15on', version: '1.54'
compile group: 'org.bouncycastle', name: 'bcpkix-jdk15on', version: '1.54'
compile group: 'com.esotericsoftware', name: 'kryo', version: '4.0.0'
compile group: 'com.google.code.findbugs', name: 'findbugs-annotations', version: '3.0.1'
testCompile group: 'junit', name: 'junit', version: '4.+'
}
// Checkstyle
checkstyle {
toolVersion = "6.12.1"
}
// Test coverage
jacocoTestReport {
reports {
xml.enabled false
csv.enabled false
html.destination = file("${buildDir}/jacocoHtml")
}
afterEvaluate {
classDirectories = files(classDirectories.files.collect {
fileTree(dir: it, exclude: 'edu/kit/tm/ptp/examples/**')
})
}
}
// Findbugs
tasks.withType(FindBugs) {
reports {
xml.enabled = false
html.enabled = true
}
}
// Create tasks to create a jar file for each example
File srcDir = file(sourceSets.main.java.srcDirs[0].getAbsolutePath() + '/edu/kit/tm/ptp/examples')
def names = []
srcDir.eachFileMatch FILES, ~/.*\.java/, { file -> names << file.name }
String exName
names.each { fileName ->
exName = fileName.split("\\.")[0]
tasks.create(name: exName, type:Jar) {
from sourceSets.main.output
manifest {
attributes 'Main-Class': 'edu.kit.tm.ptp.examples.' + exName
}
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
exclude 'META-INF/*.RSA', 'META-INF/*.SF','META-INF/*.DSA'
baseName = exName
destinationDir = new File("build/examples")
}
}
jar {
dependsOn = tasks.findAll { task -> task.name.contains('Example') }
}
// Pack all dependencies into the fat jar
// For use in a non-Gradle Java project
task fatjar (type: Jar) {
from sourceSets.main.output
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
exclude 'META-INF/*.RSA', 'META-INF/*.SF','META-INF/*.DSA'
baseName = 'PTP-full'
}
jar.dependsOn fatjar
// Outputs when running tests
test.testLogging {
showExceptions = true
showCauses = true
showStackTraces = true
events = ['started', 'failed', 'passed', 'skipped']
exceptionFormat = 'full'
}
// Required for package to be included in jCenter
task sourceJar(type: Jar) {
from sourceSets.main.allJava
}
// Upload to Bintray to add package to jCenter
bintray {
// Set bintrayUser and bintrayApiKey in gradle.properties
user = project.hasProperty('bintrayUser') ? project.property('bintrayUser') : System.getenv('BINTRAY_USER')
key = project.hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY')
publications = ['MyPublication']
pkg {
repo = 'PTP'
name = 'ptp'
userOrg = 'kit-tm'
licenses = ['GPL-3.0']
vcsUrl = 'https://github.com/kit-tm/PTP.git'
version {
name = 'v0.4.1'
desc = ''
released = new Date()
vcsTag = 'v0.4.1'
}
}
}
publishing {
publications {
MyPublication(MavenPublication) {
from components.java
groupId 'edu.kit.tm.ptp'
artifactId 'ptp'
version 'v0.4.1'
artifact sourceJar {
classifier "sources"
}
}
}
}