Skip to content

Commit

Permalink
Set the org.gradle.jvm.environment capability.
Browse files Browse the repository at this point in the history
In cases where a module produces a JVM and Android artifact, we want
consuming Android projects to match against the Android variant, not the
JVM variant. Adding an AttributeCompatibilityRule for the variant's
TargetJvmEnvironment is not possible since there is already one
registered by the ecosystem plugin that marks all values as compatible.
  • Loading branch information
christiandeange committed Sep 7, 2024
1 parent 9e1bb7c commit 725c6e1
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -5,6 +5,8 @@ package sh.christian.aaraar.gradle
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.artifacts.type.ArtifactTypeDefinition.ARTIFACT_TYPE_ATTRIBUTE
import org.gradle.api.attributes.java.TargetJvmEnvironment
import org.gradle.api.attributes.java.TargetJvmEnvironment.TARGET_JVM_ENVIRONMENT_ATTRIBUTE
import org.gradle.api.publish.maven.tasks.AbstractPublishToMaven
import org.gradle.api.publish.tasks.GenerateModuleMetadata
import org.gradle.api.tasks.bundling.Jar
@@ -77,6 +79,9 @@ class AarAarPlugin : Plugin<Project> {
isTransitive = false
isCanBeConsumed = true
isCanBeResolved = true
attributes {
attribute(TARGET_JVM_ENVIRONMENT_ATTRIBUTE, objects.named(TargetJvmEnvironment.STANDARD_JVM))
}
}

val jarTask = tasks.named<Jar>("jar")
@@ -121,6 +126,7 @@ class AarAarPlugin : Plugin<Project> {
isCanBeResolved = true
attributes {
attribute(ARTIFACT_TYPE_ATTRIBUTE, MERGEABLE_ARTIFACT_TYPE)
attribute(TARGET_JVM_ENVIRONMENT_ATTRIBUTE, objects.named(TargetJvmEnvironment.ANDROID))
}
}

0 comments on commit 725c6e1

Please sign in to comment.