|
1 | 1 | import junitbuild.extensions.javaModuleName |
2 | 2 | import net.ltgt.gradle.errorprone.errorprone |
3 | 3 | import net.ltgt.gradle.nullaway.nullaway |
4 | | -import java.util.zip.ZipFile |
5 | 4 |
|
6 | 5 | plugins { |
7 | 6 | id("junitbuild.java-nullability-conventions") |
@@ -40,42 +39,24 @@ tasks { |
40 | 39 | """) |
41 | 40 | } |
42 | 41 | } |
43 | | - fun copyFastCsvLicenseTo(file: File, configurations: List<FileCollection>) { |
44 | | - val jarFile = configurations |
45 | | - .flatMap { it.files } |
46 | | - .firstOrNull { it.name.contains("fastcsv") } |
47 | | - ?: throw GradleException("Could not find FastCSV dependency JAR") |
48 | | - |
49 | | - ZipFile(jarFile).use { zipFile -> |
50 | | - val licenseEntry = zipFile.entries().toList() |
51 | | - .firstOrNull { it.name == "META-INF/LICENSE" } |
52 | | - ?: throw GradleException("Could not find META-INF/LICENSE in FastCSV dependency JAR") |
53 | | - |
54 | | - zipFile.getInputStream(licenseEntry).use { input -> |
55 | | - file.outputStream().use { output -> |
56 | | - input.copyTo(output) |
57 | | - } |
58 | | - } |
| 42 | + val extractFastCSVLicense by registering(Sync::class) { |
| 43 | + from(zipTree(project.configurations.shadowedClasspath.map { it.files.single { file -> file.name.contains("fastcsv") } })) { |
| 44 | + include("META-INF/LICENSE") |
59 | 45 | } |
| 46 | + into(layout.buildDirectory.dir("fastcsv")) |
60 | 47 | } |
61 | 48 | shadowJar { |
62 | 49 | val tempLicenseFile = projectDir.resolve("LICENSE-fastcsv") |
63 | 50 |
|
64 | | - doFirst { |
65 | | - copyFastCsvLicenseTo(tempLicenseFile, configurations) |
66 | | - } |
67 | | - |
68 | 51 | relocate("de.siegmar.fastcsv", "org.junit.jupiter.params.shadow.de.siegmar.fastcsv") |
69 | 52 |
|
70 | 53 | from(projectDir) { |
71 | 54 | include(tempLicenseFile.name) |
72 | 55 | into("META-INF") |
73 | 56 | } |
74 | 57 |
|
75 | | - doLast { |
76 | | - if (tempLicenseFile.exists()) { |
77 | | - tempLicenseFile.delete() |
78 | | - } |
| 58 | + from(extractFastCSVLicense.map { it.destinationDir }) { |
| 59 | + rename { "LICENSE-fastcsv" } |
79 | 60 | } |
80 | 61 | } |
81 | 62 | compileJava { |
|
0 commit comments