SOLR-13452: More work on dependencies and related tasks.
diff --git a/build.gradle b/build.gradle
index 70b4636..6f04e85 100644
--- a/build.gradle
+++ b/build.gradle
@@ -39,10 +39,6 @@
   ext.filePath = { path -> file(path).getAbsolutePath() }
   // sugar multi part File
   ext.mfile = { file1, file2 -> new File(file(file1), file2.toString()) }
-  File target = new File(System.getProperty("java.io.tmpdir") + '/lucene-solr-gradle')
-  //target.deleteOnExit()
-  ext.tmp = target
-  //gradle.buildFinished {delete(target)}
 }
 
 apply from: mfile(rootProjectDir, 'buildSrc/common/build-help.gradle')
@@ -156,7 +152,6 @@
   }
   
   task pristineClean(type: org.apache.lucene.gradle.PristineClean) {}
-  
 }
 
 // -> all projects config
@@ -189,9 +184,9 @@
   File jdepsReportDir = mfile(project.buildDir, 'jdepsreport')
   
   plugins.withType(JavaPlugin) {
+    
     task jdepsReport(type: org.apache.lucene.gradle.JdepsReport) {
       target = jdepsReportDir
-      dependsOn jar
     }
     
     task listDependencies(type: org.apache.lucene.gradle.ListDeps) {
diff --git a/buildSrc/src/main/groovy/org/apache/lucene/gradle/JdepsReport.groovy b/buildSrc/src/main/groovy/org/apache/lucene/gradle/JdepsReport.groovy
index eff5719..a5e6f51 100644
--- a/buildSrc/src/main/groovy/org/apache/lucene/gradle/JdepsReport.groovy
+++ b/buildSrc/src/main/groovy/org/apache/lucene/gradle/JdepsReport.groovy
@@ -64,6 +64,14 @@
     doFirst {
       println "Writing output files to ${target}"
     }
+    
+    // make sure all jars are built
+    project.rootProject.subprojects.each {subproject ->
+      def tasks = subproject.tasks.findByName('jar')
+      if (tasks != null) {
+        dependsOn tasks
+      }
+    }
   }
   
   protected void makeDirs() {
@@ -105,6 +113,7 @@
         def topLvlProject = getTopLvlProject(subproject)
         
         if (subproject.getPlugins().hasPlugin(PartOfDist) && subproject.tasks.findByName('jar') && subproject.configurations.hasProperty(configuration)) {
+         //   subproject.tasks.findByName('jar')
            from(subproject.jar.outputs.files) {
             include "*.jar"
             into ({topLvlProject.name + '/' + topLvlProject.relativePath(subproject.projectDir)})
@@ -139,7 +148,7 @@
     def distPath1 = "${distDir}/" + topLvlProject.name + "/" + topLvlProject.relativePath(libProject.projectDir)
     def distPath2 = "${distDir}/" + topLvlProject.name + "/" + topLvlProject.relativePath(project.projectDir)
     def dotOutPath = jdepsDir.getAbsolutePath() + "/" + topLvlProject.name +  "/" + "${project.name}-${project.version}"
-    
+
     ant.exec (executable: "jdeps", failonerror: true, resolveexecutable: true) {
       ant.arg(line: '--class-path ' + "${distPath1}/lib/" + '*')
       ant.arg(line: '--multi-release 11')
diff --git a/buildSrc/src/main/groovy/org/apache/lucene/gradle/MissingDeps.groovy b/buildSrc/src/main/groovy/org/apache/lucene/gradle/MissingDeps.groovy
index 7796f0f..7ee40b1 100644
--- a/buildSrc/src/main/groovy/org/apache/lucene/gradle/MissingDeps.groovy
+++ b/buildSrc/src/main/groovy/org/apache/lucene/gradle/MissingDeps.groovy
@@ -44,7 +44,7 @@
 import java.util.zip.ZipException
 
 class MissingDeps extends DefaultTask {
-  protected static Pattern pattern = Pattern.compile("->\\s\\\"([^\\s]*?)\\s")
+  protected static Pattern pattern = Pattern.compile("\\\"(.*?)\\\"\\s+->\\s\\\"([^\\s]*?)\\s")
   protected static Pattern srcJar = Pattern.compile("(.*?)-sources.jar")
   protected static Pattern dotFilePattern = Pattern.compile("(.*?).jar.dot")
   
@@ -53,6 +53,7 @@
   
   private List<String> depExcludes = new ArrayList<>()
   private List<String> classExcludes = new ArrayList<>()
+  private List<String> foundInClassExcludes = new ArrayList<>()
   
   protected configuration = "runtimeClasspath"
   
@@ -83,6 +84,7 @@
     project.fileTree(project.mfile(inputDirectory, 'jdepsDir')) {
       
       println 'depExcludes ' + depExcludes
+      println 'foundInClassExcludes ' + foundInClassExcludes
       println 'classExcludes ' + classExcludes
       for (String ex : depExcludes) {
         exclude ex
@@ -105,11 +107,24 @@
         for (String line : lines) {
           if (line.contains('(not found)')) {
             String className
+            String classFoundInName
             AtomicBoolean foundInsrc = new AtomicBoolean(false)
             boolean excluded
             Matcher m = pattern.matcher(line)
             if (m.find()) {
-              className = m.group(1)
+              classFoundInName = m.group(1)
+              
+              for (String foundInClassExclude : foundInClassExcludes) {
+                Matcher m2 = Pattern.compile(foundInClassExclude).matcher(classFoundInName)
+                //println "${className} against ${classExclude}"
+                if (m2.matches()) {
+                  excluded = true
+                  //println 'excluded'
+                  break
+                }
+              }
+              
+              className = m.group(2)
               for (String classExclude : classExcludes) {
                 Matcher m2 = Pattern.compile(classExclude).matcher(className)
                 //println "${className} against ${classExclude}"
@@ -139,6 +154,18 @@
   }
   
   @Input
+  public Set<String> getFoundInClassExcludes() {
+    return foundInClassExcludes
+  }
+  
+  public MissingDeps foundInClassExclude(String... arg0) {
+    for (String pattern : arg0) {
+      foundInClassExcludes.add(pattern);
+    }
+    return this;
+  }
+  
+  @Input
   public Set<String> getClassExcludes() {
     return classExcludes
   }
@@ -174,15 +201,23 @@
     return topLvlProject
   }
   
-  public static void addExclusionsFrom(Project project, MissingDeps to) {
-    Set<String> depExcludes = project.missingDeps.getDepExcludes()
+  public static void addExclusionsFrom(Project fromProject, Project toProject) {
+    toProject.evaluationDependsOn(fromProject.path)
+    
+    MissingDeps to = toProject.missingDeps
+    
+    Set<String> depExcludes = fromProject.missingDeps.getDepExcludes()
     for (String exclude : depExcludes) {
       to.depExclude exclude
     }
-    Set<String> classExcludes = project.missingDeps.getClassExcludes()
+    Set<String> classExcludes = fromProject.missingDeps.getClassExcludes()
     for (String exclude : classExcludes) {
       to.classExclude exclude
     }
+    Set<String> foundInClassExcludes = fromProject.missingDeps.getFoundInClassExcludes()
+    for (String exclude : foundInClassExcludes) {
+      to.foundInClassExclude exclude
+    }
   }
 }
 
diff --git a/lucene/analysis/opennlp/build.gradle b/lucene/analysis/opennlp/build.gradle
index 821f351..a39ebd3 100644
--- a/lucene/analysis/opennlp/build.gradle
+++ b/lucene/analysis/opennlp/build.gradle
@@ -168,3 +168,8 @@
 task regenerate {
   dependsOn trainTestModels
 }
+
+missingDeps {
+  classExclude 'org\\.osgi\\..*' // osgi stuff not on classpath
+}
+
diff --git a/lucene/backward-codecs/build.gradle b/lucene/backward-codecs/build.gradle
index a84d3e9..43e80a1 100644
--- a/lucene/backward-codecs/build.gradle
+++ b/lucene/backward-codecs/build.gradle
@@ -37,4 +37,8 @@
   implementation project(':lucene:lucene-core')
 
   testImplementation project(':lucene:lucene-test-framework')
-}
\ No newline at end of file
+}
+
+missingDeps {
+  depExclude  '**/*lucene-backward-codecs-*.dot' // we expect things to be missing in our jar
+}
diff --git a/lucene/benchmark/build.gradle b/lucene/benchmark/build.gradle
index 99e5738..de85975 100644
--- a/lucene/benchmark/build.gradle
+++ b/lucene/benchmark/build.gradle
@@ -71,7 +71,7 @@
   target = mfile('temp', 'allCountries.txt.bz2')
 }
 
-task installGeoNames(){
+task installGeoNames() {
   group = 'Benchmark Data'
   description = "Installs GeoNames data files."
   doLast {
@@ -110,8 +110,13 @@
   dependsOn extractReuters
 }
 
-
 forbiddenApisMain {
   bundledSignatures -= 'jdk-system-out'
 }
 
+missingDeps {
+  classExclude 'org\\.noggit\\.JSONParser' // we don't currently pull in noggit
+  
+  foundInClassExclude  'org\\.apache\\.commons\\.compress\\.compressors\\..*' // there are optional compressor deps we don't have
+}
+
diff --git a/lucene/demo/build.gradle b/lucene/demo/build.gradle
index c43c1be..1aa031b 100644
--- a/lucene/demo/build.gradle
+++ b/lucene/demo/build.gradle
@@ -36,3 +36,7 @@
 forbiddenApisMain {
   bundledSignatures -= 'jdk-system-out'
 }
+
+missingDeps {
+  depExclude  '**/*' // demo does not make a jar
+}
diff --git a/lucene/replicator/build.gradle b/lucene/replicator/build.gradle
index ffd451e..133bcce 100644
--- a/lucene/replicator/build.gradle
+++ b/lucene/replicator/build.gradle
@@ -23,18 +23,23 @@
   api project(':lucene:lucene-core')
   api project(':lucene:lucene-facet')
   
-  runtimeOnly ('org.slf4j:jcl-over-slf4j') { transitive = false }
+  runtimeOnly ('org.slf4j:jcl-over-slf4j')
   
-  implementation ('org.apache.httpcomponents:httpclient') { transitive = false }
-  implementation ('org.apache.httpcomponents:httpcore') { transitive = false }
-  implementation ('org.eclipse.jetty:jetty-server') { transitive = false }
-  implementation ('org.eclipse.jetty:jetty-servlet') { transitive = false }
-  implementation ('org.eclipse.jetty:jetty-util') { transitive = false }
-  implementation ('org.eclipse.jetty:jetty-io') { transitive = false }
-  implementation ('org.eclipse.jetty:jetty-continuation') { transitive = false }
-  implementation ('org.eclipse.jetty:jetty-http') { transitive = false }
-  implementation ('javax.servlet:javax.servlet-api') { transitive = false }
-  implementation ('org.slf4j:slf4j-api') { transitive = false }
+  implementation ('org.apache.httpcomponents:httpclient')
+  implementation ('org.apache.httpcomponents:httpcore')
+  implementation ('org.eclipse.jetty:jetty-server')
+  implementation ('org.eclipse.jetty:jetty-servlet')
+  implementation ('org.eclipse.jetty:jetty-util')
+  implementation ('org.eclipse.jetty:jetty-io')
+  implementation ('org.eclipse.jetty:jetty-continuation')
+  implementation ('org.eclipse.jetty:jetty-http')
+  implementation ('javax.servlet:javax.servlet-api')
+  implementation ('org.slf4j:slf4j-api')
   
   testImplementation project(':lucene:lucene-test-framework')
-}
\ No newline at end of file
+}
+
+missingDeps {
+  classExclude 'org.slf4j.impl.StaticLoggerBinder' // we are a lib and don't distribute logging impl
+  classExclude 'org.apache.commons.codec.binary.Base64' // used by some org.apache.http.impl.auth classes we don't use
+}
diff --git a/lucene/spatial-extras/build.gradle b/lucene/spatial-extras/build.gradle
index eaf4fd4..02cdcf2 100644
--- a/lucene/spatial-extras/build.gradle
+++ b/lucene/spatial-extras/build.gradle
@@ -25,12 +25,16 @@
   implementation project(':lucene:lucene-spatial')
   implementation project(':lucene:lucene-spatial3d')
   
-  implementation ('org.locationtech.spatial4j:spatial4j') { transitive = false }
-  implementation ('io.sgr:s2-geometry-library-java') { transitive = false }
+  implementation ('org.locationtech.spatial4j:spatial4j')
+  implementation ('io.sgr:s2-geometry-library-java')
   
-  testImplementation ('org.locationtech.jts:jts-core') { transitive = false }
-  testImplementation ('org.locationtech.spatial4j:spatial4j::tests') { transitive = false }
+  testImplementation ('org.locationtech.jts:jts-core')
+  testImplementation ('org.locationtech.spatial4j:spatial4j::tests')
   
   testImplementation project(':lucene:lucene-test-framework')
   testImplementation project(path: ':lucene:lucene-spatial3d', configuration: 'testOutput')
 }
+
+missingDeps {
+  classExclude 'org\\.noggit\\.JSONParser' // we don't currently pull in noggit
+}
diff --git a/solr/contrib/clustering/build.gradle b/solr/contrib/clustering/build.gradle
index e153486..05741fd 100644
--- a/solr/contrib/clustering/build.gradle
+++ b/solr/contrib/clustering/build.gradle
@@ -45,5 +45,5 @@
   classExclude 'org\\.xmlpull\\.v1\\.XmlPullParser.*' // currently not brought in, wanted by simple-xml
   
   // add solr-core exclusions
-  MissingDeps.addExclusionsFrom(project(':solr:solr-core'), project.missingDeps)
+  MissingDeps.addExclusionsFrom(project(':solr:solr-core'), project)
 }
diff --git a/solr/contrib/dataimporthandler/build.gradle b/solr/contrib/dataimporthandler/build.gradle
index ba79e15..d00d8da 100644
--- a/solr/contrib/dataimporthandler/build.gradle
+++ b/solr/contrib/dataimporthandler/build.gradle
@@ -68,6 +68,6 @@
   classExclude 'org\\.xmlpull\\.v1\\.XmlPullParser.*' // currently not brought in, wanted by simple-xml
   
   // add solr-core exclusions
-  MissingDeps.addExclusionsFrom(project(':solr:solr-core'), project.missingDeps)
+  MissingDeps.addExclusionsFrom(project(':solr:solr-core'), project)
 }
 
diff --git a/solr/core/build.gradle b/solr/core/build.gradle
index b28aa3c..b665793 100644
--- a/solr/core/build.gradle
+++ b/solr/core/build.gradle
@@ -16,6 +16,7 @@
  */
 
  import org.apache.lucene.gradle.UnusedDeps
+ import org.apache.lucene.gradle.MissingDeps
  
 apply plugin: 'java-library'
 apply plugin: 'maven-publish'
@@ -57,6 +58,7 @@
   runtimeOnly ('org.apache.kerby:kerby-pkix')
   
   runtimeOnly ('com.google.protobuf:protobuf-java') // used by calicte.avatica
+  runtimeOnly ('io.netty:netty-all') // used by zookeeper
   
   compileOnly ('javax.servlet:javax.servlet-api')
 
@@ -220,9 +222,8 @@
   classExclude 'org\\.apache\\.commons\\.dbcp2\\.BasicDataSource'
   classExclude 'com\\.yahoo\\.sketches\\.hll\\..*'
   
-  // zk 3.5.5 added these deps we don't have
-  classExclude 'io\\.netty\\.buffer\\..*'
-  classExclude 'io\\.netty\\.handler\\.ssl\\.SslHandler'
+  // add solrj exclusions
+  MissingDeps.addExclusionsFrom(project(':solr:solr-solrj'), project)
 }
 
 unusedDeps {
diff --git a/solr/solrj/build.gradle b/solr/solrj/build.gradle
index 9f4d8f8..756143c 100644
--- a/solr/solrj/build.gradle
+++ b/solr/solrj/build.gradle
@@ -24,6 +24,9 @@
   api ('org.apache.zookeeper:zookeeper') { transitive = false } // // zk has annotation deps we don't need
   api ('org.apache.zookeeper:zookeeper-jute')
   
+  runtimeOnly ('org.slf4j:log4j-over-slf4j') // bridge for deps that use log4j12 directly
+  runtimeOnly ('io.netty:netty-all') // used by zookeeper
+  
   implementation ('org.slf4j:slf4j-api')
   implementation ('org.slf4j:jcl-over-slf4j')
   implementation ('org.apache.httpcomponents:httpclient')
@@ -60,3 +63,11 @@
   testImplementation project(':solr:example:solr-example-DIH')
 }
 
+missingDeps {
+  foundInClassExclude 'io\\.netty\\.handler\\.ssl\\..*' // zookeeper brings netty-all and ssl stuff we don't use
+  
+  // we are a lib and don't distribute logging impl
+  classExclude 'org.slf4j.impl.StaticLoggerBinder'
+  classExclude 'org.slf4j.impl.StaticMDCBinder'
+  classExclude 'org.slf4j.impl.StaticMarkerBinder'
+}
diff --git a/versions.lock b/versions.lock
index 15cb819..50bc0f5 100644
--- a/versions.lock
+++ b/versions.lock
@@ -62,6 +62,7 @@
 io.dropwizard.metrics:metrics-jetty9:4.0.5 (1 constraints: 0b050436)
 io.dropwizard.metrics:metrics-jmx:4.0.5 (1 constraints: 0b050436)
 io.dropwizard.metrics:metrics-jvm:4.0.5 (1 constraints: 0b050436)
+io.netty:netty-all:4.0.52.Final (1 constraints: 55073d61)
 io.opentracing:opentracing-api:0.33.0 (4 constraints: a62f7e64)
 io.opentracing:opentracing-mock:0.33.0 (1 constraints: 3805343b)
 io.opentracing:opentracing-noop:0.33.0 (3 constraints: 7c2142bd)