Skip to content

Commit 16b6651

Browse files
internship initial merge
1 parent 492f7fa commit 16b6651

204 files changed

Lines changed: 14402 additions & 60 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

settings.gradle

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,6 @@ include 'utbot-gradle'
2929
include 'utbot-summary-tests'
3030
include 'utbot-framework-test'
3131
include 'utbot-rd'
32-
32+
include 'utbot-python'
33+
include 'utbot-js'
34+
include 'utbot-go'

utbot-cli/build.gradle

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ dependencies {
2222
implementation project(':utbot-framework-api')
2323
implementation project(':utbot-framework')
2424
implementation project(':utbot-summary')
25+
api project(':utbot-python')
2526

2627
implementation group: 'org.mockito', name: 'mockito-core', version: mockito_version
2728
// Without this dependency testng tests do not run.
@@ -62,6 +63,11 @@ classes {
6263
}
6364

6465
jar {
66+
dependsOn project(':utbot-framework').tasks.jar
67+
dependsOn project(':utbot-summary').tasks.jar
68+
dependsOn project(':utbot-python').tasks.jar
69+
dependsOn project(':utbot-fuzzers').tasks.jar
70+
6571
manifest {
6672
attributes 'Main-Class': 'org.utbot.cli.ApplicationKt'
6773
attributes 'Bundle-SymbolicName': 'org.utbot.cli'

utbot-core/src/main/kotlin/org/utbot/common/FileUtil.kt

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import java.nio.file.StandardCopyOption
1313
import java.nio.file.attribute.BasicFileAttributes
1414
import java.time.Duration
1515
import java.util.concurrent.TimeUnit
16+
import java.util.zip.ZipEntry
1617
import java.util.zip.ZipFile
1718
import kotlin.concurrent.thread
1819
import kotlin.reflect.KClass
@@ -31,12 +32,14 @@ object FileUtil {
3132
fun extractArchive(
3233
archiveFile: Path,
3334
destPath: Path,
34-
vararg options: CopyOption = arrayOf(StandardCopyOption.REPLACE_EXISTING)
35+
vararg options: CopyOption = arrayOf(StandardCopyOption.REPLACE_EXISTING),
36+
extractOnlySuchEntriesPredicate: (ZipEntry) -> Boolean = { true }
3537
) {
3638
Files.createDirectories(destPath)
3739

3840
ZipFile(archiveFile.toFile()).use { archive ->
3941
val entries = archive.stream().asSequence()
42+
.filter(extractOnlySuchEntriesPredicate)
4043
.sortedBy { it.name }
4144
.toList()
4245

@@ -173,12 +176,26 @@ object FileUtil {
173176
/**
174177
* Extracts archive to temp directory and returns path to directory.
175178
*/
176-
fun extractArchive(archiveFile: Path): Path {
179+
fun extractArchive(archiveFile: Path, extractOnlySuchEntriesPredicate: (ZipEntry) -> Boolean = { true }): Path {
177180
val tempDir = createTempDirectory(TEMP_DIR_NAME).toFile().apply { deleteOnExit() }
178-
extractArchive(archiveFile, tempDir.toPath())
181+
extractArchive(archiveFile, tempDir.toPath(), extractOnlySuchEntriesPredicate = extractOnlySuchEntriesPredicate)
179182
return tempDir.toPath()
180183
}
181184

185+
/**
186+
* Extracts specified directory (with all contents) from archive to temp directory and returns path to it.
187+
*/
188+
fun extractDirectoryFromArchive(archiveFile: Path, directoryName: String): Path? {
189+
val extractedJarDirectory = extractArchive(archiveFile) { entry ->
190+
entry.name.normalizePath().startsWith(directoryName)
191+
}
192+
val extractedTargetDirectoryPath = extractedJarDirectory.resolve(directoryName)
193+
if(!extractedTargetDirectoryPath.toFile().exists()) {
194+
return null
195+
}
196+
return extractedTargetDirectoryPath
197+
}
198+
182199
/**
183200
* Returns the path to the class files for the given ClassLocation.
184201
*/

0 commit comments

Comments
 (0)