-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle
More file actions
149 lines (126 loc) · 5.18 KB
/
build.gradle
File metadata and controls
149 lines (126 loc) · 5.18 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
import org.gradle.internal.os.OperatingSystem
plugins {
id 'com.diffplug.spotless' version '6.9.0'
}
tasks.register('copyNativeLibs', Copy) { // copies correct native z3 files to libs/
def osArchMap = [
'windows-x64': 'z3-4.15.4-x64-win',
'windows-x86': 'z3-4.15.4-x86-win',
'osx-x64' : 'z3-4.15.4-x64-osx-13.7.6',
'osx-arm64' : 'z3-4.15.4-arm64-osx-13.7.6',
'linux-x64' : 'z3-4.15.4-x64-glibc-2.39',
'linux-arm64': 'z3-4.15.4-arm64-glibc-2.34'
]
def os = OperatingSystem.current()
println("Operating system: $os")
def arch = System.getProperty("os.arch") // Use Java system property to get architecture
println("Architecture: $arch")
def osKey = ''
switch (os) {
case OperatingSystem.LINUX:
osKey = arch == "aarch64" ? "linux-arm64" : "linux-x64"
break;
case OperatingSystem.MAC_OS:
osKey = arch == "aarch64" ? "osx-arm64" : "osx-x64"
break;
case OperatingSystem.WINDOWS:
osKey = arch == "x86" ? "windows-x86" : "windows-x64"
break;
}
println("Operating system key: $osKey")
if (!osKey) {
throw new GradleException("Unsupported operating system or architecture.")
}
def z3Zip = file("libs/${osArchMap[osKey]}.zip")
if (!z3Zip.exists()) {
throw new GradleException("Z3 distribution zip file not found at ${z3Zip.path}")
}
from zipTree(z3Zip)
into 'libs/java-library-path'
include "${osArchMap[osKey]}/bin/z3*"
include "${osArchMap[osKey]}/bin/libz3.*"
include "${osArchMap[osKey]}/bin/libz3java.*"
include "${osArchMap[osKey]}/bin/com.microsoft.z3.jar"
eachFile { FileCopyDetails fcp ->
fcp.relativePath = new RelativePath(true, fcp.name)
}
includeEmptyDirs false
}
tasks.register('downloadJacoco') {
description = 'Downloads JaCoCo agent jar for coverage collection'
def jacocoVersion = '0.8.13'
def jacocoUrl = "https://repo1.maven.org/maven2/org/jacoco/org.jacoco.agent/${jacocoVersion}/org.jacoco.agent-${jacocoVersion}-runtime.jar"
def jacocoCliUrl = "https://repo1.maven.org/maven2/org/jacoco/org.jacoco.cli/${jacocoVersion}/org.jacoco.cli-${jacocoVersion}-nodeps.jar"
def jacocoDir = file('libs/jacoco')
def jacocoAgent = file("${jacocoDir}/jacocoagent.jar")
def jacocoCli = file("${jacocoDir}/jacococli.jar")
outputs.files(jacocoAgent, jacocoCli)
doLast {
jacocoDir.mkdirs()
// Download JaCoCo agent
if (!jacocoAgent.exists()) {
println "Downloading JaCoCo agent from ${jacocoUrl}"
new URL(jacocoUrl).withInputStream{ i -> jacocoAgent.withOutputStream{ it << i }}
}
// Download JaCoCo CLI for report generation
if (!jacocoCli.exists()) {
println "Downloading JaCoCo CLI from ${jacocoCliUrl}"
new URL(jacocoCliUrl).withInputStream{ i -> jacocoCli.withOutputStream{ it << i }}
}
println "JaCoCo agent downloaded to: ${jacocoAgent.absolutePath}"
println "JaCoCo CLI downloaded to: ${jacocoCli.absolutePath}"
}
}
configurations {
cfgExtractor
}
dependencies {
cfgExtractor 'de.uzl.its:cfg-extractor:1.0-SNAPSHOT'
}
tasks.register('downloadCfgExtractor', Copy) {
description = 'Downloads cfg-extractor fat JAR from GitHub Packages'
from configurations.cfgExtractor
into 'libs/cfg-extractor'
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
doLast {
def jarFile = fileTree('libs/cfg-extractor').matching { include '*.jar' }.singleFile
println "cfg-extractor fat JAR downloaded to: ${jarFile.absolutePath}"
println "Usage: java -jar ${jarFile.name} <input-path> <output-dir> [entry-class] [entry-method] [analysis-type]"
}
}
allprojects {
apply plugin: 'com.diffplug.spotless'
apply plugin: 'java'
repositories {
mavenCentral()
// GitHub Packages repository for cfg-extractor
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/SWAT-project/SWAT-Research")
credentials {
username = project.findProperty("gpr.user") ?: System.getenv("GITHUB_USERNAME")
password = project.findProperty("gpr.token") ?: System.getenv("GITHUB_TOKEN")
}
}
// JitPack for SootUp dependencies (dex-tools)
maven {
url = uri("https://jitpack.io")
}
// Google's Maven repository for Android tools (R8)
maven {
url = uri("https://maven.google.com")
}
}
java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}
apply from: "${rootProject.projectDir}/spotless.gradle"
// Ensures that all tasks that run Java code use the correct Java version
tasks.withType(JavaExec).configureEach {
javaLauncher = javaToolchains.launcherFor {
languageVersion = JavaLanguageVersion.of(17)
}
}
}