Skip to content
Merged
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
41 changes: 32 additions & 9 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,22 @@
* under the License.
*/

import java.nio.charset.StandardCharsets;
import java.io.ByteArrayOutputStream;

import com.avast.gradle.dockercompose.tasks.ComposePull
import com.github.jengelman.gradle.plugins.shadow.ShadowPlugin
import de.thetaphi.forbiddenapis.gradle.ForbiddenApisPlugin
import org.apache.tools.ant.taskdefs.condition.Os
import org.gradle.plugins.ide.eclipse.model.AccessRule
import org.gradle.plugins.ide.eclipse.model.SourceFolder
import org.opensearch.gradle.BuildPlugin
import org.opensearch.gradle.CheckCompatibilityTask
import org.opensearch.gradle.Version
import org.opensearch.gradle.VersionProperties
import org.opensearch.gradle.info.BuildParams
import org.opensearch.gradle.plugin.PluginBuildPlugin
import org.opensearch.gradle.tar.SymbolicLinkPreservingTar
import org.gradle.plugins.ide.eclipse.model.AccessRule
import org.gradle.plugins.ide.eclipse.model.EclipseJdt
import org.gradle.plugins.ide.eclipse.model.SourceFolder
import org.gradle.api.Project;
import org.gradle.process.ExecResult;
import org.opensearch.gradle.CheckCompatibilityTask

import java.nio.charset.StandardCharsets

import static org.opensearch.gradle.util.GradleUtils.maybeConfigure

