This repository has been archived by the owner on Nov 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathbuild.gradle
126 lines (112 loc) · 3.77 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
repositories {
mavenCentral()
}
apply plugin: 'base'
apply plugin: 'java'
version = 0.4
sourceCompatibility = 1.7
def libsDir = new File(project.buildDir,'libs')
def wlt3ClassesDir = new File(project.buildDir,'classes/java/main/bort/millipede/wlt3')
//get local IP address of host executing gradle build process
def getLocalIP() {
Enumeration<NetworkInterface> ifaces = NetworkInterface.getNetworkInterfaces();
while(ifaces.hasMoreElements()) {
NetworkInterface iface = ifaces.nextElement();
if(iface.isUp() && !iface.isLoopback()) {
Enumeration<InetAddress> addrs = iface.getInetAddresses();
while(addrs.hasMoreElements()) {
String addr = addrs.nextElement().getHostAddress();
if(!addr.contains(":")) {
return addr
}
}
}
}
}
dependencies {
compile fileTree(dir: project.buildDir.absolutePath+"/libs", include: ["ysoserial*.jar","wlthint3client*.jar"])
testCompile "junit:junit:4.12"
}
sourceSets {
main {
java {
srcDir 'src'
}
}
test {
java {
srcDir 'tests'
}
}
}
task prepare {
doLast {
project.mkdir(project.buildDir)
libsDir.mkdirs()
wlt3ClassesDir.mkdirs()
}
}
task getYSS {
doLast {
FileTree tree = fileTree(dir: libsDir, include: ['ysoserial*.jar'])
if(tree.isEmpty()) {
println "downloading ysoserial v0.0.5"
File ysJar = new File(libsDir,'ysoserial-v0.0.5.jar')
new URL('https://jitpack.io/com/github/frohoff/ysoserial/v0.0.5/ysoserial-v0.0.5.jar').withInputStream{ i -> ysJar.withOutputStream{ it << i }}
}
}
}
task checkWLClient {
doLast {
FileTree tree = fileTree(dir: libsDir, include: ['wlthint3client*.jar'])
if(tree.isEmpty()) {
throw new GradleException("Required jar file wlthint3client.jar not present in "+libsDir.absolutePath+" directory! Build cannot continue!\n\n"+
"Download wls1036_dev.zip file from http://www.oracle.com/technetwork/middleware/weblogic/downloads/wls-main-097127.html (\"Zip distribution for Mac OSX, Windows, and Linux\" under \"Oracle WebLogic Server 10.3.6\" section) and extract wlthint3client.jar (/wlserver/server/lib/wlthint3client.jar) file into "+libsDir.absolutePath+" directory!")
}
}
}
getYSS.dependsOn prepare
checkWLClient.dependsOn getYSS
compileJava.dependsOn checkWLClient
//disabled for now, may be removed later.
/*task fatJar(type: Jar) {
manifest {
attributes 'Main-Class': 'bort.millipede.wlt3.WLT3Serial'
}
baseName = project.name + '-full'
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
with jar
}*/
/*
parameters (specified at runtime with "gradle -Dparam=val test"):
(required)
wlt3.target.host: target host to use
wlt3.target.t3.port: T3 port to use on target host
wlt3.target.t3s.port: T3S port to use on target hosts
(optional)
wlt3.test.server.port: local port for web server to listen on
wlt3.test.tries: number of times to verify whether target system has accessed local web server
wlt3.test.verbose: verbose WLT3Serial output (true or false)
*/
test {
useJUnit {
//required test input properties
systemProperty "wlt3.target.host", System.getProperty("wlt3.target.host")
systemProperty "wlt3.target.t3.port", System.getProperty("wlt3.target.t3.port")
systemProperty "wlt3.target.t3s.port", System.getProperty("wlt3.target.t3s.port")
systemProperty "localhost.ip", getLocalIP()
//optional test input properties
def serverPort = System.getProperty("wlt3.test.server.port")
if(serverPort != null) systemProperty "wlt3.test.server.port", serverPort
def tries = System.getProperty("wlt3.test.tries")
if(tries != null) systemProperty "wlt3.test.tries", tries
def verbose = System.getProperty("wlt3.test.verbose")
if(verbose != null) systemProperty "wlt3.test.verbose", verbose
forkEvery = 1
scanForTestClasses = true
testLogging.showStandardStreams = true
}
testLogging {
exceptionFormat "full"
}
}