-
Notifications
You must be signed in to change notification settings - Fork 24.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Begin moving XContent to a separate lib/artifact (#29300)
* Begin moving XContent to a separate lib/artifact This commit moves a large portion of the XContent code from the `server` project to the `libs/xcontent` project. For the pieces that have been moved, some helpers have been duplicated to allow them to be decoupled from ES helper classes. In addition, `Booleans` and `CheckedFunction` have been moved to the `elasticsearch-core` project. This decoupling is a move so that we can eventually make things like the high-level REST client not rely on the entire ES jar, only the parts it needs. There are some pieces that are still not decoupled, in particular some of the XContent tests still remain in the server project, this is because they test a large portion of the pluggable xcontent pieces through `XContentElasticsearchException`. They may be decoupled in future work. Additionally, there may be more piecese that we want to move to the xcontent lib in the future that are not part of this PR, this is a starting point. Relates to #28504
- Loading branch information
Showing
56 changed files
with
395 additions
and
176 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
70 changes: 70 additions & 0 deletions
70
libs/elasticsearch-core/src/main/java/org/elasticsearch/common/Glob.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
package org.elasticsearch.common; | ||
|
||
/** | ||
* Utility class for glob-like matching | ||
*/ | ||
public class Glob { | ||
|
||
/** | ||
* Match a String against the given pattern, supporting the following simple | ||
* pattern styles: "xxx*", "*xxx", "*xxx*" and "xxx*yyy" matches (with an | ||
* arbitrary number of pattern parts), as well as direct equality. | ||
* | ||
* @param pattern the pattern to match against | ||
* @param str the String to match | ||
* @return whether the String matches the given pattern | ||
*/ | ||
public static boolean globMatch(String pattern, String str) { | ||
if (pattern == null || str == null) { | ||
return false; | ||
} | ||
int firstIndex = pattern.indexOf('*'); | ||
if (firstIndex == -1) { | ||
return pattern.equals(str); | ||
} | ||
if (firstIndex == 0) { | ||
if (pattern.length() == 1) { | ||
return true; | ||
} | ||
int nextIndex = pattern.indexOf('*', firstIndex + 1); | ||
if (nextIndex == -1) { | ||
return str.endsWith(pattern.substring(1)); | ||
} else if (nextIndex == 1) { | ||
// Double wildcard "**" - skipping the first "*" | ||
return globMatch(pattern.substring(1), str); | ||
} | ||
String part = pattern.substring(1, nextIndex); | ||
int partIndex = str.indexOf(part); | ||
while (partIndex != -1) { | ||
if (globMatch(pattern.substring(nextIndex), str.substring(partIndex + part.length()))) { | ||
return true; | ||
} | ||
partIndex = str.indexOf(part, partIndex + 1); | ||
} | ||
return false; | ||
} | ||
return (str.length() >= firstIndex && | ||
pattern.substring(0, firstIndex).equals(str.substring(0, firstIndex)) && | ||
globMatch(pattern.substring(firstIndex), str.substring(firstIndex))); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import org.elasticsearch.gradle.precommit.PrecommitTasks | ||
|
||
/* | ||
* 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. | ||
*/ | ||
|
||
apply plugin: 'elasticsearch.build' | ||
apply plugin: 'nebula.maven-base-publish' | ||
apply plugin: 'nebula.maven-scm' | ||
|
||
archivesBaseName = 'elasticsearch-x-content' | ||
|
||
publishing { | ||
publications { | ||
nebula { | ||
artifactId = archivesBaseName | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
compile "org.elasticsearch:elasticsearch-core:${version}" | ||
|
||
compile "org.yaml:snakeyaml:${versions.snakeyaml}" | ||
compile "com.fasterxml.jackson.core:jackson-core:${versions.jackson}" | ||
compile "com.fasterxml.jackson.dataformat:jackson-dataformat-smile:${versions.jackson}" | ||
compile "com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:${versions.jackson}" | ||
compile "com.fasterxml.jackson.dataformat:jackson-dataformat-cbor:${versions.jackson}" | ||
|
||
testCompile "com.carrotsearch.randomizedtesting:randomizedtesting-runner:${versions.randomizedrunner}" | ||
testCompile "junit:junit:${versions.junit}" | ||
testCompile "org.hamcrest:hamcrest-all:${versions.hamcrest}" | ||
|
||
if (isEclipse == false || project.path == ":libs:x-content-tests") { | ||
testCompile("org.elasticsearch.test:framework:${version}") { | ||
exclude group: 'org.elasticsearch', module: 'elasticsearch-x-content' | ||
} | ||
} | ||
|
||
} | ||
|
||
forbiddenApisMain { | ||
// x-content does not depend on server | ||
// TODO: Need to decide how we want to handle for forbidden signatures with the changes to core | ||
signaturesURLs = [PrecommitTasks.getResource('/forbidden/jdk-signatures.txt')] | ||
} | ||
|
||
if (isEclipse) { | ||
// in eclipse the project is under a fake root, we need to change around the source sets | ||
sourceSets { | ||
if (project.path == ":libs:x-content") { | ||
main.java.srcDirs = ['java'] | ||
main.resources.srcDirs = ['resources'] | ||
} else { | ||
test.java.srcDirs = ['java'] | ||
test.resources.srcDirs = ['resources'] | ||
} | ||
} | ||
} | ||
|
||
thirdPartyAudit.excludes = [ | ||
// from com.fasterxml.jackson.dataformat.yaml.YAMLMapper (jackson-dataformat-yaml) | ||
'com.fasterxml.jackson.databind.ObjectMapper', | ||
] | ||
|
||
dependencyLicenses { | ||
mapping from: /jackson-.*/, to: 'jackson' | ||
} | ||
|
||
jarHell.enabled = false |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.