logstash-plugins/logstash-input-java_input_example

Requires versions.yml

ScottPeterJohnson opened this issue · 5 comments

It seems like recent versions of Logstash (7.4.2) require the presence of a "versions.yml" file found in the Logstash directory to build plugins.

Without it, attempting to build elicits the following cryptic error:

A problem was found with the configuration of task ':downloadJRuby'.
> File '/home/scott/Desktop/logstash_cloudwatch_logs/versions.yml' specified for property '$1' does not exist.

@ScottPeterJohnson, as mentioned in the documentation, building any kind of Java plugin requires a local copy of the Logstash codebase since the Java plugin APIs and some other support files such as Gradle build scripts and the versions.yml file are contained in that project. If you have the Logstash codebase available locally, are you able to build your plugin?

I have it locally and set LOGSTASH_CORE_PATH. If I copy versions.yml to my project it can then build fully.

The problem I assume is that the imported rubyUtils.gradle is looking in the default project directory for versions.yml, so it doesn't find it when imported from the plugin project. Thus it fails to e.g. download JRuby.

@ScottPeterJohnson, thanks for that additional information. I'm trying to reproduce your problem but haven't been successful. If I have the Logstash repo checked out to any of the master, 7.x, or 7.4 branches, I'm able to successfully build the plugin and the Gradle build script looks in the Logstash directory for the versions.yml file. Have you modified anything in the build scripts? Had you been able to build the plugin in previous releases of Logstash? There have been almost no changes to those scripts in the past several releases.

I think I see the issue. I upgraded the bundled gradle in my project to 5.6.2, which translates a warning into an error. If you run ./gradlew downloadJRuby --warning-mode=all under 4.8, you'll see:

> Task :downloadJRuby
A problem was found with the configuration of task ':downloadJRuby'. Registering invalid inputs and outputs via TaskInputs and TaskOutputs methods has been deprecated and is scheduled to be removed in Gradle 5.0.
 - File '/home/scott/Desktop/Projects/logstash_cloudwatch_logs_importer/versions.yml' specified for property '$1' does not exist.

BUILD SUCCESSFUL in 0s

Looking at the definition of downloadJRuby:

task downloadJRuby(type: Download) {
    description "Download JRuby artifact from this specific URL: ${jRubyURL}"
    src jRubyURL
    onlyIfNewer true
    inputs.file("${projectDir}/versions.yml")
    outputs.file(jrubyTarPath)
    dest new File("${projectDir}/vendor/_", "jruby-dist-${jRubyVersion}-bin.tar.gz")
}

The line inputs.file("${projectDir}/versions.yml") should probably read inputs.file("${versionsPath}/versions.yml")

Here's what I'm working on for reference: https://github.com/ScottPeterJohnson/cloudwatch_logs_importer

@ScottPeterJohnson, thank you for the additional detail and your debugging efforts. It does look like you're right about the path for the versions.yml file and I'll open a PR to address that.