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

Filter by extension

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 NOTICE.TXT
Original file line number Diff line number Diff line change
Expand Up @@ -4276,7 +4276,7 @@ http://www.apache.org/licenses/LICENSE-2.0
See the License for the specific language governing permissions and
limitations under the License.
==========
Notice for: com.google.googlejavaformat:google-java-format-1.22.0
Notice for: com.google.googlejavaformat:google-java-format-1.25.2
----------

Copyright 2015 Google Inc.
Expand Down
42 changes: 25 additions & 17 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

buildscript {
ext {
shadowGradlePluginVersion = '8.1.1'
shadowGradlePluginVersion = '9.2.2'
}

repositories {
Expand Down Expand Up @@ -194,15 +194,15 @@ tasks.register("configureArtifactInfo") {
}
}

tasks.register("markAliasDefinitions", SignAliasDefinitions) {
def markAliasDefinitions = tasks.register("markAliasDefinitions", SignAliasDefinitions) {
description = "Create an hashes aliases file from original aliases yml definition"
hashedFile = project.file("${project.buildDir}/plugin_aliases_hashed.yml")
hashedFile.set(layout.buildDirectory.file("plugin_aliases_hashed.yml"))
}

tasks.register("markTestAliasDefinitions", SignAliasDefinitions) {
def markTestAliasDefinitions = tasks.register("markTestAliasDefinitions", SignAliasDefinitions) {
description = "Create an hashes aliases file for testing aliases yml definition"
stage SignAliasDefinitions.Stage.test
hashedFile = project.file("${project.buildDir}/plugin_aliases_hashed_test.yml")
hashedFile.set(layout.buildDirectory.file("plugin_aliases_hashed_test.yml"))
}

tasks.register("copyPluginAlias", Copy) {
Expand All @@ -212,23 +212,27 @@ tasks.register("copyPluginAlias", Copy) {

tasks.register("copyPluginAlias_ruby", Copy) {
description = "Copy the marked plugin_aliases.yml file to destination folders"
dependsOn "markAliasDefinitions"
dependsOn markAliasDefinitions

inputs.file("${buildDir}/plugin_aliases_hashed.yml")
def hashedFileProvider = markAliasDefinitions.flatMap { it.hashedFile }

from(markAliasDefinitions.hashedFile) {
inputs.file(hashedFileProvider)

from(hashedFileProvider) {
rename "plugin_aliases_hashed.yml", "plugin_aliases.yml"
}
into "lib/pluginmanager/"
}

tasks.register("copyPluginAlias_java", Copy) {
description = "Copy the marked plugin_aliases.yml file to destination folders"
dependsOn "markAliasDefinitions"
dependsOn markAliasDefinitions

def hashedFileProvider = markAliasDefinitions.flatMap { it.hashedFile }

inputs.file("${buildDir}/plugin_aliases_hashed.yml")
inputs.file(hashedFileProvider)

from(markAliasDefinitions.hashedFile) {
from(hashedFileProvider) {
rename "plugin_aliases_hashed.yml", "plugin_aliases.yml"
}
into "logstash-core/src/main/resources/org/logstash/plugins/"
Expand All @@ -241,23 +245,27 @@ tasks.register("copyPluginTestAlias") {

tasks.register("copyPluginTestAlias_ruby", Copy) {
description = "Copy the marked test plugin_aliases.yml file into Ruby's plugin_manager specs"
dependsOn "markTestAliasDefinitions"
dependsOn markTestAliasDefinitions

inputs.file(markTestAliasDefinitions.hashedFile)
def hashedTestFileProvider = markTestAliasDefinitions.flatMap { it.hashedFile }

from(markTestAliasDefinitions.hashedFile) {
inputs.file(hashedTestFileProvider)

from(hashedTestFileProvider) {
rename "plugin_aliases_hashed_test.yml", "plugin_aliases.yml"
}
into "spec/unit/plugin_manager/"
}

tasks.register("copyPluginTestAlias_java", Copy) {
description = "Copy the marked test plugin_aliases.yml file into logstash-core's test resources"
dependsOn "markTestAliasDefinitions"
dependsOn markTestAliasDefinitions

def hashedTestFileProvider = markTestAliasDefinitions.flatMap { it.hashedFile }

inputs.file("${buildDir}/plugin_aliases_hashed_test.yml")
inputs.file(hashedTestFileProvider)

from(markTestAliasDefinitions.hashedFile) {
from(hashedTestFileProvider) {
rename "plugin_aliases_hashed_test.yml", "plugin_aliases.yml"
}
into "logstash-core/src/test/resources/org/logstash/plugins/"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,51 +1,69 @@
package org.logstash.gradle.tooling

import org.gradle.api.DefaultTask
import org.gradle.api.file.ProjectLayout
import org.gradle.api.file.RegularFileProperty
import org.gradle.api.provider.Property
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.InputFile
import org.gradle.api.tasks.OutputFile
import org.gradle.api.tasks.PathSensitive
import org.gradle.api.tasks.PathSensitivity
import org.gradle.api.tasks.TaskAction

import javax.inject.Inject

abstract class SignAliasDefinitions extends DefaultTask {

enum Stage {
main, test;
}

private final ProjectLayout projectLayout

@Inject
SignAliasDefinitions(ProjectLayout projectLayout) {
this.projectLayout = projectLayout
registry.convention('org/logstash/plugins/AliasRegistry.yml')
stage.convention(Stage.main)
registryFile.convention(registry.zip(stage) { reg, st ->
projectLayout.projectDirectory.file("logstash-core/src/${st}/resources/${reg}")
})
}

/**
* Relative path to the AliasRegistry.yml file to use, relative to project's root
* */
* Relative path to the AliasRegistry.yml file to use, relative to project's root.
*/
@Input
abstract Property<String> getRegistry()

@Input
String registry = 'org/logstash/plugins/AliasRegistry.yml'
abstract Property<Stage> getStage()

@InputFile
File getRegistryFullPath() {
String stagedRegistry = "logstash-core/src/${stage}/resources/${registry}"
project.file("${project.projectDir}/${stagedRegistry}")
}
@PathSensitive(PathSensitivity.RELATIVE)
abstract RegularFileProperty getRegistryFile()

/**
* Full file path to the file containing the marked AliasRegistry file
* */
@OutputFile
File hashedFile

private Stage stage = Stage.main
abstract RegularFileProperty getHashedFile()

@TaskAction
def sign() {
String aliasesDefs = registryFullPath.text
void sign() {
Stage stageValue = stage.get()
String registryPath = registry.get()
String stagedRegistry = "logstash-core/src/${stageValue}/resources/${registryPath}"
String aliasesDefs = registryFile.get().asFile.text
String hash = aliasesDefs.digest('SHA-256')
String stagedRegistry = "logstash-core/src/${stage}/resources/${registry}"
hashedFile.withWriter('utf-8') { writer ->
hashedFile.get().asFile.withWriter('utf-8') { writer ->
writer.writeLine "#CHECKSUM: ${hash}"
writer.writeLine "# DON'T EDIT THIS FILE, PLEASE REFER TO ${stagedRegistry}"
writer.write aliasesDefs
}
}

SignAliasDefinitions stage(Stage stage) {
this.stage = stage
this.stage.set(stage)
return this
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ class SignAliasDefinitionsTest {

def task = project.task("signerTask", type: SignAliasDefinitions) {
stage SignAliasDefinitions.Stage.test
registry = "ToSign.yml"
hashedFile = project.file("${project.buildDir}/hashed_output.yml")
registry.set("ToSign.yml")
hashedFile.set(project.layout.buildDirectory.file("hashed_output.yml"))
}

// Exercise
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.1.0-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
5 changes: 1 addition & 4 deletions gradlew
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh

#
# Copyright © 2015-2021 the original authors.
# Copyright © 2015 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -114,7 +114,6 @@ case "$( uname )" in #(
NONSTOP* ) nonstop=true ;;
esac

CLASSPATH="\\\"\\\""


# Determine the Java command to use to start the JVM.
Expand Down Expand Up @@ -172,7 +171,6 @@ fi
# For Cygwin or MSYS, switch paths to Windows format before running java
if "$cygwin" || "$msys" ; then
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )

JAVACMD=$( cygpath --unix "$JAVACMD" )

Expand Down Expand Up @@ -212,7 +210,6 @@ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
"$@"

Expand Down
3 changes: 1 addition & 2 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,10 @@ goto fail
:execute
@rem Setup the command line

set CLASSPATH=


@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*

:end
@rem End local scope for the variables with windows NT shell
Expand Down
4 changes: 2 additions & 2 deletions logstash-core/benchmarks/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ buildscript {
gradlePluginPortal()
}
dependencies {
classpath "com.github.johnrengelman:shadow:${shadowGradlePluginVersion}"
classpath "com.gradleup.shadow:shadow-gradle-plugin:${shadowGradlePluginVersion}"
}
}

Expand Down Expand Up @@ -63,7 +63,7 @@ javadoc {
enabled = false
}

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

shadowJar {
archiveBaseName = 'logstash-core-benchmarks-all'
Expand Down
12 changes: 6 additions & 6 deletions logstash-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,9 @@ dependencies {
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}"
implementation group: 'org.yaml', name: 'snakeyaml', version: '2.2'
implementation group: 'com.google.guava', name: 'guava', version: '33.1.0-jre'
implementation('com.google.googlejavaformat:google-java-format:1.22.0') {
implementation 'org.yaml:snakeyaml:2.2'
implementation 'com.google.guava:guava:33.1.0-jre'
implementation('com.google.googlejavaformat:google-java-format:1.25.2') {
exclude group: 'com.google.guava', module: 'guava'
}
implementation 'org.javassist:javassist:3.30.2-GA'
Expand All @@ -258,7 +258,7 @@ dependencies {
testImplementation 'org.assertj:assertj-core:3.11.1'
testImplementation 'org.awaitility:awaitility:4.2.0'

api group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.14'
api group: 'commons-codec', name: 'commons-codec', version: '1.17.0'
api group: 'org.apache.httpcomponents', name: 'httpcore', version: '4.4.16'
api 'org.apache.httpcomponents:httpclient:4.5.14'
api 'commons-codec:commons-codec:1.17.0'
api 'org.apache.httpcomponents:httpcore:4.4.16'
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ public ByteBufferCleanerImpl() {
Field unsafeField = Unsafe.class.getDeclaredField("theUnsafe");
unsafeField.setAccessible(true);
unsafe = (Unsafe) unsafeField.get(null);
}catch (Exception e){
} catch (Exception e) {
throw new IllegalStateException(e);
}
}

@Override
@SuppressWarnings("removal")
public void clean(MappedByteBuffer buffer) {
unsafe.invokeCleaner(buffer);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.codehaus.commons.compiler.CompileException;
import org.codehaus.janino.Scanner;
import org.codehaus.commons.compiler.ISimpleCompiler;
Expand Down Expand Up @@ -73,6 +75,8 @@ public final class ComputeStepSyntaxElement<T extends Dataset> {

private static final Pattern CLASS_NAME_PLACEHOLDER_REGEX = Pattern.compile(CLASS_NAME_PLACEHOLDER);

private static final Logger LOGGER = LogManager.getLogger(ComputeStepSyntaxElement.class);

private final Iterable<MethodSyntaxElement> methods;

private final ClassFields fields;
Expand Down Expand Up @@ -170,23 +174,25 @@ public boolean equals(final Object other) {
}

private String generateCode(final String name) {
try {
return REDUNDANT_SEMICOLON.matcher(new Formatter().formatSource(
String.format(
"package org.logstash.generated;\npublic final class %s extends org.logstash.config.ir.compiler.BaseDataset implements %s { %s }",
name,
type.getName(),
SyntaxFactory.join(
fields.inlineAssigned().generateCode(), fieldsAndCtor(name),
combine(
StreamSupport.stream(methods.spliterator(), false)
.toArray(SyntaxElement[]::new)
)
)
final String rawSource = String.format(
"package org.logstash.generated;\npublic final class %s extends org.logstash.config.ir.compiler.BaseDataset implements %s { %s }",
name,
type.getName(),
SyntaxFactory.join(
fields.inlineAssigned().generateCode(), fieldsAndCtor(name),
combine(
StreamSupport.stream(methods.spliterator(), false)
.toArray(SyntaxElement[]::new)
)
)).replaceAll("\n");
} catch (final FormatterException ex) {
throw new IllegalStateException(ex);
)
);

try {
final String formatted = new Formatter().formatSource(rawSource);
return REDUNDANT_SEMICOLON.matcher(formatted).replaceAll("\n");
} catch (final FormatterException | LinkageError ex) {
LOGGER.warn("Failed to format generated pipeline class with google-java-format; continuing with unformatted code", ex);
return REDUNDANT_SEMICOLON.matcher(rawSource).replaceAll("\n");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

@SuppressWarnings("try")
/**
* Used by Ruby's JavaPipeline
* */
* Used by Ruby's JavaPipeline.
*/
@SuppressWarnings("try")
public final class PeriodicFlush implements AutoCloseable {

private static final Logger LOGGER = LogManager.getLogger(PeriodicFlush.class);
Expand Down
Loading
Loading