Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ vendor
build/*
.ci/*
.gradle/*
lib/logstash-input-http_jars.rb
logstash-input-http.iml
lib/logstash-input-http_jars.rb
63 changes: 36 additions & 27 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,17 @@ repositories {
}

dependencies {
testImplementation "org.junit.jupiter:junit-jupiter-api:${junitVersion}"
// netty-codec-http pulls netty-handler, which pulls netty-buffer, netty-codec, netty-common,
// netty-transport, netty-transport-native-unix-common, and netty-resolver as transitive dependencies
implementation "io.netty:netty-codec-http:${nettyVersion}"

compileOnly "org.apache.logging.log4j:log4j-api:${log4jVersion}" // provided by Logstash

testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:${junitVersion}"
testImplementation "org.junit.jupiter:junit-jupiter-api:${junitVersion}"
testImplementation 'org.hamcrest:hamcrest-library:2.2'
testImplementation "org.apache.logging.log4j:log4j-core:${log4jVersion}"
testImplementation 'org.mockito:mockito-core:5.12.0'

implementation "io.netty:netty-buffer:${nettyVersion}"
implementation "io.netty:netty-codec:${nettyVersion}"
implementation "io.netty:netty-codec-http:${nettyVersion}"
implementation "io.netty:netty-common:${nettyVersion}"
implementation "io.netty:netty-transport:${nettyVersion}"
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
compileOnly "org.apache.logging.log4j:log4j-api:${log4jVersion}" // provided by Logstash
}

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

task generateGemJarRequiresFile {
doLast {
File jars_file = file('lib/logstash-input-http_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-http_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