|
| 1 | +import com.android.build.api.attributes.BuildTypeAttr |
| 2 | + |
1 | 3 | plugins {
|
2 | 4 | id("org.gradle.java")
|
3 | 5 | id("org.example.gradle.base.lifecycle")
|
4 | 6 | id("org.example.gradle.base.dependency-rules")
|
5 | 7 | id("org.example.gradle.check.format-gradle")
|
6 |
| - id("org.example.gradle.report.code-coverage") |
| 8 | + // id("org.example.gradle.report.code-coverage") |
7 | 9 | id("org.example.gradle.report.plugin-analysis")
|
8 | 10 | id("org.example.gradle.report.sbom")
|
9 |
| - id("org.example.gradle.report.test") |
| 11 | + // id("org.example.gradle.report.test") |
10 | 12 | }
|
11 | 13 |
|
12 | 14 | dependencies { implementation(projects.app) }
|
| 15 | + |
| 16 | +configurations { |
| 17 | + compileClasspath { selectRelease() } |
| 18 | + runtimeClasspath { selectRelease() } |
| 19 | + testCompileClasspath { selectRelease() } |
| 20 | + testRuntimeClasspath { selectRelease() } |
| 21 | +} |
| 22 | + |
| 23 | +fun Configuration.selectRelease() { |
| 24 | + attributes.attribute(ArtifactTypeDefinition.ARTIFACT_TYPE_ATTRIBUTE, "jar") |
| 25 | + attributes.attribute(BuildTypeAttr.ATTRIBUTE, objects.named("release")) |
| 26 | +} |
| 27 | + |
| 28 | +// Allow AARs to appear along JARs on the joint classpath for reports |
| 29 | +dependencies { |
| 30 | + attributesSchema { getMatchingStrategy(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE).compatibilityRules.add(AarJarCompatibility::class.java) } |
| 31 | + attributesSchema { getMatchingStrategy(ArtifactTypeDefinition.ARTIFACT_TYPE_ATTRIBUTE).compatibilityRules.add(AarJarStringCompatibility::class.java) } |
| 32 | +} |
| 33 | + |
| 34 | +class AarJarCompatibility : AttributeCompatibilityRule<LibraryElements> { |
| 35 | + override fun execute(details: CompatibilityCheckDetails<LibraryElements>) { |
| 36 | + if (details.producerValue?.name == "aar") { |
| 37 | + details.compatible() |
| 38 | + } |
| 39 | + } |
| 40 | +} |
| 41 | + |
| 42 | +class AarJarStringCompatibility : AttributeCompatibilityRule<String> { |
| 43 | + override fun execute(details: CompatibilityCheckDetails<String>) { |
| 44 | + if (details.producerValue == "aar" || details.producerValue == "android-classes-jar") { |
| 45 | + details.compatible() |
| 46 | + } |
| 47 | + } |
| 48 | +} |
0 commit comments