-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
219 lines (184 loc) · 6.09 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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'application'
apply plugin: 'com.google.protobuf'
group = 'cic.unb.ca'
version = '4.0'
description = """CICFlowMeterV4"""
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories {
mavenLocal()
mavenCentral()
maven { url "https://clojars.org/repo" }
}
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.8'
}
}
def grpcVersion = '1.29.0'
dependencies {
repositories {
mavenCentral()
}
compile "io.grpc:grpc-netty:${grpcVersion}"
compile "io.grpc:grpc-protobuf:${grpcVersion}"
compile "io.grpc:grpc-stub:${grpcVersion}"
compile group: 'com.google.protobuf', name: 'protobuf-java-util', version: '3.12.2'
compile group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.11.0'
compile group: 'org.slf4j', name: 'slf4j-log4j12', version:'1.7.25'
compile group: 'org.jnetpcap', name: 'jnetpcap', version:'1.4.1'
compile group: 'junit', name: 'junit', version:'4.12'
compile group: 'org.apache.commons', name: 'commons-lang3', version:'3.6'
compile group: 'org.apache.commons', name: 'commons-math3', version:'3.5'
compile group: 'commons-io', name: 'commons-io', version:'2.5'
compile group: 'nz.ac.waikato.cms.weka', name: 'weka-stable', version:'3.6.14'
// https://mvnrepository.com/artifact/org.jfree/jfreechart
compile group: 'org.jfree', name: 'jfreechart', version: '1.5.0'
// https://mvnrepository.com/artifact/com.google.guava/guava
compile group: 'com.google.guava', name: 'guava', version: '23.6-jre'
// https://mvnrepository.com/artifact/org.apache.tika/tika-core
compile group: 'org.apache.tika', name: 'tika-core', version: '1.17'
}
sourceSets {
main {
java {
srcDir 'src'
srcDirs 'build/generated/source/proto/main/grpc'
srcDirs 'build/generated/source/proto/main/java'
exclude '**/CICFlowMeter.java'
}
}
}
task zipSrc(type: Zip){
baseName "${applicationName}-Source"
destinationDir = file('build/')
from('.'){
include '**/'
exclude '.gradle/','build/','bin/','logs/','*.iml','*.ipr','*.iws','.idea/','out/','data/'
into "${applicationName}V${version}-Src"
}
}
import org.apache.tools.ant.DirectoryScanner
task zipPro(type: Zip){
doFirst {
DirectoryScanner.defaultExcludes.each { DirectoryScanner.removeDefaultExclude it }
//DirectoryScanner.addDefaultExclude 'something has to be in here or everything gets excluded'
}
doLast {
DirectoryScanner.resetDefaultExcludes()
}
baseName "${applicationName}-Full"
destinationDir = file('build/')
from('.'){
include '**/'
exclude '.gradle/','build/','bin/','logs/','*.iml','*.ipr','*.iws','.idea/','out/','data/',".git/"
into "${applicationName}V${version}"
}
}
task fatJar(type: Jar) {
println 'type Jar'
manifest {
attributes 'Premain-Class': 'swing.common.ObjectSizeFetcher'
attributes 'Can-Retransform-Classes': true
attributes 'Implementation-Title': 'Gradle Jar File Example',
'Implementation-Version': version,
'Main-Class': 'cic.cs.unb.ca.ifm.App'
}
/*baseName = "NetWorkTraffic" + '-all'
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
into(new File('build/jar/'))
with jar*/
}
task execute(type: JavaExec) {
println 'type JavaExec'
main = "cic.cs.unb.ca.ifm.App" //main class
classpath = sourceSets.main.runtimeClasspath
String osName = System.getProperty('os.name').toLowerCase()
if(osName.contains('windows')){
jvmArgs '-Djava.library.path=jnetpcap/win/jnetpcap-1.4.r1425'
}else{
jvmArgs '-Djava.library.path=jnetpcap/linux/jnetpcap-1.4.r1425'
}
}
task exeCMD(type: JavaExec){
main = "cic.cs.unb.ca.ifm.Cmd" //main class
classpath = sourceSets.main.runtimeClasspath
String osName = System.getProperty('os.name').toLowerCase()
if(osName.contains('windows')){
jvmArgs '-Djava.library.path=jnetpcap/win/jnetpcap-1.4.r1425'
}else{
jvmArgs '-Djava.library.path=jnetpcap/linux/jnetpcap-1.4.r1425'
}
//args = ["/home/yzhang29/0a/Capture/", "/home/yzhang29/0a/Capture/out/"]
}
task cmdScript(type: CreateStartScripts) {
mainClassName = "cic.cs.unb.ca.ifm.Cmd"
applicationName = "cfm"
outputDir = new File(project.buildDir, 'scripts')
classpath = jar.outputs.files + project.configurations.runtime
defaultJvmOpts = ["-Djava.library.path=../lib/native"]
}
applicationDistribution.into("bin") {
from(cmdScript)
fileMode = 0755
}
// The Application Plugin
mainClassName = "cic.cs.unb.ca.ifm.App"
applicationName = "CICFlowMeter"
applicationDefaultJvmArgs = ["-Djava.library.path=../lib/native"]
applicationDistribution.from("jnetpcap/linux/jnetpcap-1.4.r1425") {
include "*.so"
into('lib/native')
}
applicationDistribution.from("jnetpcap/win/jnetpcap-1.4.r1425") {
include "*.dll"
into('lib/native')
}
applicationDistribution.from('LICENSE.txt'){
into('')
}
applicationDistribution.from('ReadMe.txt'){
into('')
rename("ReadMe.txt","README.md")
}
// An example task that "generates" protobuf files. A real project
// would fetch protobuf definitions from an HTTP site and/or have
// a code generator task that would generate protobufs.
//task generateProtobuf() {
// def file = new File("${buildDir}/proto/example.proto")
// doLast {
// file.parentFile.mkdirs()
// file.text = '''
// syntax = "proto2";
//
// message TestMessage {
// optional int32 example = 1;
// }
// '''
// }
//}
jar {
manifest {
attributes 'Main-Class': 'ciccic.cs.unb.ca.ifm.Cmd'
}
}
protobuf {
protoc {
artifact = 'com.google.protobuf:protoc:3.12.2'
}
plugins {
grpc {
artifact = "io.grpc:protoc-gen-grpc-java:${grpcVersion}"
}
}
generateProtoTasks {
all()*.plugins {
grpc {}
}
}
}