@@ -10,41 +10,60 @@ repositories {
10
10
mavenCentral()
11
11
}
12
12
13
- val z3native by configurations.creating
14
-
15
13
val z3Version = " 4.11.2"
16
14
17
- val z3JavaJar by lazy { z3Release(" x64-win" , " *.jar" ) }
15
+ val z3JavaJar by lazy { mkZ3ReleaseDownloadTask(" x64-win" , " *.jar" ) }
16
+
17
+ val z3Binaries = listOf (
18
+ mkZ3ReleaseDownloadTask(" x64-win" , " *.dll" ),
19
+ mkZ3ReleaseDownloadTask(" x64-glibc-2.31" , " *.so" ),
20
+ mkZ3ReleaseDownloadTask(" x64-osx-10.16" , " *.dylib" )
21
+ )
18
22
19
23
dependencies {
20
24
implementation(project(" :ksmt-core" ))
21
- implementation(z3JavaJar)
25
+ implementation(fileTree(z3JavaJar.outputDirectory) {
26
+ builtBy(z3JavaJar)
27
+ })
22
28
23
29
testImplementation(testFixtures(project(" :ksmt-core" )))
24
30
testFixturesApi(testFixtures(project(" :ksmt-core" )))
25
- testFixturesImplementation(z3Release(" x64-win" , " *.jar" ))
26
-
27
- z3native(z3Release(" x64-win" , " *.dll" ))
28
- z3native(z3Release(" x64-glibc-2.31" , " *.so" ))
29
- z3native(z3Release(" x64-osx-10.16" , " *.dylib" ))
31
+ testFixturesImplementation(fileTree(z3JavaJar.outputDirectory) {
32
+ builtBy(z3JavaJar)
33
+ })
30
34
}
31
35
32
36
tasks.withType<ProcessResources > {
33
- from(z3native.resolvedConfiguration.files) {
34
- into(" lib/x64" )
37
+ dependsOn.addAll(z3Binaries)
38
+ z3Binaries.forEach { z3BinaryTask ->
39
+ from(z3BinaryTask.outputFiles) {
40
+ into(" lib/x64" )
41
+ }
35
42
}
36
43
}
37
44
38
- fun z3Release (arch : String , artifactPattern : String ): FileTree {
45
+ fun Project. mkZ3ReleaseDownloadTask (arch : String , artifactPattern : String ): TaskProvider < Task > {
39
46
val z3ReleaseBaseUrl = " https://github.com/Z3Prover/z3/releases/download"
40
47
val releaseName = " z3-${z3Version} "
41
48
val packageName = " z3-${z3Version} -${arch} .zip"
42
49
val packageDownloadTarget = buildDir.resolve(" dist" ).resolve(releaseName).resolve(packageName)
43
- download(listOf (z3ReleaseBaseUrl, releaseName, packageName).joinToString(" /" ), packageDownloadTarget)
44
- return zipTree(packageDownloadTarget).matching { include(" **/$artifactPattern " ) }
50
+ val downloadUrl = listOf (z3ReleaseBaseUrl, releaseName, packageName).joinToString(" /" )
51
+ val downloadTaskName = " z3-release-$releaseName -$arch -${artifactPattern.replace(' *' , ' -' )} "
52
+ return tasks.register(downloadTaskName) {
53
+ val outputDir = buildDir.resolve(" dist" ).resolve(downloadTaskName)
54
+ doLast {
55
+ download(downloadUrl, packageDownloadTarget)
56
+ val files = zipTree(packageDownloadTarget).matching { include(" **/$artifactPattern " ) }
57
+ copy {
58
+ from(files.files)
59
+ into(outputDir)
60
+ }
61
+ }
62
+ outputs.dir(outputDir)
63
+ }
45
64
}
46
65
47
- val runBenchmarksBasedTests = project.booleanProperty(" z3.runBenchmarksBasedTests" ) ? : true
66
+ val runBenchmarksBasedTests = project.booleanProperty(" z3.runBenchmarksBasedTests" ) ? : false
48
67
49
68
// skip big benchmarks to achieve faster tests build and run time
50
69
val skipBigBenchmarks = project.booleanProperty(" z3.skipBigBenchmarks" ) ? : true
@@ -108,7 +127,7 @@ tasks.withType<Test> {
108
127
tasks.withType<ShadowJar > {
109
128
archiveClassifier.set(" " )
110
129
dependencies {
111
- include(dependency(z3JavaJar))
130
+ include(dependency(z3JavaJar.outputFiles ))
112
131
}
113
132
val implementation = project.configurations[" implementation" ].dependencies.toSet()
114
133
val runtimeOnly = project.configurations[" runtimeOnly" ].dependencies.toSet()
@@ -124,3 +143,9 @@ publishing {
124
143
}
125
144
}
126
145
}
146
+
147
+ val TaskProvider <Task >.outputDirectory: File
148
+ get() = get().outputs.files.singleFile
149
+
150
+ val TaskProvider <Task >.outputFiles: FileTree
151
+ get() = fileTree(outputDirectory)
0 commit comments