How to query for `provided` scoped dependencies of a configuration?

I have a dependency that has a pom.xml that contains a few <scope>provider</scope>. It doesn’t seem like

In the pom.xml there is:

    <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>javax.servlet-api</artifactId>
      <version>3.1.0</version>
      <scope>provided</scope>
    </dependency>

I’d like to get that dependency transitively and make use of it, by using it in a specific compileOnly of one of projects and other places.

If I do this:

configurations["myConfig"].resolvedConfiguration.resolvedArtifacts.filter {
  it.moduleVersion.id.name == "javax.servlet-api"
}.forEach {
  println(it)
}

I don’t see the javax.servlet-api in any of the resolved artifacts.

How do I query for it from the configuration? Or, what is a better way to get it?