Expand All @@ -55,6 +52,7 @@ plugins {
id 'opensearch.docker-support'
id 'opensearch.global-build-info'
id "com.diffplug.spotless" version "6.25.0" apply false
id "org.openrewrite.rewrite" version "7.11.0" apply false
id "org.gradle.test-retry" version "1.6.2" apply false
id "test-report-aggregation"
id 'jacoco-report-aggregation'
Expand All @@ -65,6 +63,7 @@ apply from: 'gradle/runtime-jdk-provision.gradle'
apply from: 'gradle/ide.gradle'
apply from: 'gradle/forbidden-dependencies.gradle'
apply from: 'gradle/formatting.gradle'
apply from: 'gradle/rewrite.gradle'
apply from: 'gradle/local-distribution.gradle'
apply from: 'gradle/run.gradle'
apply from: 'gradle/missing-javadoc.gradle'
Expand All @@ -76,7 +75,31 @@ allprojects {
version = VersionProperties.getOpenSearch()
description = "OpenSearch subproject ${project.path}"
}

allprojects {
configurations.configureEach {
resolutionStrategy {
force(
'org.jetbrains:annotations:26.0.2',
'org.apache.commons:commons-text:1.13.1',
'org.ow2.asm:asm:9.8',
'org.ow2.asm:asm-util:9.8',
)
eachDependency { details ->
if (details.requested.group.startsWith('com.fasterxml.jackson')) {
Copy link
Owner Author

Choose a reason for hiding this comment

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

try remove this

details.useVersion '2.17.3'
}
if (details.requested.group == 'org.openrewrite.recipe' &&
details.requested.name == 'rewrite-java-dependencies') {
details.useVersion '1.37.0'
}
if (details.requested.group == 'com.google.errorprone' &&
details.requested.name == 'error_prone_annotations') {
details.useVersion '2.36.0'
}
}
}
}
}
configure(allprojects - project(':distribution:archives:integ-test-zip')) {
project.pluginManager.withPlugin('nebula.maven-base-publish') {
if (project.pluginManager.hasPlugin('opensearch.build') == false) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,22 +142,22 @@ public void applyZipPublicationPluginWithConfig() throws IOException, URISyntaxE
// and how these tasks are chained. The problem is that there is a known gradle issue (#20301) that does
// not allow for it ATM. If, however, it is fixed in the future the following is the code that can
// be used...

Project project = ProjectBuilder.builder().build();
project.getPluginManager().apply(Publish.class);
// add publications via API

// evaluate the project
((DefaultProject)project).evaluate();

// - Check that "validatePluginZipPom" and/or "publishPluginZipPublicationToZipStagingRepository"
// tasks have dependencies on "generatePomFileForNebulaPublication".
// - Check that there is the staging repository added.

// However, due to known issue(1): https://github.com/gradle/gradle/issues/20301
// it is impossible to reach to individual tasks and work with them.
// (1): https://docs.gradle.org/7.4/release-notes.html#known-issues

// I.e.: The following code throws exception, basically any access to individual tasks fails.
project.getTasks().getByName("validatePluginZipPom");
------------------------------- */
Expand Down
1 change: 0 additions & 1 deletion client/sniffer/licenses/jackson-core-2.18.2.jar.sha1

This file was deleted.

2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
org.gradle.caching=true
org.gradle.warning.mode=none
org.gradle.parallel=true
# https://github.com/openrewrite/rewrite-gradle-plugin/issues/212
#org.gradle.workers.max=3
org.gradle.jvmargs=-Xmx3g -XX:+HeapDumpOnOutOfMemoryError -Xss2m \
--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED \
--add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED \
Expand Down
3 changes: 0 additions & 3 deletions gradle/formatting.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ allprojects {
// non-standard places
target '**/*.java'

removeUnusedImports()
importOrder(
'de.thetaphi',
'com.carrotsearch',
Expand All @@ -83,7 +82,6 @@ allprojects {
)

eclipse().withP2Mirrors(Map.of("https://download.eclipse.org/", "https://mirror.umd.edu/eclipse/")).configFile rootProject.file('buildSrc/formatterConfig.xml')
trimTrailingWhitespace()
endWithNewline()

custom 'Refuse wildcard imports', {
Expand All @@ -103,7 +101,6 @@ allprojects {

targetExclude '**/simple-bulk11.json', '**/simple-msearch5.json'

trimTrailingWhitespace()
endWithNewline()
}
}
Expand Down
74 changes: 74 additions & 0 deletions gradle/rewrite.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/

/*
* Licensed to Elasticsearch under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch 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 org.opensearch.gradle.BuildPlugin

/**
* # - org.openrewrite.staticanalysis.ModifierOrder
#
# - org.openrewrite.java.format.RemoveTrailingWhitespace
# - org.openrewrite.java.recipes.JavaRecipeBestPractices
# - org.openrewrite.java.recipes.RecipeNullabilityBestPractices
# - org.openrewrite.java.recipes.RecipeTestingBestPractices
# - org.openrewrite.staticanalysis.EqualsAvoidsNull
# - org.openrewrite.staticanalysis.JavaApiBestPractices
# - org.openrewrite.staticanalysis.MissingOverrideAnnotation
# - org.openrewrite.staticanalysis.RemoveUnusedLocalVariables
# - org.openrewrite.staticanalysis.RemoveUnusedPrivateFields
# - org.openrewrite.staticanalysis.StringLiteralEquality
# - org.openrewrite.staticanalysis.WrappingAndBraces
# - org.openrewrite.text.EndOfLineAtEndOfFile
*/
allprojects {
plugins.withType(BuildPlugin).whenPluginAdded {
project.apply plugin: "org.openrewrite.rewrite"
rewrite {
activeRecipe("org.opensearch.openrewrite.recipe.CodeCleanup")
configFile = file("$rootDir/gradle/rewrite.yml")
exclusions.add("**OpenSearchTestCaseTests.java")
exclusions.add("**AbstractBenchmark.java")
exclusions.add("**ScriptClassPathResolutionContext.java")
exclusions.add("**StarTreeMapper.java")
failOnDryRunResults = true
}
repositories {
mavenCentral()
}
dependencies {
rewrite("org.openrewrite.recipe:rewrite-rewrite:0.9.0")
rewrite("org.openrewrite.recipe:rewrite-static-analysis:2.12.0")
}
tasks {
rewriteDryRun {
dependsOn(check)
}
}
}
}
13 changes: 13 additions & 0 deletions gradle/rewrite.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
type: specs.openrewrite.org/v1beta/recipe
name: org.opensearch.openrewrite.recipe.CodeCleanup
displayName: CodeCleanup
description: Automatically cleanup code, e.g. remove unnecessary parentheses, simplify expressions.
recipeList:
- org.openrewrite.java.RemoveUnusedImports
# - org.openrewrite.staticanalysis.RemoveUnusedPrivateMethods
# - org.openrewrite.java.format.RemoveTrailingWhitespace
# - org.openrewrite.staticanalysis.EmptyBlock
# - org.openrewrite.staticanalysis.RemoveCallsToSystemGc
# - org.openrewrite.staticanalysis.RemoveUnusedLocalVariables
# - org.openrewrite.staticanalysis.RemoveUnusedPrivateFields
# - org.openrewrite.staticanalysis.UnnecessaryThrows
1 change: 0 additions & 1 deletion libs/core/licenses/jackson-core-2.18.2.jar.sha1

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,7 @@ public XContentBuilder utf8Value(byte[] bytes, int offset, int length) throws IO
/**
* Write a time-based field and value, if the passed timeValue is null a
* null value is written, otherwise a date transformers lookup is performed.

* @throws IllegalArgumentException if there is no transformers for the type of object
*/
public XContentBuilder timeField(String name, Object timeValue) throws IOException {
Expand Down Expand Up @@ -772,7 +772,7 @@ public XContentBuilder timeField(String name, String readableName, long value) t
/**
* Write a time-based value, if the value is null a null value is written,
* otherwise a date transformers lookup is performed.

* @throws IllegalArgumentException if there is no transformers for the type of object
*/
public XContentBuilder timeValue(Object timeValue) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,18 +195,18 @@ public DissectParser(String pattern, String appendSeparator) {
*/
public Map<String, String> parse(String inputString) {
/*

This implements a naive string matching algorithm. The string is walked left to right, comparing each byte against
another string's bytes looking for matches. If the bytes match, then a second cursor looks ahead to see if all the bytes
of the other string matches. If they all match, record it and advances the primary cursor to the match point. If it can not match
all of the bytes then progress the main cursor. Repeat till the end of the input string. Since the string being searching for
(the delimiter) is generally small and rare the naive approach is efficient.

In this case the string that is walked is the input string, and the string being searched for is the current delimiter.
For example for a dissect pattern of {@code %{a},%{b}:%{c}} the delimiters (comma then colon) are searched for in the
input string. At class construction the list of keys+delimiters are found (dissectPairs), which allows the use of that ordered
list to know which delimiter to use for the search. The delimiters is progressed once the current delimiter is matched.

There are two special cases that requires additional parsing beyond the standard naive algorithm. Consecutive delimiters should
results in a empty matches unless the {@code ->} is provided. For example given the dissect pattern of
{@code %{a},%{b},%{c},%{d}} and input string of {@code foo,,,} the match should be successful with empty values for b,c and d.
Expand Down
1 change: 0 additions & 1 deletion libs/x-content/licenses/jackson-core-2.18.2.jar.sha1

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion modules/lang-expression/licenses/asm-9.7.jar.sha1

This file was deleted.

1 change: 0 additions & 1 deletion modules/lang-painless/licenses/asm-9.7.jar.sha1

This file was deleted.

1 change: 0 additions & 1 deletion modules/lang-painless/licenses/asm-util-9.7.jar.sha1

This file was deleted.

Loading
Loading