-
Notifications
You must be signed in to change notification settings - Fork 24.9k
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
Begin moving XContent to a separate lib/artifact #29300
Changes from 7 commits
d8d0902
af79dfb
c7bda43
4bc0b97
f84637f
7d21a9c
00a3870
544cfde
491784b
d55d4ff
f62f536
1f03587
ddcaa9f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ++ |
||
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))); | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
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-xcontent' | ||
|
||
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:xcontent-tests") { | ||
testCompile("org.elasticsearch.test:framework:${version}") { | ||
exclude group: 'org.elasticsearch', module: 'elasticsearch-xcontent' | ||
} | ||
} | ||
|
||
} | ||
|
||
forbiddenApisMain { | ||
// xcontent does not depend on server | ||
// TODO: Need to decide how we want to handle for forbidden signatures with the changes to core | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you mean that we should have more forbidden signatures here than just what is in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If so, then that makes sense to me and I'm happy to think of that in a followup. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should have a followup item to separate out forbidden signatures that are truly server specific (eg log4j apis that require server deps) and those that should really be shared by all. We already have an "es-all-signatures", that should probably be used here as a start (in addition to jdk signatures)? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ++ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is copied from the elasticsearch-core build.gradle file, is there already a followup item for this then? Can you explain what you mean by using the "es-all-signatures" here? (like I said, I copied it, so I'm not that familiar yet with configuring it) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We have a number of different signature files. In particular, in addition to the jdk signatures provided by forbiddenapis itself, we have an "es-all" signature file that is supposed to apply across main and test code. Then we have "es-server" and "es-test". We should at least be using the es-all here I think (it only contains jdk methods, I believe). es-server is a little more convoluted, because it has mostly jdk methods, but also some ES server specific code (PathUtils.get), or ES server specific dependency code (log4j methods). So here I am suggesting starting by adding the es-all signatures file. I don't think we have an existing issue to split the signature files more, but it is worth a discussion on where the breakdown should be (how fine grained we should get). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I checked into adding the es-all-signatures here, but it fails because it is checking for a Lucene forbiddenapi, which isn't on the classpath for xcontent (since no lucene dependency) |
||
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:xcontent") { | ||
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' | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make this
x-content
. This is consistent with established naming conventions. Sorry.