This message was deleted.
# community-support
s
This message was deleted.
a
Copy code
--------------------------------------------------
Variant releaseApiElements
--------------------------------------------------
API elements for release

Capabilities
    - app.cash.redwood:redwood-treehouse-host:0.3.0-SNAPSHOT (default capability)
Attributes
    - com.android.build.api.attributes.AgpVersionAttr          = 7.4.2
    - com.android.build.api.attributes.BuildTypeAttr           = release
    - com.android.build.gradle.internal.attributes.VariantAttr = release
    - org.gradle.category                                      = library
    - org.gradle.jvm.environment                               = android
    - org.gradle.usage                                         = java-api
    - org.jetbrains.kotlin.platform.type                       = androidJvm

Secondary Variants (*)

    --------------------------------------------------
    Secondary Variant android-classes-jar
    --------------------------------------------------
    
    Attributes
        - com.android.build.api.attributes.AgpVersionAttr          = 7.4.2
        - com.android.build.api.attributes.BuildTypeAttr           = release
        - com.android.build.gradle.internal.attributes.VariantAttr = release
        - org.gradle.category                                      = library
        - org.gradle.jvm.environment                               = android
        - org.gradle.usage                                         = java-api
        - org.jetbrains.kotlin.platform.type                       = androidJvm
    Artifacts
        - build/intermediates/compile_library_classes_jar/release/classes.jar (artifactType = android-classes-jar)
to try and debug the issue I made this task, which maybe has a bug, but it’s similar to what I’m using in my plugin
Copy code
val dumpConfigurationContents by tasks.registering {
  group = "help"
  val configurationFiles = objects.mapProperty<String, FileCollection>()

  val configurations = project.configurations

  configurations
    .matching { it.isCanBeResolved }
    .all {
      val contents = incoming
        .artifactView { lenient(true) }
        .artifacts
        .artifactFiles

      configurationFiles.put(name, contents)
    }

  doLast {
    configurationFiles.get().forEach { (name, files) ->
      println("-----------------------------------")
      println(name)
      println()
      println(files.joinToString("\n") { " - ${it.name}" })
      println()
      println("-----------------------------------")
    }
  }
}
t
I think you'll want to resolve the configurations when the task is executed rather than when it's configured: move everything except the
group = "help"
line to the
doLast
block.
a
no effect :(
v
Not sure without playing with it, but I think you have to request the
artifactType = android-classes-jar
, so
Copy code
attributes {
    attribute(ArtifactTypeDefinition.ARTIFACT_TYPE_ATTRIBUTE, "android-classes-jar")
}
thank you 1
👍 1
a
I finally got it working by using
withVariantReselection()
! and adding either of these (some sort of mysterious compatibility rule I guess?)
Copy code
attribute(AndroidArtifacts.ARTIFACT_TYPE, AndroidArtifacts.ArtifactType.JAR.type)
Copy code
attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage.JAVA_RUNTIME))
It was really confusing because
./gradlew outgoingVariants
didn’t contain this attribute, and the Gradle docs don’t really explain secondary variants in a way that I understand.
Copy code
val dumpConfigurationContents by tasks.registering {
  group = "help"
  val configurationFiles = objects.mapProperty<String, FileCollection>()

  val configurations = project.configurations

  configurations
    .matching { it.isCanBeResolved }
    .all {
      val contents = incoming
        .artifactView {
          withVariantReselection()
          attributes {
            attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage.JAVA_RUNTIME))
          }
          lenient(true)
        }
        .artifacts
        .artifactFiles

      configurationFiles.put(name, contents)
    }

  doLast {
    configurationFiles.get().forEach { (name, files) ->
      println("-----------------------------------")
      println(name)
      println()
      println(files.joinToString("\n") { " - ${it.name}" })
      println()
      println("-----------------------------------")
    }
  }
}
v
You "just" have to know it is an attribute too. 🙂
Attributes are a bit confusing overall anyway. There is also a difference between configuration attributes and artifact attributes when it comes to the actual resolution, but you declare them the same. 😕
👍 1
a
🤦 d’oh, thanks. I remember that now, somewhere in the docs it say that ‘artifact type’ is an attribute, but a special one
t
That one? https://docs.gradle.org/current/userguide/artifact_transforms.html#artifact_transform_selection_and_execution
The
artifactType
attribute is special, since it is only present on resolved artifacts and not on dependencies. As a consequence, any transform which is only mutating
artifactType
will never be selected when resolving a configuration with only the
artifactType
as requested attribute. It will only be considered when using an ArtifactView.
a
Ah yes, that’s the one @Thomas Broyer, thanks