Files
HMCL/minecraft/libraries/log4j-patch/build.gradle

53 lines
1.0 KiB
Groovy
Raw Normal View History

2021-12-18 10:38:05 +08:00
version '1.0'
2021-12-19 12:59:46 +08:00
sourceSets.create("agent") {
java {
srcDir 'src/main/agent'
}
}
2021-12-18 10:38:05 +08:00
dependencies {
compileOnly group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.0-beta9'
}
2021-12-19 12:59:46 +08:00
tasks.withType(JavaCompile) {
2021-12-18 10:38:05 +08:00
sourceCompatibility = 8
targetCompatibility = 8
doLast {
2021-12-19 12:59:46 +08:00
FileTree tree = fileTree('build/classes/java')
2021-12-18 10:38:05 +08:00
tree.include '**/*.class'
tree.each {
RandomAccessFile rf = new RandomAccessFile(it, "rw")
rf.seek(7) // major version
rf.write(50) // java 6
rf.close()
}
}
}
2021-12-19 12:59:46 +08:00
task agentJar(type: Jar) {
2021-12-18 10:38:05 +08:00
dependsOn(tasks.compileJava)
2021-12-19 12:59:46 +08:00
baseName = 'log4j-patch-agent'
2021-12-18 10:38:05 +08:00
2021-12-19 12:59:46 +08:00
manifest {
attributes 'Premain-Class': 'org.glavo.log4j.patch.agent.Log4jAgent'
2021-12-18 10:38:05 +08:00
}
2021-12-19 12:59:46 +08:00
from(sourceSets.agent.output)
2021-12-18 10:38:05 +08:00
from(sourceSets.main.output) {
2021-12-19 12:59:46 +08:00
includeEmptyDirs = false
eachFile {
it.path = "org/glavo/log4j/patch/agent/${it.name}.bin"
}
2021-12-18 10:38:05 +08:00
}
}
tasks.jar {
enabled = false
2021-12-19 12:59:46 +08:00
dependsOn agentJar
2021-12-18 11:15:10 +08:00
}
2021-12-19 12:59:46 +08:00