Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove google java formatter dependency #11765

Closed
wants to merge 3 commits into from
Closed
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
6 changes: 0 additions & 6 deletions logstash-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,6 @@ dependencies {
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') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that it's use for code formatting in debug mode of Janino, we should keep it and update to version 1.13 which still require Java 11 and is In Apache License

exclude group: 'com.google.guava', module: 'guava'
}
implementation 'org.javassist:javassist:3.26.0-GA'
testImplementation "org.apache.logging.log4j:log4j-core:${log4jVersion}:tests"
testImplementation 'org.hamcrest:hamcrest:2.2'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
package org.logstash.config.ir.compiler;

import com.google.common.annotations.VisibleForTesting;
import com.google.googlejavaformat.java.Formatter;
import com.google.googlejavaformat.java.FormatterException;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.nio.charset.StandardCharsets;
Expand Down Expand Up @@ -63,12 +61,6 @@ public final class ComputeStepSyntaxElement<T extends Dataset> {

private static final AtomicLong DATASET_CLASS_INDEX = new AtomicLong(0);

/**
* Pattern to remove redundant {@code ;} from formatted code since {@link Formatter} does not
* remove those.
*/
private static final Pattern REDUNDANT_SEMICOLON = Pattern.compile("\n[ ]*;\n");

private static final String CLASS_NAME_PLACEHOLDER = "CLASS_NAME_PLACEHOLDER";

private static final Pattern CLASS_NAME_PLACEHOLDER_REGEX = Pattern.compile(CLASS_NAME_PLACEHOLDER);
Expand Down Expand Up @@ -170,24 +162,17 @@ 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)
)
return 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);
}
));
}

private static Path debugDir() {
Expand Down