You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by th...@apache.org on 2020/09/14 16:38:19 UTC
[lucene-solr] 01/39: LUCENE-9411: Fail complation on warnings,
9x gradle-only
This is an automated email from the ASF dual-hosted git repository.
thelabdude pushed a commit to branch reference_impl_gradle_updates
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git
commit 0edf0f34f77c962efe5141e33c47fe3558a0e600
Author: Erick Erickson <Er...@gmail.com>
AuthorDate: Tue Jun 23 16:10:49 2020 -0400
LUCENE-9411: Fail complation on warnings, 9x gradle-only
---
build.gradle | 3 +-
gradle/defaults-java.gradle | 1 +
gradle/hacks/findbugs.gradle | 45 ++++++++++++++++++++++
gradle/validation/jar-checks.gradle | 4 +-
lucene/CHANGES.txt | 3 ++
.../solr/common/util/JsonSchemaValidator.java | 11 ++----
6 files changed, 57 insertions(+), 10 deletions(-)
diff --git a/build.gradle b/build.gradle
index 83368a1..9c07bc7 100644
--- a/build.gradle
+++ b/build.gradle
@@ -150,6 +150,7 @@ apply from: file('gradle/documentation/documentation.gradle')
apply from: file('gradle/documentation/changes-to-html.gradle')
apply from: file('gradle/documentation/markdown.gradle')
apply from: file('gradle/render-javadoc.gradle')
+apply from: file('gradle/hacks/findbugs.gradle')
allprojects {
task ufclasspath {
@@ -166,4 +167,4 @@ allprojects {
}
}
}
-}
\ No newline at end of file
+}
diff --git a/gradle/defaults-java.gradle b/gradle/defaults-java.gradle
index 584054c..4d0fae7 100644
--- a/gradle/defaults-java.gradle
+++ b/gradle/defaults-java.gradle
@@ -33,6 +33,7 @@ allprojects {
"-Xdoclint:-missing",
"-Xdoclint:-accessibility",
"-proc:none", // proc:none was added because of LOG4J2-1925 / JDK-8186647
+ "-Werror",
]
}
}
diff --git a/gradle/hacks/findbugs.gradle b/gradle/hacks/findbugs.gradle
new file mode 100644
index 0000000..bdbdb7e
--- /dev/null
+++ b/gradle/hacks/findbugs.gradle
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF 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.
+ */
+
+// See LUCENE-9411. This hack adds compile-time only dependencies
+// on findbugs annotations. Otherwise javac generates odd warnings about missing
+// type information.
+
+configure([project(":solr:core"),
+ project(":solr:solrj"),
+ project(":solr:contrib:prometheus-exporter")]) {
+ plugins.withType(JavaPlugin) {
+ dependencies {
+ // Use versionless variants because these libraries are in versions.lock.
+ compileOnly 'com.google.errorprone:error_prone_annotations'
+ testCompileOnly 'com.google.errorprone:error_prone_annotations'
+ compileOnly 'com.google.code.findbugs:jsr305'
+ testCompileOnly 'com.google.code.findbugs:jsr305'
+
+ // This one isn't.
+ compileOnly 'com.google.code.findbugs:annotations:3.0.1'
+ testCompileOnly 'com.google.code.findbugs:annotations:3.0.1'
+ }
+
+ // Exclude these from jar validation and license checks.
+ configurations.jarValidation {
+ exclude group: "com.google.code.findbugs", module: "jsr305"
+ exclude group: "com.google.code.findbugs", module: "annotations"
+ exclude group: "com.google.errorprone", module: "error_prone_annotations"
+ }
+ }
+}
diff --git a/gradle/validation/jar-checks.gradle b/gradle/validation/jar-checks.gradle
index b369b06..61db9a1 100644
--- a/gradle/validation/jar-checks.gradle
+++ b/gradle/validation/jar-checks.gradle
@@ -115,7 +115,9 @@ subprojects {
ArrayDeque<ResolvedDependency> queue = new ArrayDeque<>()
configurations.jarValidation.extendsFrom.each { conf ->
if (excludeRules) {
- conf = configurations.detachedConfiguration().extendsFrom(conf)
+ conf = conf.copyRecursive()
+ conf.canBeResolved = true
+ conf.canBeConsumed = true
conf.excludeRules = excludeRules
}
if (conf.canBeResolved) {
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index a3c27ef..29d5aba 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -138,6 +138,9 @@ Other
* LUCENE-9267: Update MatchingQueries documentation to correct
time unit. (Pierre-Luc Perron via Mike Drob)
+* LUCENE-9411: Fail complation on warnings, 9x gradle-only (Erick Erickson, Dawid Weiss)
+ Deserves mention here as well as Lucene CHANGES.txt since it affects both.
+
======================= Lucene 8.6.0 =======================
API Changes
diff --git a/solr/solrj/src/java/org/apache/solr/common/util/JsonSchemaValidator.java b/solr/solrj/src/java/org/apache/solr/common/util/JsonSchemaValidator.java
index 3231eb5..3e39525 100644
--- a/solr/solrj/src/java/org/apache/solr/common/util/JsonSchemaValidator.java
+++ b/solr/solrj/src/java/org/apache/solr/common/util/JsonSchemaValidator.java
@@ -34,21 +34,18 @@ import java.util.function.Function;
* It validates most aspects of json schema but it is NOT A FULLY COMPLIANT JSON schema parser or validator.
* This validator borrow some design's idea from https://github.com/networknt/json-schema-validator
*/
-@SuppressWarnings({"unchecked"})
+@SuppressWarnings({"unchecked", "rawtypes"})
public class JsonSchemaValidator {
- @SuppressWarnings({"unchecked", "rawtypes"})
private List<Validator> validators;
private static Set<String> KNOWN_FNAMES = new HashSet<>(Arrays.asList(
"description","documentation","default","additionalProperties", "#include"));
- @SuppressWarnings({"rawtypes"})
public JsonSchemaValidator(String jsonString) {
this((Map) Utils.fromJSONString(jsonString));
}
- @SuppressWarnings({"rawtypes"})
public JsonSchemaValidator(Map jsonSchema) {
this.validators = new LinkedList<>();
for (Object fname : jsonSchema.keySet()) {
@@ -61,7 +58,6 @@ public class JsonSchemaValidator {
}
}
- @SuppressWarnings({"rawtypes"})
static final Map<String, Function<Pair<Map,Object>, Validator>> VALIDATORS = new HashMap<>();
static {
@@ -79,7 +75,6 @@ public class JsonSchemaValidator {
return errs.isEmpty() ? null : errs;
}
- @SuppressWarnings({"unchecked", "rawtypes"})
boolean validate(Object data, List<String> errs) {
if (data == null) return true;
for (Validator validator : validators) {
@@ -93,7 +88,6 @@ public class JsonSchemaValidator {
}
abstract class Validator<T> {
- @SuppressWarnings("unused")
Validator(@SuppressWarnings({"rawtypes"})Map schema, T properties) {};
abstract boolean validate(Object o, List<String> errs);
}
@@ -182,7 +176,7 @@ class TypeValidator extends Validator<Object> {
@SuppressWarnings({"rawtypes"})
class ItemsValidator extends Validator<Map> {
private JsonSchemaValidator validator;
- ItemsValidator(@SuppressWarnings({"rawtypes"})Map schema, @SuppressWarnings({"rawtypes"})Map properties) {
+ ItemsValidator(Map schema, Map properties) {
super(schema, properties);
validator = new JsonSchemaValidator(properties);
}
@@ -282,6 +276,7 @@ class PropertiesValidator extends Validator<Map<String, Map>> {
}
@Override
+ @SuppressWarnings({"rawtypes"})
boolean validate(Object o, List<String> errs) {
if (o instanceof Map) {
@SuppressWarnings({"rawtypes"})