mirror of
https://github.com/elastic/logstash.git
synced 2025-04-24 22:57:16 -04:00
Refactor: move PipelineConfig from Ruby to Java Reimplement the Ruby class PipelinceConfig in Java trying to keep the method signatures to limit the changes in client code, this is a step of other that intend to move all the configuration code in Java language. Having all that code in Java unlock some reasoning about how to better implement it and probably an improvement in performance during process startup. Moved also the spec into a JUnit and fixed here and there the failing tests Closes: #11824
192 lines
7 KiB
Groovy
192 lines
7 KiB
Groovy
/*
|
|
* Licensed to Elasticsearch B.V. under one or more contributor
|
|
* license agreements. See the NOTICE file distributed with
|
|
* this work for additional information regarding copyright
|
|
* ownership. Elasticsearch B.V. licenses this file to you under
|
|
* the Apache License, Version 2.0 (the "License"); you may
|
|
* not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing,
|
|
* software distributed under the License is distributed on an
|
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
* KIND, either express or implied. See the License for the
|
|
* specific language governing permissions and limitations
|
|
* under the License.
|
|
*/
|
|
|
|
import java.nio.file.Files
|
|
import java.nio.file.Paths
|
|
import org.yaml.snakeyaml.Yaml
|
|
|
|
// fetch version from Logstash's master versions.yml file
|
|
def versionMap = (Map) (new Yaml()).load(new File("$projectDir/../versions.yml").text)
|
|
|
|
description = """Logstash Core Java"""
|
|
version = versionMap['logstash-core']
|
|
String jrubyVersion = versionMap['jruby']['version']
|
|
String jacksonVersion = versionMap['jackson']
|
|
String jacksonDatabindVersion = versionMap['jackson-databind']
|
|
|
|
repositories {
|
|
mavenCentral()
|
|
}
|
|
|
|
buildscript {
|
|
repositories {
|
|
mavenCentral()
|
|
}
|
|
dependencies {
|
|
classpath 'org.yaml:snakeyaml:1.17'
|
|
}
|
|
}
|
|
|
|
tasks.register("sourcesJar", Jar) {
|
|
dependsOn classes
|
|
from sourceSets.main.allSource
|
|
archiveClassifier = 'sources'
|
|
archiveExtension = 'jar'
|
|
}
|
|
|
|
tasks.register("javadocJar", Jar) {
|
|
dependsOn javadoc
|
|
from javadoc.destinationDir
|
|
archiveClassifier = 'javadoc'
|
|
archiveExtension = 'jar'
|
|
}
|
|
|
|
tasks.register("copyRuntimeLibs", Copy) {
|
|
into project.file('lib/jars/')
|
|
from configurations.compileClasspath, configurations.runtimeClasspath
|
|
}
|
|
|
|
// copy jar file into the gem lib dir but without the version number in filename
|
|
tasks.register("copyGemjar", Copy) {
|
|
dependsOn=[sourcesJar, copyRuntimeLibs]
|
|
from project.jar
|
|
into project.file('lib/jars/')
|
|
rename(/(.+)-${project.version}.jar/, '$1.jar')
|
|
}
|
|
|
|
tasks.register("cleanGemjar") {
|
|
delete fileTree(project.file('lib/jars/')) {
|
|
include '*.jar'
|
|
}
|
|
}
|
|
|
|
clean.dependsOn(cleanGemjar)
|
|
jar.finalizedBy(copyGemjar)
|
|
assemble.dependsOn(copyGemjar)
|
|
|
|
configurations.create('sources')
|
|
configurations.create('javadoc')
|
|
configurations.archives {
|
|
extendsFrom configurations.sources
|
|
extendsFrom configurations.javadoc
|
|
}
|
|
|
|
tasks.register("javaTests", Test) {
|
|
exclude '/org/logstash/RSpecTests.class'
|
|
exclude '/org/logstash/config/ir/ConfigCompilerTest.class'
|
|
exclude '/org/logstash/config/ir/CompiledPipelineTest.class'
|
|
exclude '/org/logstash/config/ir/EventConditionTest.class'
|
|
exclude '/org/logstash/config/ir/PipelineConfigTest.class'
|
|
exclude '/org/logstash/config/ir/compiler/OutputDelegatorTest.class'
|
|
exclude '/org/logstash/config/ir/compiler/JavaCodecDelegatorTest.class'
|
|
exclude '/org/logstash/plugins/NamespacedMetricImplTest.class'
|
|
exclude '/org/logstash/plugins/CounterMetricImplTest.class'
|
|
exclude '/org/logstash/plugins/PluginFactoryExtTest.class'
|
|
}
|
|
|
|
tasks.register("rubyTests", Test) {
|
|
inputs.files fileTree("${projectDir}/lib")
|
|
inputs.files fileTree("${projectDir}/spec")
|
|
systemProperty 'logstash.core.root.dir', projectDir.absolutePath
|
|
include '/org/logstash/RSpecTests.class'
|
|
include '/org/logstash/config/ir/ConfigCompilerTest.class'
|
|
include '/org/logstash/config/ir/CompiledPipelineTest.class'
|
|
include '/org/logstash/config/ir/EventConditionTest.class'
|
|
include '/org/logstash/config/ir/PipelineConfigTest.class'
|
|
include '/org/logstash/config/ir/compiler/OutputDelegatorTest.class'
|
|
include '/org/logstash/config/ir/compiler/JavaCodecDelegatorTest.class'
|
|
include '/org/logstash/plugins/NamespacedMetricImplTest.class'
|
|
include '/org/logstash/plugins/CounterMetricImplTest.class'
|
|
include '/org/logstash/plugins/PluginFactoryExtTest.class'
|
|
}
|
|
|
|
test {
|
|
exclude '/**'
|
|
}
|
|
test.dependsOn javaTests, rubyTests
|
|
|
|
artifacts {
|
|
sources(sourcesJar) {
|
|
// Weird Gradle quirk where type will be used for the extension, but only for sources
|
|
type 'jar'
|
|
}
|
|
javadoc(javadocJar) {
|
|
type 'javadoc'
|
|
}
|
|
}
|
|
|
|
configurations {
|
|
provided
|
|
}
|
|
|
|
project.sourceSets {
|
|
main.compileClasspath += project.configurations.provided
|
|
main.runtimeClasspath += project.configurations.provided
|
|
test.compileClasspath += project.configurations.provided
|
|
test.runtimeClasspath += project.configurations.provided
|
|
}
|
|
project.javadoc.classpath += project.configurations.provided
|
|
|
|
idea {
|
|
module {
|
|
scopes.PROVIDED.plus += [project.configurations.provided]
|
|
}
|
|
}
|
|
|
|
def customJRubyDir = project.hasProperty("custom.jruby.path") ? project.property("custom.jruby.path") : ""
|
|
def customJRubyVersion = customJRubyDir == "" ? "" : Files.readAllLines(Paths.get(customJRubyDir, "VERSION")).get(0).trim()
|
|
|
|
dependencies {
|
|
implementation 'org.apache.logging.log4j:log4j-api:2.13.3'
|
|
annotationProcessor 'org.apache.logging.log4j:log4j-core:2.13.3'
|
|
api 'org.apache.logging.log4j:log4j-core:2.13.3'
|
|
runtimeOnly 'org.apache.logging.log4j:log4j-slf4j-impl:2.13.3'
|
|
// concerns libraries such as manticore's http-client 4.5 (using commons-logging)
|
|
runtimeOnly 'org.apache.logging.log4j:log4j-jcl:2.13.3'
|
|
// for the log4j-jcl bridge to work commons-logging needs to be on the same class-path
|
|
runtimeOnly 'commons-logging:commons-logging:1.2'
|
|
implementation('org.reflections:reflections:0.9.11') {
|
|
exclude group: 'com.google.guava', module: 'guava'
|
|
}
|
|
implementation 'commons-codec:commons-codec:1.14'
|
|
// Jackson version moved to versions.yml in the project root (the JrJackson version is there too)
|
|
implementation "com.fasterxml.jackson.core:jackson-core:${jacksonVersion}"
|
|
api "com.fasterxml.jackson.core:jackson-databind:${jacksonDatabindVersion}"
|
|
api "com.fasterxml.jackson.core:jackson-annotations:${jacksonVersion}"
|
|
implementation 'org.codehaus.janino:janino:3.1.0'
|
|
implementation "com.fasterxml.jackson.dataformat:jackson-dataformat-cbor:${jacksonVersion}"
|
|
if (customJRubyDir == "") {
|
|
api "org.jruby:jruby-complete:${jrubyVersion}"
|
|
} else {
|
|
api files(customJRubyDir + "/maven/jruby-complete/target/jruby-complete-${customJRubyVersion}.jar")
|
|
}
|
|
implementation group: 'com.google.guava', name: 'guava', version: '24.1.1-jre'
|
|
// WARNING: DO NOT UPGRADE "google-java-format"
|
|
// later versions require GPL licensed code in javac-shaded that is
|
|
// Apache2 incompatible
|
|
implementation('com.google.googlejavaformat:google-java-format:1.1') {
|
|
exclude group: 'com.google.guava', module: 'guava'
|
|
}
|
|
implementation 'org.javassist:javassist:3.26.0-GA'
|
|
testImplementation 'org.apache.logging.log4j:log4j-core:2.13.3:tests'
|
|
testImplementation 'junit:junit:4.12'
|
|
testImplementation 'net.javacrumbs.json-unit:json-unit:2.3.0'
|
|
testImplementation 'org.elasticsearch:securemock:1.2'
|
|
testImplementation 'org.assertj:assertj-core:3.11.1'
|
|
}
|