| 1 |
package junitbuild.exec |
| 2 |
|
| 3 |
import org.gradle.api.DefaultTask |
| 4 |
import org.gradle.api.file.ArchiveOperations |
| 5 |
import org.gradle.api.file.FileSystemOperations |
| 6 |
import org.gradle.api.file.RegularFileProperty |
| 7 |
import org.gradle.api.file.RelativePath |
| 8 |
import org.gradle.api.tasks.CacheableTask |
| 9 |
import org.gradle.api.tasks.Classpath |
| 10 |
import org.gradle.api.tasks.OutputFile |
| 11 |
import org.gradle.api.tasks.TaskAction |
| 12 |
import javax.inject.Inject |
| 13 |
|
| 14 |
@CacheableTask |
| 15 |
abstract class GenerateStandaloneConsoleLauncherShadowedArtifactsFile @Inject constructor( |
| 16 |
private val fileSystem: FileSystemOperations, |
| 17 |
private val archives: ArchiveOperations |
| 18 |
) : DefaultTask() { |
| 19 |
|
| 20 |
@get:Classpath |
| 21 |
abstract val inputJar: RegularFileProperty |
| 22 |
|
| 23 |
@get:OutputFile |
| 24 |
abstract val outputFile: RegularFileProperty |
| 25 |
|
| 26 |
@TaskAction |
| 27 |
fun execute() { |
| 28 |
fileSystem.copy { |
| 29 |
from(archives.zipTree(inputJar)) { |
| 30 |
include("META-INF/shadowed-artifacts") |
| 31 |
includeEmptyDirs = false |
| 32 |
eachFile { |
| 33 |
relativePath = RelativePath(true, outputFile.get().asFile.name) |
| 34 |
} |
| 35 |
filter { line -> "- `${line}`" } |
| 36 |
} |
| 37 |
into(outputFile.get().asFile.parentFile) |
| 38 |
} |
| 39 |
} |
| 40 |
} |