12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- import org.gradle.api.file.ArchiveOperations
- apply plugin: 'elasticsearch.java'
- sourceSets {
- patcher
- }
- configurations {
- thejar {
- canBeResolved = true
- }
- }
- dependencies {
- thejar("org.apache.hadoop:hadoop-client-api:${project.parent.versions.hadoop}") {
- transitive = false
- }
- patcherImplementation 'org.ow2.asm:asm:9.7.1'
- patcherImplementation 'org.ow2.asm:asm-tree:9.7.1'
- }
- def outputDir = layout.buildDirectory.dir("patched-classes")
- def patchTask = tasks.register("patchClasses", JavaExec) {
- inputs.files(configurations.thejar).withPathSensitivity(PathSensitivity.RELATIVE)
- inputs.files(sourceSets.patcher.output).withPathSensitivity(PathSensitivity.RELATIVE)
- outputs.dir(outputDir)
- classpath = sourceSets.patcher.runtimeClasspath
- mainClass = 'org.elasticsearch.hdfs.patch.HdfsClassPatcher'
- def thejar = configurations.thejar
- doFirst {
- args(thejar.singleFile, outputDir.get().asFile)
- }
- }
- interface InjectedArchiveOps {
- @Inject ArchiveOperations getArchiveOperations()
- }
- tasks.named('jar').configure {
- dependsOn(configurations.thejar)
- def injected = project.objects.newInstance(InjectedArchiveOps)
- def thejar = configurations.thejar
- from(patchTask)
- from({ injected.getArchiveOperations().zipTree(thejar.singleFile) }) {
- eachFile {
- if (outputDir.get().file(it.relativePath.pathString).asFile.exists()) {
- it.exclude()
- }
- }
- }
- }
|