| 485 | toAbsolutePath().normalize() |
| 486 | |
| 487 | fun convertCacheToLocalMavenRepo(source: Path, destination: Path, logger: Logger) { |
| 488 | val allowedExtensions = setOf("aar", "jar", "module", "pom") |
| 489 | val normalizedSource = source.normalizedAbsolute() |
| 490 | val normalizedDestination = destination.normalizedAbsolute() |
| 491 | |
| 492 | require(Files.isDirectory(normalizedSource)) { |
| 493 | "Maven cache directory does not exist or is not a directory: $normalizedSource" |
| 494 | } |
| 495 | require(!normalizedDestination.startsWith(normalizedSource)) { |
| 496 | "Local Maven output directory must not be inside the input cache: $normalizedDestination" |
| 497 | } |
| 498 | |
| 499 | Files.createDirectories(normalizedDestination) |
| 500 | |
| 501 | normalizedSource.toFile().walkTopDown() |
| 502 | .filter { it.isFile } |
| 503 | .filter { it.extension.lowercase() in allowedExtensions } |
| 504 | .forEach { file -> |
| 505 | val filePath = file.toPath() |
| 506 | val relativeParent = |
| 507 | filePath.parent |
| 508 | ?.let { normalizedSource.relativize(it).map(Path::toString).toList() } |
| 509 | .orEmpty() |
| 510 | |
| 511 | val targetParts = |
| 512 | if (relativeParent.firstOrNull()?.contains(".") == true) { |
| 513 | relativeParent.first().split(".") + relativeParent.drop(1).dropLast(1) |
| 514 | } else { |
| 515 | relativeParent.dropLast(1) |
| 516 | } |
| 517 | |
| 518 | val targetParent = normalizedDestination.resolveParts(targetParts) |
| 519 | val targetFile = targetParent.resolve(file.name) |
| 520 | |
| 521 | Files.createDirectories(targetParent) |
| 522 | Files.copy(filePath, targetFile, StandardCopyOption.REPLACE_EXISTING) |
| 523 | logger.lifecycle("Copied ${filePath.relativeTo(normalizedSource)} -> ${targetFile.relativeTo(normalizedDestination)}") |
| 524 | } |
| 525 | } |
| 526 | |
| 527 | fun zeroCompressMavenRepo(source: Path, destination: Path, validateArchives: Boolean, logger: Logger) { |
| 528 | val normalizedSource = source.normalizedAbsolute() |
no test coverage detected