You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by dw...@apache.org on 2019/12/03 22:09:04 UTC

[lucene-solr] branch gradle-master updated: Add verification check that gradle and ant rules are in sync.

This is an automated email from the ASF dual-hosted git repository.

dweiss pushed a commit to branch gradle-master
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git


The following commit(s) were added to refs/heads/gradle-master by this push:
     new 64e1499  Add verification check that gradle and ant rules are in sync.
64e1499 is described below

commit 64e1499bc7c85d7ef7b896f5e73a9ff727fc7532
Author: Dawid Weiss <da...@carrotsearch.com>
AuthorDate: Tue Dec 3 23:08:57 2019 +0100

    Add verification check that gradle and ant rules are in sync.
---
 build.gradle                                       |  2 +-
 .../ant-compat/forbidden-api-rules-in-sync.gradle  | 37 ++++++++++++++++++++++
 2 files changed, 38 insertions(+), 1 deletion(-)

diff --git a/build.gradle b/build.gradle
index a043c47..2d1c561 100644
--- a/build.gradle
+++ b/build.gradle
@@ -53,4 +53,4 @@ apply from: file('gradle/ant-compat/post-jar.gradle')
 apply from: file('gradle/ant-compat/test-classes-cross-deps.gradle')
 apply from: file('gradle/ant-compat/artifact-naming.gradle')
 apply from: file('gradle/ant-compat/solr-forbidden-apis.gradle')
-
+apply from: file('gradle/ant-compat/forbidden-api-rules-in-sync.gradle')
\ No newline at end of file
diff --git a/gradle/ant-compat/forbidden-api-rules-in-sync.gradle b/gradle/ant-compat/forbidden-api-rules-in-sync.gradle
new file mode 100644
index 0000000..6ead715
--- /dev/null
+++ b/gradle/ant-compat/forbidden-api-rules-in-sync.gradle
@@ -0,0 +1,37 @@
+
+// Just make sure the forbidden API rules are in sync between gradle and ant versions until
+// we get rid of ant build.
+
+def linesOf(FileTree ftree) {
+  return ftree.collectMany { path ->
+    path.readLines("UTF-8")
+      .collect { line -> line.trim() }
+      .findAll { line -> !line.startsWith("#") }
+      .unique()
+      .collect { line -> [path: path, line: line] }
+  }.groupBy { e -> e.line }
+}
+
+configure(rootProject) {
+  task verifyForbiddenApiRulesInSync() {
+    doFirst {
+      // Read all rules line by line from ant, gradle, remove comments, uniq.
+      // Rule sets should be identical.
+      def gradleRules = linesOf(fileTree("gradle/validation/forbidden-apis", { include "**/*.txt" }))
+      def antRules = linesOf(project(":lucene").fileTree("tools/forbiddenApis", { include "**/*.txt" }))
+
+      def antOnlyLines = antRules.keySet() - gradleRules.keySet()
+      def gradleOnlyLines = gradleRules.keySet() - antRules.keySet()
+
+      if (!gradleOnlyLines.isEmpty() || !antOnlyLines.isEmpty()) {
+        project.logger.log(LogLevel.ERROR, "The following rules don't have counterparts:\n" +
+          (gradleRules.findAll { gradleOnlyLines.contains(it.key) } + antRules.findAll { antOnlyLines.contains(it.key)})
+            .collectMany { it.value }
+            .join("\n"))
+        throw new GradleException("Forbidden APIs rules out of sync.")
+      }
+    }
+  }
+
+  check.dependsOn verifyForbiddenApiRulesInSync
+}