uschindler commented on a change in pull request #1830:
URL: https://github.com/apache/lucene-solr/pull/1830#discussion_r484692069



##########
File path: gradle/validation/validate-source-patterns.gradle
##########
@@ -29,50 +33,127 @@ buildscript {
   }
 }
 
-configure(rootProject) {
-  task("validateSourcePatterns", type: ValidateSourcePatternsTask) { task ->
+def extensions = [
+    'adoc',
+    'bat',
+    'cmd',
+    'css',
+    'g4',
+    'gradle',
+    'groovy',
+    'html',
+    'java',
+    'jflex',
+    'jj',
+    'js',
+    'json',
+    'md',
+    'mdtext',
+    'pl',
+    'policy',
+    'properties',
+    'py',
+    'sh',
+    'template',
+    'vm',
+    'xml',
+    'xsl',
+]
+
+// Create source validation task local for each project's files.
+subprojects {
+  task validateSourcePatterns(type: ValidateSourcePatternsTask) { task ->
     group = 'Verification'
     description = 'Validate Source Patterns'
 
     // This task has no proper outputs.
     setupDummyOutputs(task)
 
-    sourceFiles = project.fileTree(project.rootDir) {
-      [
-        'java', 'jflex', 'py', 'pl', 'g4', 'jj', 'html', 'js',
-        'css', 'xml', 'xsl', 'vm', 'sh', 'cmd', 'bat', 'policy',
-        'properties', 'mdtext', 'groovy', 'gradle',
-        'template', 'adoc', 'json',
-      ].each{
-        include "lucene/**/*.${it}"
-        include "solr/**/*.${it}"
-        include "dev-tools/**/*.${it}"
-        include "gradle/**/*.${it}"
-        include "*.${it}"
+    sourceFiles = fileTree(projectDir) {
+      extensions.each{
+        include "**/*.${it}"
       }
-      // TODO: For now we don't scan txt / md files, so we
-      // check licenses in top-level folders separately:
-      include '*.txt'
-      include '*/*.txt'
-      include '*.md'
-      include '*/*.md'
-      // excludes:
+      
+      // Don't go into child projects (scanned separately).
+      childProjects.keySet().each{
+        exclude "${it}/**"
+      }
+
+      // default excludes.
+      exclude 'build/**'
+    }
+  }
+
+  // Add source validation to per-project checks as well.
+  check.dependsOn validateSourcePatterns
+}
+
+configure(project(':lucene:benchmark')) {
+  project.tasks.withType(ValidateSourcePatternsTask) {
+    sourceFiles.exclude 'temp/**'
+    sourceFiles.exclude 'work/**'
+  }
+}
+
+configure(project(':solr:core')) {
+  project.tasks.withType(ValidateSourcePatternsTask) {
+    sourceFiles.exclude 'src/**/CheckLoggingConfiguration.java'
+    sourceFiles.exclude 'src/test/org/apache/hadoop/**'
+  }
+}
+
+configure(rootProject) {
+  task validateRootAndOtherFiles(type: ValidateSourcePatternsTask) { task ->
+    // This task has no proper outputs.
+    setupDummyOutputs(task)
+
+    sourceFiles = fileTree(projectDir) {
+      extensions.each{
+        include "**/*.${it}"
+      }
+
+      // We do not scan for *.txt by default (broken files in subprojects),
+      // but in root we can do this).
+      include '**/*.txt'
+
+      // Don't go into child projects (scanned separately).
+      childProjects.keySet().each{
+        exclude "${it}/**"
+      }
+
+      // default excludes.
       exclude '**/build/**'
-      exclude '**/dist/**'
       exclude 'dev-tools/missing-doclet/src/**/*.java' // <-- TODO: remove 
once we allow "var" on master
-      exclude 'lucene/benchmark/work/**'
-      exclude 'lucene/benchmark/temp/**'
-      exclude '**/CheckLoggingConfiguration.java'
-      exclude 'solr/core/src/test/org/apache/hadoop/**'
-      exclude '**/validate-source-patterns.gradle' // ourselves :-)
+
+      // ourselves :-)
+      exclude 'gradle/validation/validate-source-patterns.gradle'
     }
   }
+
+  task validateSourcePatterns() {
+    group = 'Verification'
+    description = 'Validate Source Patterns'
+
+    // Make it depend on all so-named tasks from subprojects.

Review comment:
       I also want this to be able to run it from root separately. If that's 
not needed and works automatically, remove it here.
   
   I just made it consistent with other validation tasks 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org
For additional commands, e-mail: issues-h...@lucene.apache.org

Reply via email to