MCPcopy Create free account
hub / github.com/appdevforall/CodeOnTheGo / zeroCompressMavenRepo

Function zeroCompressMavenRepo

build.gradle.kts:527–559  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

525}
526
527fun zeroCompressMavenRepo(source: Path, destination: Path, validateArchives: Boolean, logger: Logger) {
528 val normalizedSource = source.normalizedAbsolute()
529 val normalizedDestination = destination.normalizedAbsolute()
530
531 require(Files.isDirectory(normalizedSource)) {
532 "Maven repository directory does not exist or is not a directory: $normalizedSource"
533 }
534 require(!normalizedDestination.startsWith(normalizedSource)) {
535 "Zero-compressed output directory must not be inside the input repository: $normalizedDestination"
536 }
537
538 Files.createDirectories(normalizedDestination)
539
540 normalizedSource.toFile().walkTopDown()
541 .filter { it.isFile }
542 .forEach { file ->
543 val sourceFile = file.toPath()
544 val targetFile = normalizedDestination.resolve(normalizedSource.relativize(sourceFile))
545
546 Files.createDirectories(targetFile.parent)
547
548 when (file.extension.lowercase()) {
549 "aar", "jar" -> {
550 zeroCompressArchive(sourceFile, targetFile)
551 if (validateArchives) {
552 validateZeroCompressedArchive(sourceFile, targetFile)
553 }
554 logger.lifecycle("Zero-compressed ${sourceFile.relativeTo(normalizedSource)}")
555 }
556 else -> Files.copy(sourceFile, targetFile, StandardCopyOption.REPLACE_EXISTING)
557 }
558 }
559}
560
561fun zeroCompressArchive(source: Path, destination: Path) {
562 ZipInputStream(Files.newInputStream(source).buffered()).use { input ->

Callers 1

build.gradle.ktsFile · 0.85

Calls 13

requireFunction · 0.85
zeroCompressArchiveFunction · 0.85
lowercaseMethod · 0.80
startsWithMethod · 0.65
resolveMethod · 0.65
copyMethod · 0.65
isDirectoryMethod · 0.45
forEachMethod · 0.45
filterMethod · 0.45
toFileMethod · 0.45
relativizeMethod · 0.45

Tested by

no test coverage detected