Uploaded image for project: 'Infinispan'
  1. Infinispan
  2. ISPN-12461

Scopes defined in BOM don't work with Gradle

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • Major
    • None
    • 10.1.8.Final, 11.0.4.Final
    • Build
    • None
    • Undefined

    Description

      The Infinispan BOM seems to define the scope of theĀ infinispan-component-annotations andĀ org.infinispan.protostream dependencies:

      <dependency>
          <groupId>org.infinispan</groupId>
          <artifactId>infinispan-component-annotations</artifactId>
          <version>${version.infinispan}</version>
          <scope>provided</scope>
      </dependency>
      
      ...
      
      <dependency>
          <groupId>org.infinispan.protostream</groupId>
          <artifactId>protostream-processor</artifactId>
          <version>${version.protostream}</version>
          <!-- compile-only dependency -->
          <scope>provided</scope>
      </dependency>
      

      It seems that with Maven, this is allowed and defines the scope of the dependency for all usages of the dependency. However, some consider this bad practice, and suggest the user should decide on the scope of the dependency. See for example https://stackoverflow.com/a/47402262/398174. To be honest, this makes sense to me.

      More problematically, with Gradle the dependency resolution mechanism works a little different. When the user uses Gradle instead of Maven and adds infinispan-core as a dependency and infinispan-component-annotations is not included at all.

      My hypothesis is that when Gradle encounters a scope in the BOM, it applies the version constraint only when the dependency is in the equivalent Gradle configuration. But it doesn't enforce the dependency to be in a specific configuration, as with Gradle you always specify the configuration the dependency should be in.

      So when Gradle processes infinispan-core, it finds infinispan-component-processor > infinispan-component-annotations and applies these dependencies to the compile configuration (scope). (Note that infinispan-component-processor overrides the scope of the infinispan-component-annotations dependency to compile.) However, there's no version constraint for infinispan-component-annotations in this configuration/scope, so it doesn't get included and we see issues like:
      https://stackoverflow.com/questions/63008438/after-infinispan-10-1-8-update-class-file-for-org-infinispan-factories-scopes-s

      Concluding, I'd suggest to move the Maven scope declarations of dependencies from the BOM to the actual usages of the dependency.

      Attachments

        Activity

          People

            Unassigned Unassigned
            evpaassen Erik van Paassen (Inactive)
            Votes:
            2 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: