Uploaded image for project: 'Drools'
  1. Drools
  2. DROOLS-1084

kjar maven dependencies are downloaded even if scope is set to provided or test

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • None
    • 6.3.0.Final
    • None
    • None
    • 2020 Week 01-03 (from Dec 30)
    • NEW
    • NEW

      The creation of a new kbase triggers the specified rules kjar to be downloaded from the remote Maven repository. This works as expected but has the side effect of also downloading the Maven dependencies for the kjar. The problem is that it is downloading ALL the Maven dependencies even if they are specified as provided or test scope. This shouldn't happen since provided dependencies are expected to already be on the classpath and we should never need test dependencies at all during runtime at all.

      I did some digging into the Drools source to and found out that
      KieRepositoryImpl#getKieModule()
      contains logic to check the classpath for the KieModule and if it can't find it to load everything from the Maven repo which includes downloading all the dependencies (and dependencies of dependencies and so on).

      Unfortunately the code for checking the classpath is not actually implemented and looks like this:

      private KieModule checkClasspathForKieModule(ReleaseId releaseId) {
          // TODO
          // ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
          // URL url = classLoader.getResource( ((ReleaseIdImpl)releaseId).getPomPropertiesPath() );
          return null;
      }
      

      After nothing is found on the classpath everything is downloaded from Maven. You can see all the stuff that is going to be downloaded (if it's not already in your Maven repo) in
      DefaultProjectDependenciesResolver#resolve() //line 159
      You can even see here that the dependencies have been marked as provided, but regardless they are going to be downloaded.

        1. debug3.png
          debug3.png
          265 kB
        2. debug2.png
          debug2.png
          277 kB
        3. debug1.png
          debug1.png
          200 kB

              mfusco@redhat.com Mario Fusco
              lindsaythurmond_jira Lindsay Thurmond (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: