diff --git a/.gitignore b/.gitignore index bfbe4ca..796e580 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,5 @@ lib/jars .ci .gradle .idea -build \ No newline at end of file +build +lib/logstash-input-file_jars.rb \ No newline at end of file diff --git a/build.gradle b/build.gradle index a0d33cb..c208581 100644 --- a/build.gradle +++ b/build.gradle @@ -65,8 +65,11 @@ task generateGemJarRequiresFile { 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" + 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 << "\nrequire_jar(\'${project.group}\', \'${project.name}\', \'${project.version}\')\n" } @@ -76,13 +79,21 @@ task generateGemJarRequiresFile { 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 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()