Skip to content
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ build/
*.iws
log4j2.xml_bk
Gemfile.lock
lib/logstash-input-beats_jars.rb
lib/logstash-input-beats_jars.rb
69 changes: 38 additions & 31 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,20 @@ repositories {
}

dependencies {
testImplementation 'junit:junit:4.12'
testImplementation 'org.hamcrest:hamcrest-library:1.3'
testImplementation 'org.apache.logging.log4j:log4j-core:2.17.0'
implementation "io.netty:netty-buffer:${nettyVersion}"
implementation "io.netty:netty-codec:${nettyVersion}"
implementation "io.netty:netty-common:${nettyVersion}"
implementation "io.netty:netty-transport:${nettyVersion}"
// netty-handler pulls netty-buffer, netty-codec, netty-common, netty-transport,
// netty-transport-native-unix-common, and netty-resolver as transitive dependencies
implementation "io.netty:netty-handler:${nettyVersion}"
implementation "io.netty:netty-transport-native-unix-common:${nettyVersion}" // this is needed from Netty 4.1.78.Final on
implementation 'org.javassist:javassist:3.24.0-GA'
testImplementation "com.fasterxml.jackson.core:jackson-core:${jacksonVersion}"
testImplementation "com.fasterxml.jackson.core:jackson-annotations:${jacksonVersion}"
testImplementation "com.fasterxml.jackson.core:jackson-databind:${jacksonDatabindVersion}"
testImplementation "com.fasterxml.jackson.module:jackson-module-afterburner:${jacksonVersion}"

compileOnly "com.fasterxml.jackson.core:jackson-core:${jacksonVersion}"
compileOnly "com.fasterxml.jackson.core:jackson-annotations:${jacksonVersion}"
compileOnly "com.fasterxml.jackson.core:jackson-databind:${jacksonDatabindVersion}"
compileOnly "com.fasterxml.jackson.module:jackson-module-afterburner:${jacksonVersion}"
compileOnly 'org.apache.logging.log4j:log4j-api:2.17.0'

testImplementation "com.fasterxml.jackson.core:jackson-core:${jacksonVersion}"
testImplementation "com.fasterxml.jackson.module:jackson-module-afterburner:${jacksonVersion}"
testImplementation 'junit:junit:4.12'
testImplementation 'org.hamcrest:hamcrest-library:1.3'
testImplementation 'org.apache.logging.log4j:log4j-core:2.17.0'
}

test {
Expand All @@ -70,32 +65,44 @@ task run (type: JavaExec, dependsOn: classes){

task generateGemJarRequiresFile {
doLast {
File jars_file = file('lib/logstash-input-beats_jars.rb')
jars_file.newWriter().withWriter { w ->
w << "# AUTOGENERATED BY THE GRADLE SCRIPT. DO NOT EDIT.\n\n"
w << "require \'jar_dependencies\'\n"
configurations.runtimeClasspath.allDependencies.each {
w << "require_jar(\'${it.group}\', \'${it.name}\', \'${it.version}\')\n"
}
w << "require_jar(\'${project.group}\', \'${project.name}\', \'${project.version}\')\n"
File jars_file = file("lib/logstash-input-beats_jars.rb")
jars_file.newWriter().withWriter { w ->
w << "# AUTOGENERATED BY THE GRADLE SCRIPT. DO NOT EDIT.\n\n"
w << "require \'jar_dependencies\'\n"
configurations.runtimeClasspath.incoming.artifacts.artifacts.each { artifact ->
def id = artifact.id.componentIdentifier
if (id instanceof org.gradle.api.artifacts.component.ModuleComponentIdentifier) {
w << "require_jar(\'${id.group}\', \'${id.module}\', \'${id.version}\')\n"
}
}
w << "require_jar(\'${project.group}\', \'${project.name}\', \'${project.version}\')\n"
}
}
}

task vendor {
doLast {
String vendorPathPrefix = "vendor/jar-dependencies"
configurations.runtimeClasspath.allDependencies.each { dep ->
File f = configurations.runtimeClasspath.filter { it.absolutePath.contains("${dep.group}/${dep.name}/${dep.version}") }.singleFile
String groupPath = dep.group.replaceAll('\\.', '/')
File newJarFile = file("${vendorPathPrefix}/${groupPath}/${dep.name}/${dep.version}/${dep.name}-${dep.version}.jar")
newJarFile.mkdirs()
Files.copy(f.toPath(), newJarFile.toPath(), REPLACE_EXISTING)
configurations.runtimeClasspath.incoming.artifacts.artifacts.each { artifact ->
def id = artifact.id.componentIdentifier
if (id instanceof org.gradle.api.artifacts.component.ModuleComponentIdentifier) {
String group = id.group
String name = id.module
String version = id.version
String groupPath = group.replaceAll('\\.', '/')
File newJarFile = file("${vendorPathPrefix}/${groupPath}/${name}/${version}/${name}-${version}.jar")
if (!newJarFile.parentFile.exists()) {
newJarFile.parentFile.mkdirs()
}
Files.copy(artifact.file.toPath(), newJarFile.toPath(), REPLACE_EXISTING)
}
}

// Copy the project jar into vendor/jar-dependencies
String projectGroupPath = project.group.replaceAll('\\.', '/')
File projectJarFile = file("${vendorPathPrefix}/${projectGroupPath}/${project.name}/${project.version}/${project.name}-${project.version}.jar")
projectJarFile.mkdirs()
Files.copy(file("$buildDir/libs/${project.name}-${project.version}.jar").toPath(), projectJarFile.toPath(), REPLACE_EXISTING)
File projectJarFile = file("${vendorPathPrefix}/${projectGroupPath}/${project.name}/${project.version}/${project.name}-${project.version}.jar")
projectJarFile.mkdirs()
Files.copy(file("$buildDir/libs/${project.name}-${project.version}.jar").toPath(), projectJarFile.toPath(), REPLACE_EXISTING)
}
}

Expand Down