Skip to content

Commit

Permalink
Build: skip shadowing jar dependencies (logstash-plugins#187)
Browse files Browse the repository at this point in the history
  • Loading branch information
kares authored Feb 1, 2022
1 parent f60633f commit 038acbe
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 22 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
*.gem
Gemfile.lock
.bundle
vendor
.idea
Expand All @@ -10,4 +9,5 @@ build
*.ipr
out
.rakeTasks

Gemfile.lock
lib/logstash-input-beats_jars.rb
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
## 6.2.7
- Build: skip shadowing jar dependencies [#187](https://github.com/logstash-plugins/logstash-input-tcp/pull/187)
* plugin no longer shadows dependencies into its *logstash-input-tcp.jar*
* log4j-api is now a provided dependency and is no longer packaged with the plugin

## 6.2.6
- [DOC] Fix incorrect pipeline code snippet [#194](https://github.com/logstash-plugins/logstash-input-tcp/pull/194)
- Update log4j dependency to 2.17.1 [#196](https://github.com/logstash-plugins/logstash-input-tcp/pull/196)

## 6.2.5
- Update log4j dependency to 2.17.0

Expand Down
41 changes: 27 additions & 14 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,39 +34,52 @@ buildscript {
mavenCentral()
gradlePluginPortal()
}

dependencies {
classpath 'gradle.plugin.com.github.jengelman.gradle.plugins:shadow:7.0.0'
}
}

repositories {
mavenCentral()
}

apply plugin: 'com.github.johnrengelman.shadow'

shadowJar {
classifier = null
}

dependencies {
testImplementation 'org.apache.logging.log4j:log4j-core:2.17.1'

implementation 'io.netty:netty-all:4.1.65.Final'
implementation group: 'commons-io', name: 'commons-io', version: '2.8.0' // used from Netty
implementation 'org.apache.logging.log4j:log4j-api:2.17.1'

compileOnly 'org.apache.logging.log4j:log4j-api:2.17.1' // provided by Logstash
compileOnly group: 'org.jruby', name: 'jruby-complete', version: "9.1.13.0" // provided by Logstash
// 1.60 effectively means jruby-openssl >= 0.10.2 (logstash > 6.7)
compileOnly group: 'org.bouncycastle', name: 'bcpkix-jdk15on', version: "1.60"
compileOnly group: 'org.bouncycastle', name: 'bcpkix-jdk15on', version: "1.60" // provided by Logstash (JRuby-OpenSSL)
}

task vendor(dependsOn: shadowJar) {
task generateGemJarRequiresFile {
doLast {
File jars_file = file('lib/logstash-input-tcp_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 << "\nrequire_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)
}
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)
}
}

vendor.dependsOn(jar, generateGemJarRequiresFile)
4 changes: 0 additions & 4 deletions lib/logstash-input-tcp_jars.rb

This file was deleted.

2 changes: 1 addition & 1 deletion version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6.2.6
6.2.7

0 comments on commit 038acbe

Please sign in to comment.