diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index bfda9c705..c8a39a0ea 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -302,3 +302,27 @@ jobs: with: name: booster-android-gradle-v7_2 path: booster-android-gradle-v7_2/build/reports/tests/integrationTest + + integration-test-agp-v7_3: + name: AGP 7.3 Integration Test + needs: build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-java@v3 + with: + distribution: 'adopt' + java-version: '11' + cache: 'gradle' + - uses: actions/cache@v3 + with: + path: ~/.m2 + key: ${{ runner.os }}-m2-${{ github.run_number }} + - shell: bash + run: ./gradlew booster-android-gradle-v7_3:integrationTest -S --no-daemon -Pversion=${{ github.run_number }} + - uses: actions/upload-artifact@v3 + if: failure() + with: + name: booster-android-gradle-v7_3 + path: booster-android-gradle-v7_3/build/reports/tests/integrationTest + diff --git a/booster-android-gradle-api/src/main/kotlin/com/didiglobal/booster/gradle/BaseVariant.kt b/booster-android-gradle-api/src/main/kotlin/com/didiglobal/booster/gradle/BaseVariant.kt index 97c0cad48..57472121f 100644 --- a/booster-android-gradle-api/src/main/kotlin/com/didiglobal/booster/gradle/BaseVariant.kt +++ b/booster-android-gradle-api/src/main/kotlin/com/didiglobal/booster/gradle/BaseVariant.kt @@ -14,6 +14,7 @@ import org.gradle.api.UnknownTaskException import org.gradle.api.artifacts.ArtifactCollection import org.gradle.api.artifacts.result.ResolvedArtifactResult import org.gradle.api.file.FileCollection +import org.gradle.api.provider.Provider import org.gradle.api.tasks.TaskProvider import java.io.File diff --git a/booster-android-gradle-api/src/main/kotlin/com/didiglobal/booster/gradle/TransformInvocation.kt b/booster-android-gradle-api/src/main/kotlin/com/didiglobal/booster/gradle/TransformInvocation.kt index adfb0b331..e0c513a3f 100644 --- a/booster-android-gradle-api/src/main/kotlin/com/didiglobal/booster/gradle/TransformInvocation.kt +++ b/booster-android-gradle-api/src/main/kotlin/com/didiglobal/booster/gradle/TransformInvocation.kt @@ -2,6 +2,7 @@ package com.didiglobal.booster.gradle import com.android.build.api.transform.TransformInvocation import com.android.build.gradle.api.BaseVariant +import com.android.builder.model.ApiVersion import org.gradle.api.Project import java.io.File @@ -21,6 +22,9 @@ val TransformInvocation.project: Project val TransformInvocation.variant: BaseVariant get() = AGP.run { variant } +val TransformInvocation.targetSdkVersion: ApiVersion + get() = AGP.run { variant.targetSdkVersion } + val TransformInvocation.bootClasspath: Collection get() = AGP.run { bootClasspath } diff --git a/booster-android-gradle-compat/src/main/kotlin/com/didiglobal/booster/gradle/AGPInterface.kt b/booster-android-gradle-compat/src/main/kotlin/com/didiglobal/booster/gradle/AGPInterface.kt index 96db2c72a..53622ef3c 100644 --- a/booster-android-gradle-compat/src/main/kotlin/com/didiglobal/booster/gradle/AGPInterface.kt +++ b/booster-android-gradle-compat/src/main/kotlin/com/didiglobal/booster/gradle/AGPInterface.kt @@ -96,10 +96,15 @@ interface AGPInterface { val BaseVariant.variantScope: VariantScope + @Deprecated( + message = "Use BaseVariant.namespace instead", + replaceWith = ReplaceWith(expression = "variant.namespace"), + ) val BaseVariant.originalApplicationId: String val BaseVariant.hasDynamicFeature: Boolean + @Deprecated(message = "Deprecated, don't use it") val BaseVariant.rawAndroidResources: FileCollection val BaseVariant.javaCompilerTaskProvider: TaskProvider @@ -181,6 +186,7 @@ interface AGPInterface { ) val Project.aapt2Enabled: Boolean + @Suppress("DEPRECATION") val Project.isAapt2Enabled: Boolean get() = aapt2Enabled diff --git a/booster-android-gradle-v3_3/src/integrationTest/kotlin/com/didiglobal/booster/android/gradle/v3_3/V33IntegrationTest.kt b/booster-android-gradle-v3_3/src/integrationTest/kotlin/com/didiglobal/booster/android/gradle/v3_3/V33IntegrationTest.kt index cdca9a74d..543283cce 100644 --- a/booster-android-gradle-v3_3/src/integrationTest/kotlin/com/didiglobal/booster/android/gradle/v3_3/V33IntegrationTest.kt +++ b/booster-android-gradle-v3_3/src/integrationTest/kotlin/com/didiglobal/booster/android/gradle/v3_3/V33IntegrationTest.kt @@ -6,7 +6,6 @@ import com.android.build.gradle.AppExtension import com.android.build.gradle.BaseExtension import com.android.build.gradle.LibraryExtension import com.android.build.gradle.api.BaseVariant -import com.android.builder.core.VariantTypeImpl import com.android.sdklib.BuildToolInfo import com.didiglobal.booster.gradle.AGP import com.didiglobal.booster.gradle.getAndroid @@ -31,12 +30,11 @@ import kotlin.test.assertNotNull import kotlin.test.assertTrue import kotlin.test.fail -private const val MIN_SDK_VERSION = 18 +private val MIN_SDK_VERSION = System.getProperty("android.minsdk.version").toInt() private const val TARGET_SDK_VERSION = 26 -private val ARGS = arrayOf( - "assemble", "-S", +private val ARGS = System.getProperty("gradle.args").split("\\s+".toRegex()) + listOf( "-Pbooster_version=${Build.VERSION}", "-Pandroid_gradle_version=3.3.0", "-Pcompile_sdk_version=28", @@ -53,7 +51,7 @@ abstract class V33IntegrationTest(private val isLib: Boolean) { @get:Rule val ruleChain: TestRule = rule(projectDir) { rule(LocalProperties(projectDir::getRoot)) { - GradleExecutor(projectDir::getRoot, "4.10.1", *ARGS) + GradleExecutor(projectDir::getRoot, "4.10.1", *ARGS.toTypedArray()) } } @@ -139,10 +137,6 @@ abstract class V33IntegrationTest(private val isLib: Boolean) { @Case(TargetSdkVersionTestUnit::class) fun `test AGPInterface#targetSdkVersion`() = Unit - @Test - @Case(VariantTypeTestUnit::class) - fun `test AGPInterface#variantType`() = Unit - @Test @Case(AarTestUnit::class) fun `test AGPInterface#aar`() = Unit @@ -328,18 +322,6 @@ class TargetSdkVersionTestUnit : VariantTestCase() { } } -class VariantTypeTestUnit : VariantTestCase() { - override fun apply(variant: BaseVariant) { - val project = AGP.run { variant.project } - val variantType = AGP.run { variant.variantType } - if (project.plugins.hasPlugin("com.android.application")) { - assertEquals(VariantTypeImpl.BASE_APK, variantType) - } else if (project.plugins.hasPlugin("com.android.library")) { - assertEquals(VariantTypeImpl.LIBRARY, variantType) - } - } -} - class AarTestUnit : VariantTestCase() { override fun apply(project: Project) { if (project.plugins.hasPlugin("com.android.library")) { diff --git a/booster-android-gradle-v3_4/src/integrationTest/kotlin/com/didiglobal/booster/android/gradle/v3_4/V34IntegrationTest.kt b/booster-android-gradle-v3_4/src/integrationTest/kotlin/com/didiglobal/booster/android/gradle/v3_4/V34IntegrationTest.kt index e75fa5e03..eb400dda4 100644 --- a/booster-android-gradle-v3_4/src/integrationTest/kotlin/com/didiglobal/booster/android/gradle/v3_4/V34IntegrationTest.kt +++ b/booster-android-gradle-v3_4/src/integrationTest/kotlin/com/didiglobal/booster/android/gradle/v3_4/V34IntegrationTest.kt @@ -6,7 +6,6 @@ import com.android.build.gradle.AppExtension import com.android.build.gradle.BaseExtension import com.android.build.gradle.LibraryExtension import com.android.build.gradle.api.BaseVariant -import com.android.builder.core.VariantTypeImpl import com.android.sdklib.BuildToolInfo import com.didiglobal.booster.gradle.AGP import com.didiglobal.booster.gradle.getAndroid @@ -31,12 +30,11 @@ import kotlin.test.assertNotNull import kotlin.test.assertTrue import kotlin.test.fail -private const val MIN_SDK_VERSION = 18 +private val MIN_SDK_VERSION = System.getProperty("android.minsdk.version").toInt() private const val TARGET_SDK_VERSION = 26 -private val ARGS = arrayOf( - "assemble", "-S", +private val ARGS = System.getProperty("gradle.args").split("\\s+".toRegex()) + listOf( "-Pbooster_version=${Build.VERSION}", "-Pandroid_gradle_version=3.4.0", "-Pcompile_sdk_version=28", @@ -53,7 +51,7 @@ abstract class V34IntegrationTest(private val isLib: Boolean) { @get:Rule val ruleChain: TestRule = rule(projectDir) { rule(LocalProperties(projectDir::getRoot)) { - GradleExecutor(projectDir::getRoot, "5.1.1", *ARGS) + GradleExecutor(projectDir::getRoot, "5.1.1", *ARGS.toTypedArray()) } } @@ -139,10 +137,6 @@ abstract class V34IntegrationTest(private val isLib: Boolean) { @Case(TargetSdkVersionTestUnit::class) fun `test AGPInterface#targetSdkVersion`() = Unit - @Test - @Case(VariantTypeTestUnit::class) - fun `test AGPInterface#variantType`() = Unit - @Test @Case(AarTestUnit::class) fun `test AGPInterface#aar`() = Unit @@ -328,18 +322,6 @@ class TargetSdkVersionTestUnit : VariantTestCase() { } } -class VariantTypeTestUnit : VariantTestCase() { - override fun apply(variant: BaseVariant) { - val project = AGP.run { variant.project } - val variantType = AGP.run { variant.variantType } - if (project.plugins.hasPlugin("com.android.application")) { - assertEquals(VariantTypeImpl.BASE_APK, variantType) - } else if (project.plugins.hasPlugin("com.android.library")) { - assertEquals(VariantTypeImpl.LIBRARY, variantType) - } - } -} - class AarTestUnit : VariantTestCase() { override fun apply(project: Project) { if (project.plugins.hasPlugin("com.android.library")) { diff --git a/booster-android-gradle-v3_5/src/integrationTest/kotlin/com/didiglobal/booster/android/gradle/v3_5/V35IntegrationTest.kt b/booster-android-gradle-v3_5/src/integrationTest/kotlin/com/didiglobal/booster/android/gradle/v3_5/V35IntegrationTest.kt index de074837c..6107e68e6 100644 --- a/booster-android-gradle-v3_5/src/integrationTest/kotlin/com/didiglobal/booster/android/gradle/v3_5/V35IntegrationTest.kt +++ b/booster-android-gradle-v3_5/src/integrationTest/kotlin/com/didiglobal/booster/android/gradle/v3_5/V35IntegrationTest.kt @@ -6,7 +6,6 @@ import com.android.build.gradle.AppExtension import com.android.build.gradle.BaseExtension import com.android.build.gradle.LibraryExtension import com.android.build.gradle.api.BaseVariant -import com.android.builder.core.VariantTypeImpl import com.android.sdklib.BuildToolInfo import com.didiglobal.booster.gradle.AGP import com.didiglobal.booster.gradle.getAndroid @@ -31,18 +30,17 @@ import kotlin.test.assertNotNull import kotlin.test.assertTrue import kotlin.test.fail -private const val MIN_SDK_VERSION = 18 +private val MIN_SDK_VERSION = System.getProperty("android.minsdk.version").toInt() private const val TARGET_SDK_VERSION = 26 -private val ARGS = arrayOf( - "assemble", "-S", +private val ARGS = System.getProperty("gradle.args").split("\\s+".toRegex()) + listOf( "-Pbooster_version=${Build.VERSION}", "-Pandroid_gradle_version=3.5.0", "-Pcompile_sdk_version=28", "-Pbuild_tools_version=26.0.3", "-Pmin_sdk_version=${MIN_SDK_VERSION}", - "-Ptarget_sdk_version=${TARGET_SDK_VERSION}" + "-Ptarget_sdk_version=${TARGET_SDK_VERSION}", ) @Suppress("RemoveCurlyBracesFromTemplate", "FunctionName") @@ -53,7 +51,7 @@ abstract class V35IntegrationTest(private val isLib: Boolean) { @get:Rule val ruleChain: TestRule = rule(projectDir) { rule(LocalProperties(projectDir::getRoot)) { - GradleExecutor(projectDir::getRoot, "5.4.1", *ARGS) + GradleExecutor(projectDir::getRoot, "5.4.1", *ARGS.toTypedArray()) } } @@ -139,10 +137,6 @@ abstract class V35IntegrationTest(private val isLib: Boolean) { @Case(TargetSdkVersionTestUnit::class) fun `test AGPInterface#targetSdkVersion`() = Unit - @Test - @Case(VariantTypeTestUnit::class) - fun `test AGPInterface#variantType`() = Unit - @Test @Case(AarTestUnit::class) fun `test AGPInterface#aar`() = Unit @@ -328,18 +322,6 @@ class TargetSdkVersionTestUnit : VariantTestCase() { } } -class VariantTypeTestUnit : VariantTestCase() { - override fun apply(variant: BaseVariant) { - val project = AGP.run { variant.project } - val variantType = AGP.run { variant.variantType } - if (project.plugins.hasPlugin("com.android.application")) { - assertEquals(VariantTypeImpl.BASE_APK, variantType) - } else if (project.plugins.hasPlugin("com.android.library")) { - assertEquals(VariantTypeImpl.LIBRARY, variantType) - } - } -} - class AarTestUnit : VariantTestCase() { override fun apply(project: Project) { if (project.plugins.hasPlugin("com.android.library")) { diff --git a/booster-android-gradle-v3_5/src/main/kotlin/com/didiglobal/booster/android/gradle/v3_5/V35.kt b/booster-android-gradle-v3_5/src/main/kotlin/com/didiglobal/booster/android/gradle/v3_5/V35.kt index c865e1da4..952270cdc 100644 --- a/booster-android-gradle-v3_5/src/main/kotlin/com/didiglobal/booster/android/gradle/v3_5/V35.kt +++ b/booster-android-gradle-v3_5/src/main/kotlin/com/didiglobal/booster/android/gradle/v3_5/V35.kt @@ -4,9 +4,6 @@ import com.android.build.api.artifact.ArtifactType import com.android.build.api.artifact.BuildArtifactType import com.android.build.api.transform.Context import com.android.build.api.transform.QualifiedContent -import com.android.build.gradle.AppPlugin -import com.android.build.gradle.DynamicFeaturePlugin -import com.android.build.gradle.LibraryPlugin import com.android.build.gradle.api.ApplicationVariant import com.android.build.gradle.api.BaseVariant import com.android.build.gradle.api.LibraryVariant diff --git a/booster-android-gradle-v3_6/src/integrationTest/kotlin/com/didiglobal/booster/android/gradle/v3_6/V36IntegrationTest.kt b/booster-android-gradle-v3_6/src/integrationTest/kotlin/com/didiglobal/booster/android/gradle/v3_6/V36IntegrationTest.kt index 711fc5619..d9feb8e9f 100644 --- a/booster-android-gradle-v3_6/src/integrationTest/kotlin/com/didiglobal/booster/android/gradle/v3_6/V36IntegrationTest.kt +++ b/booster-android-gradle-v3_6/src/integrationTest/kotlin/com/didiglobal/booster/android/gradle/v3_6/V36IntegrationTest.kt @@ -6,7 +6,6 @@ import com.android.build.gradle.AppExtension import com.android.build.gradle.BaseExtension import com.android.build.gradle.LibraryExtension import com.android.build.gradle.api.BaseVariant -import com.android.builder.core.VariantTypeImpl import com.android.sdklib.BuildToolInfo import com.didiglobal.booster.gradle.AGP import com.didiglobal.booster.gradle.getAndroid @@ -31,12 +30,11 @@ import kotlin.test.assertNotNull import kotlin.test.assertTrue import kotlin.test.fail -private const val MIN_SDK_VERSION = 18 +private val MIN_SDK_VERSION = System.getProperty("android.minsdk.version").toInt() private const val TARGET_SDK_VERSION = 26 -private val ARGS = arrayOf( - "assemble", "-S", +private val ARGS = System.getProperty("gradle.args").split("\\s+".toRegex()) + listOf( "-Pbooster_version=${Build.VERSION}", "-Pandroid_gradle_version=3.6.0", "-Pcompile_sdk_version=28", @@ -53,7 +51,7 @@ abstract class V36IntegrationTest(private val isLib: Boolean) { @get:Rule val ruleChain: TestRule = rule(projectDir) { rule(LocalProperties(projectDir::getRoot)) { - GradleExecutor(projectDir::getRoot, "5.6.4", *ARGS) + GradleExecutor(projectDir::getRoot, "5.6.4", *ARGS.toTypedArray()) } } @@ -139,10 +137,6 @@ abstract class V36IntegrationTest(private val isLib: Boolean) { @Case(TargetSdkVersionTestUnit::class) fun `test AGPInterface#targetSdkVersion`() = Unit - @Test - @Case(VariantTypeTestUnit::class) - fun `test AGPInterface#variantType`() = Unit - @Test @Case(AarTestUnit::class) fun `test AGPInterface#aar`() = Unit @@ -328,18 +322,6 @@ class TargetSdkVersionTestUnit : VariantTestCase() { } } -class VariantTypeTestUnit : VariantTestCase() { - override fun apply(variant: BaseVariant) { - val project = AGP.run { variant.project } - val variantType = AGP.run { variant.variantType } - if (project.plugins.hasPlugin("com.android.application")) { - assertEquals(VariantTypeImpl.BASE_APK, variantType) - } else if (project.plugins.hasPlugin("com.android.library")) { - assertEquals(VariantTypeImpl.LIBRARY, variantType) - } - } -} - class AarTestUnit : VariantTestCase() { override fun apply(project: Project) { if (project.plugins.hasPlugin("com.android.library")) { diff --git a/booster-android-gradle-v4_0/src/integrationTest/kotlin/com/didiglobal/booster/android/gradle/v4_0/V40IntegrationTest.kt b/booster-android-gradle-v4_0/src/integrationTest/kotlin/com/didiglobal/booster/android/gradle/v4_0/V40IntegrationTest.kt index 541c8728e..280f28552 100644 --- a/booster-android-gradle-v4_0/src/integrationTest/kotlin/com/didiglobal/booster/android/gradle/v4_0/V40IntegrationTest.kt +++ b/booster-android-gradle-v4_0/src/integrationTest/kotlin/com/didiglobal/booster/android/gradle/v4_0/V40IntegrationTest.kt @@ -6,7 +6,6 @@ import com.android.build.gradle.AppExtension import com.android.build.gradle.BaseExtension import com.android.build.gradle.LibraryExtension import com.android.build.gradle.api.BaseVariant -import com.android.builder.core.VariantTypeImpl import com.android.sdklib.BuildToolInfo import com.didiglobal.booster.gradle.AGP import com.didiglobal.booster.gradle.getAndroid @@ -31,12 +30,11 @@ import kotlin.test.assertNotNull import kotlin.test.assertTrue import kotlin.test.fail -private const val MIN_SDK_VERSION = 18 +private val MIN_SDK_VERSION = System.getProperty("android.minsdk.version").toInt() private const val TARGET_SDK_VERSION = 26 -private val ARGS = arrayOf( - "assemble", "-S", +private val ARGS = System.getProperty("gradle.args").split("\\s+".toRegex()) + listOf( "-Pbooster_version=${Build.VERSION}", "-Pandroid_gradle_version=4.0.0", "-Pcompile_sdk_version=28", @@ -53,7 +51,7 @@ abstract class V40IntegrationTest(private val isLib: Boolean) { @get:Rule val ruleChain: TestRule = rule(projectDir) { rule(LocalProperties(projectDir::getRoot)) { - GradleExecutor(projectDir::getRoot, "6.1.1", *ARGS) + GradleExecutor(projectDir::getRoot, "6.1.1", *ARGS.toTypedArray()) } } @@ -139,10 +137,6 @@ abstract class V40IntegrationTest(private val isLib: Boolean) { @Case(TargetSdkVersionTestUnit::class) fun `test AGPInterface#targetSdkVersion`() = Unit - @Test - @Case(VariantTypeTestUnit::class) - fun `test AGPInterface#variantType`() = Unit - @Test @Case(AarTestUnit::class) fun `test AGPInterface#aar`() = Unit @@ -328,18 +322,6 @@ class TargetSdkVersionTestUnit : VariantTestCase() { } } -class VariantTypeTestUnit : VariantTestCase() { - override fun apply(variant: BaseVariant) { - val project = AGP.run { variant.project } - val variantType = AGP.run { variant.variantType } - if (project.plugins.hasPlugin("com.android.application")) { - assertEquals(VariantTypeImpl.BASE_APK, variantType) - } else if (project.plugins.hasPlugin("com.android.library")) { - assertEquals(VariantTypeImpl.LIBRARY, variantType) - } - } -} - class AarTestUnit : VariantTestCase() { override fun apply(project: Project) { if (project.plugins.hasPlugin("com.android.library")) { diff --git a/booster-android-gradle-v4_0/src/main/kotlin/com/didiglobal/booster/android/gradle/v4_0/V40.kt b/booster-android-gradle-v4_0/src/main/kotlin/com/didiglobal/booster/android/gradle/v4_0/V40.kt index 406e237bb..859c2289b 100644 --- a/booster-android-gradle-v4_0/src/main/kotlin/com/didiglobal/booster/android/gradle/v4_0/V40.kt +++ b/booster-android-gradle-v4_0/src/main/kotlin/com/didiglobal/booster/android/gradle/v4_0/V40.kt @@ -2,9 +2,6 @@ package com.didiglobal.booster.android.gradle.v4_0 import com.android.build.api.transform.Context import com.android.build.api.transform.QualifiedContent -import com.android.build.gradle.AppPlugin -import com.android.build.gradle.DynamicFeaturePlugin -import com.android.build.gradle.LibraryPlugin import com.android.build.gradle.api.ApplicationVariant import com.android.build.gradle.api.BaseVariant import com.android.build.gradle.api.LibraryVariant diff --git a/booster-android-gradle-v4_1/src/integrationTest/kotlin/com/didiglobal/booster/android/gradle/v4_1/V41IntegrationTest.kt b/booster-android-gradle-v4_1/src/integrationTest/kotlin/com/didiglobal/booster/android/gradle/v4_1/V41IntegrationTest.kt index e4a28b2df..f8e2b1cba 100644 --- a/booster-android-gradle-v4_1/src/integrationTest/kotlin/com/didiglobal/booster/android/gradle/v4_1/V41IntegrationTest.kt +++ b/booster-android-gradle-v4_1/src/integrationTest/kotlin/com/didiglobal/booster/android/gradle/v4_1/V41IntegrationTest.kt @@ -6,7 +6,6 @@ import com.android.build.gradle.AppExtension import com.android.build.gradle.BaseExtension import com.android.build.gradle.LibraryExtension import com.android.build.gradle.api.BaseVariant -import com.android.builder.core.VariantTypeImpl import com.android.sdklib.BuildToolInfo import com.didiglobal.booster.gradle.AGP import com.didiglobal.booster.gradle.getAndroid @@ -31,12 +30,11 @@ import kotlin.test.assertNotNull import kotlin.test.assertTrue import kotlin.test.fail -private const val MIN_SDK_VERSION = 18 +private val MIN_SDK_VERSION = System.getProperty("android.minsdk.version").toInt() private const val TARGET_SDK_VERSION = 26 -private val ARGS = arrayOf( - "assemble", "-S", +private val ARGS = System.getProperty("gradle.args").split("\\s+".toRegex()) + listOf( "-Pbooster_version=${Build.VERSION}", "-Pandroid_gradle_version=4.1.0", "-Pcompile_sdk_version=28", @@ -53,7 +51,7 @@ abstract class V41IntegrationTest(val isLib: Boolean) { @get:Rule val ruleChain: TestRule = rule(projectDir) { rule(LocalProperties(projectDir::getRoot)) { - GradleExecutor(projectDir::getRoot, "6.5", *ARGS) + GradleExecutor(projectDir::getRoot, "6.5", *ARGS.toTypedArray()) } } @@ -139,10 +137,6 @@ abstract class V41IntegrationTest(val isLib: Boolean) { @Case(TargetSdkVersionTestUnit::class) fun `test AGPInterface#targetSdkVersion`() = Unit - @Test - @Case(VariantTypeTestUnit::class) - fun `test AGPInterface#variantType`() = Unit - @Test @Case(AarTestUnit::class) fun `test AGPInterface#aar`() = Unit @@ -328,18 +322,6 @@ class TargetSdkVersionTestUnit : VariantTestCase() { } } -class VariantTypeTestUnit : VariantTestCase() { - override fun apply(variant: BaseVariant) { - val project = AGP.run { variant.project } - val variantType = AGP.run { variant.variantType } - if (project.plugins.hasPlugin("com.android.application")) { - assertEquals(VariantTypeImpl.BASE_APK, variantType) - } else if (project.plugins.hasPlugin("com.android.library")) { - assertEquals(VariantTypeImpl.LIBRARY, variantType) - } - } -} - class AarTestUnit : VariantTestCase() { override fun apply(project: Project) { if (project.plugins.hasPlugin("com.android.library")) { diff --git a/booster-android-gradle-v4_1/src/main/kotlin/com/didiglobal/booster/android/gradle/v4_1/V41.kt b/booster-android-gradle-v4_1/src/main/kotlin/com/didiglobal/booster/android/gradle/v4_1/V41.kt index fccd0310b..7c9906596 100644 --- a/booster-android-gradle-v4_1/src/main/kotlin/com/didiglobal/booster/android/gradle/v4_1/V41.kt +++ b/booster-android-gradle-v4_1/src/main/kotlin/com/didiglobal/booster/android/gradle/v4_1/V41.kt @@ -7,9 +7,6 @@ import com.android.build.api.artifact.impl.ArtifactsImpl import com.android.build.api.component.impl.ComponentPropertiesImpl import com.android.build.api.transform.Context import com.android.build.api.transform.QualifiedContent -import com.android.build.gradle.AppPlugin -import com.android.build.gradle.DynamicFeaturePlugin -import com.android.build.gradle.LibraryPlugin import com.android.build.gradle.api.ApplicationVariant import com.android.build.gradle.api.BaseVariant import com.android.build.gradle.api.LibraryVariant diff --git a/booster-android-gradle-v4_2/src/integrationTest/kotlin/com/didiglobal/booster/android/gradle/v4_2/V42IntegrationTest.kt b/booster-android-gradle-v4_2/src/integrationTest/kotlin/com/didiglobal/booster/android/gradle/v4_2/V42IntegrationTest.kt index 9f6421524..c439a0921 100644 --- a/booster-android-gradle-v4_2/src/integrationTest/kotlin/com/didiglobal/booster/android/gradle/v4_2/V42IntegrationTest.kt +++ b/booster-android-gradle-v4_2/src/integrationTest/kotlin/com/didiglobal/booster/android/gradle/v4_2/V42IntegrationTest.kt @@ -6,7 +6,6 @@ import com.android.build.gradle.AppExtension import com.android.build.gradle.BaseExtension import com.android.build.gradle.LibraryExtension import com.android.build.gradle.api.BaseVariant -import com.android.builder.core.VariantTypeImpl import com.android.sdklib.BuildToolInfo import com.didiglobal.booster.gradle.AGP import com.didiglobal.booster.gradle.getAndroid @@ -31,12 +30,11 @@ import kotlin.test.assertNotNull import kotlin.test.assertTrue import kotlin.test.fail -private const val MIN_SDK_VERSION = 18 +private val MIN_SDK_VERSION = System.getProperty("android.minsdk.version").toInt() private const val TARGET_SDK_VERSION = 26 -private val ARGS = arrayOf( - "assemble", "-S", +private val ARGS = System.getProperty("gradle.args").split("\\s+".toRegex()) + listOf( "-Pbooster_version=${Build.VERSION}", "-Pandroid_gradle_version=4.2.1", "-Pcompile_sdk_version=28", @@ -53,7 +51,7 @@ abstract class V42IntegrationTest(val isLib: Boolean) { @get:Rule val ruleChain: TestRule = rule(projectDir) { rule(LocalProperties(projectDir::getRoot)) { - GradleExecutor(projectDir::getRoot, "6.7.1", *ARGS) + GradleExecutor(projectDir::getRoot, "6.7.1", *ARGS.toTypedArray()) } } @@ -139,10 +137,6 @@ abstract class V42IntegrationTest(val isLib: Boolean) { @Case(TargetSdkVersionTestUnit::class) fun `test AGPInterface#targetSdkVersion`() = Unit - @Test - @Case(VariantTypeTestUnit::class) - fun `test AGPInterface#variantType`() = Unit - @Test @Case(AarTestUnit::class) fun `test AGPInterface#aar`() = Unit @@ -328,18 +322,6 @@ class TargetSdkVersionTestUnit : VariantTestCase() { } } -class VariantTypeTestUnit : VariantTestCase() { - override fun apply(variant: BaseVariant) { - val project = AGP.run { variant.project } - val variantType = AGP.run { variant.variantType } - if (project.plugins.hasPlugin("com.android.application")) { - assertEquals(VariantTypeImpl.BASE_APK, variantType) - } else if (project.plugins.hasPlugin("com.android.library")) { - assertEquals(VariantTypeImpl.LIBRARY, variantType) - } - } -} - class AarTestUnit : VariantTestCase() { override fun apply(project: Project) { if (project.plugins.hasPlugin("com.android.library")) { diff --git a/booster-android-gradle-v4_2/src/integrationTest/resources/app.gradle b/booster-android-gradle-v4_2/src/integrationTest/resources/app.gradle index a9db67a64..aa3c5f2d6 100644 --- a/booster-android-gradle-v4_2/src/integrationTest/resources/app.gradle +++ b/booster-android-gradle-v4_2/src/integrationTest/resources/app.gradle @@ -11,7 +11,7 @@ buildscript { classpath("com.didiglobal.booster:booster-gradle-plugin:${project.booster_version}") { exclude group: 'com.google.guava' } - classpath "io.bootstage.testkit:testkit-gradle-plugin:1.1.0" + classpath "io.bootstage.testkit:testkit-gradle-plugin:1.4.0" } } diff --git a/booster-android-gradle-v4_2/src/integrationTest/resources/buildSrc/build.gradle b/booster-android-gradle-v4_2/src/integrationTest/resources/buildSrc/build.gradle index bb9648dce..79a9b104a 100644 --- a/booster-android-gradle-v4_2/src/integrationTest/resources/buildSrc/build.gradle +++ b/booster-android-gradle-v4_2/src/integrationTest/resources/buildSrc/build.gradle @@ -20,5 +20,5 @@ dependencies { implementation("com.didiglobal.booster:booster-android-gradle-api:${project.booster_version}") { exclude group: 'com.google.guava' } - implementation "io.bootstage.testkit:testkit-gradle-plugin:1.1.0" + implementation "io.bootstage.testkit:testkit-gradle-plugin:1.4.0" } diff --git a/booster-android-gradle-v4_2/src/integrationTest/resources/lib.gradle b/booster-android-gradle-v4_2/src/integrationTest/resources/lib.gradle index 64a9540e9..adc9b1ca0 100644 --- a/booster-android-gradle-v4_2/src/integrationTest/resources/lib.gradle +++ b/booster-android-gradle-v4_2/src/integrationTest/resources/lib.gradle @@ -11,7 +11,7 @@ buildscript { classpath("com.didiglobal.booster:booster-gradle-plugin:${project.booster_version}") { exclude group: 'com.google.guava' } - classpath "io.bootstage.testkit:testkit-gradle-plugin:1.1.0" + classpath "io.bootstage.testkit:testkit-gradle-plugin:1.4.0" } } diff --git a/booster-android-gradle-v4_2/src/main/kotlin/com/didiglobal/booster/android/gradle/v4_2/V42.kt b/booster-android-gradle-v4_2/src/main/kotlin/com/didiglobal/booster/android/gradle/v4_2/V42.kt index 2fc0be9c9..33b03d957 100644 --- a/booster-android-gradle-v4_2/src/main/kotlin/com/didiglobal/booster/android/gradle/v4_2/V42.kt +++ b/booster-android-gradle-v4_2/src/main/kotlin/com/didiglobal/booster/android/gradle/v4_2/V42.kt @@ -7,9 +7,6 @@ import com.android.build.api.artifact.impl.ArtifactsImpl import com.android.build.api.component.impl.ComponentImpl import com.android.build.api.transform.Context import com.android.build.api.transform.QualifiedContent -import com.android.build.gradle.AppPlugin -import com.android.build.gradle.DynamicFeaturePlugin -import com.android.build.gradle.LibraryPlugin import com.android.build.gradle.api.ApplicationVariant import com.android.build.gradle.api.BaseVariant import com.android.build.gradle.api.LibraryVariant @@ -251,7 +248,7 @@ internal object V42 : AGPInterface { override val BaseVariant.allClasses: FileCollection get() = when (this) { is ApplicationVariant -> getFinalArtifactFiles(InternalArtifactType.JAVAC) + project.files("build${File.separator}tmp${File.separator}kotlin-classes${File.separator}${dirName}") - is LibraryVariant -> getFinalArtifactFiles(InternalArtifactType.COMPILE_LIBRARY_CLASSES_JAR) + is LibraryVariant -> getFinalArtifactFiles(InternalArtifactType.AAR_MAIN_JAR) else -> project.files() } diff --git a/booster-android-gradle-v7_0/src/integrationTest/kotlin/com/didiglobal/booster/android/gradle/v7_0/V70IntegrationTest.kt b/booster-android-gradle-v7_0/src/integrationTest/kotlin/com/didiglobal/booster/android/gradle/v7_0/V70IntegrationTest.kt index fbf22c5d1..7dcf3ad92 100644 --- a/booster-android-gradle-v7_0/src/integrationTest/kotlin/com/didiglobal/booster/android/gradle/v7_0/V70IntegrationTest.kt +++ b/booster-android-gradle-v7_0/src/integrationTest/kotlin/com/didiglobal/booster/android/gradle/v7_0/V70IntegrationTest.kt @@ -6,7 +6,6 @@ import com.android.build.gradle.AppExtension import com.android.build.gradle.BaseExtension import com.android.build.gradle.LibraryExtension import com.android.build.gradle.api.BaseVariant -import com.android.builder.core.VariantTypeImpl import com.didiglobal.booster.gradle.AGP import com.didiglobal.booster.gradle.getAndroid import com.didiglobal.booster.kotlinx.search @@ -30,12 +29,11 @@ import kotlin.test.assertNotNull import kotlin.test.assertTrue import kotlin.test.fail -private const val MIN_SDK_VERSION = 18 +private val MIN_SDK_VERSION = System.getProperty("android.minsdk.version").toInt() private const val TARGET_SDK_VERSION = 30 -private val ARGS = arrayOf( - "assemble", "-S", +private val ARGS = System.getProperty("gradle.args").split("\\s+".toRegex()) + listOf( "-Pbooster_version=${Build.VERSION}", "-Pandroid_gradle_version=7.0.0", "-Pcompile_sdk_version=30", @@ -52,7 +50,7 @@ abstract class V70IntegrationTest(private val isLib: Boolean) { @get:Rule val ruleChain: TestRule = rule(projectDir) { rule(LocalProperties(projectDir::getRoot)) { - GradleExecutor(projectDir::getRoot, "7.0.2", *ARGS) + GradleExecutor(projectDir::getRoot, "7.0.2", *ARGS.toTypedArray()) } } @@ -138,11 +136,6 @@ abstract class V70IntegrationTest(private val isLib: Boolean) { @Case(TargetSdkVersionTestUnit::class) fun `test AGPInterface#targetSdkVersion`() = Unit - @Test - @Case(VariantTypeTestUnit::class) - fun `test AGPInterface#variantType`() { - } - @Test @Case(AarTestUnit::class) fun `test AGPInterface#aar`() { @@ -333,18 +326,6 @@ class TargetSdkVersionTestUnit : VariantTestCase() { } } -class VariantTypeTestUnit : VariantTestCase() { - override fun apply(variant: BaseVariant) { - val project = AGP.run { variant.project } - val variantType = AGP.run { variant.variantType } - if (project.plugins.hasPlugin("com.android.application")) { - assertEquals(VariantTypeImpl.BASE_APK, variantType) - } else if (project.plugins.hasPlugin("com.android.library")) { - assertEquals(VariantTypeImpl.LIBRARY, variantType) - } - } -} - class AarTestUnit : VariantTestCase() { override fun apply(project: Project) { if (project.plugins.hasPlugin("com.android.library")) { diff --git a/booster-android-gradle-v7_0/src/integrationTest/resources/app.gradle b/booster-android-gradle-v7_0/src/integrationTest/resources/app.gradle index a9db67a64..aa3c5f2d6 100644 --- a/booster-android-gradle-v7_0/src/integrationTest/resources/app.gradle +++ b/booster-android-gradle-v7_0/src/integrationTest/resources/app.gradle @@ -11,7 +11,7 @@ buildscript { classpath("com.didiglobal.booster:booster-gradle-plugin:${project.booster_version}") { exclude group: 'com.google.guava' } - classpath "io.bootstage.testkit:testkit-gradle-plugin:1.1.0" + classpath "io.bootstage.testkit:testkit-gradle-plugin:1.4.0" } } diff --git a/booster-android-gradle-v7_0/src/integrationTest/resources/buildSrc/build.gradle b/booster-android-gradle-v7_0/src/integrationTest/resources/buildSrc/build.gradle index bb9648dce..79a9b104a 100644 --- a/booster-android-gradle-v7_0/src/integrationTest/resources/buildSrc/build.gradle +++ b/booster-android-gradle-v7_0/src/integrationTest/resources/buildSrc/build.gradle @@ -20,5 +20,5 @@ dependencies { implementation("com.didiglobal.booster:booster-android-gradle-api:${project.booster_version}") { exclude group: 'com.google.guava' } - implementation "io.bootstage.testkit:testkit-gradle-plugin:1.1.0" + implementation "io.bootstage.testkit:testkit-gradle-plugin:1.4.0" } diff --git a/booster-android-gradle-v7_0/src/integrationTest/resources/lib.gradle b/booster-android-gradle-v7_0/src/integrationTest/resources/lib.gradle index 64a9540e9..adc9b1ca0 100644 --- a/booster-android-gradle-v7_0/src/integrationTest/resources/lib.gradle +++ b/booster-android-gradle-v7_0/src/integrationTest/resources/lib.gradle @@ -11,7 +11,7 @@ buildscript { classpath("com.didiglobal.booster:booster-gradle-plugin:${project.booster_version}") { exclude group: 'com.google.guava' } - classpath "io.bootstage.testkit:testkit-gradle-plugin:1.1.0" + classpath "io.bootstage.testkit:testkit-gradle-plugin:1.4.0" } } diff --git a/booster-android-gradle-v7_0/src/main/kotlin/com/didiglobal/booster/android/gradle/v7_0/V70.kt b/booster-android-gradle-v7_0/src/main/kotlin/com/didiglobal/booster/android/gradle/v7_0/V70.kt index 6dad42f81..292cf131a 100644 --- a/booster-android-gradle-v7_0/src/main/kotlin/com/didiglobal/booster/android/gradle/v7_0/V70.kt +++ b/booster-android-gradle-v7_0/src/main/kotlin/com/didiglobal/booster/android/gradle/v7_0/V70.kt @@ -7,9 +7,6 @@ import com.android.build.api.artifact.impl.ArtifactsImpl import com.android.build.api.component.impl.ComponentImpl import com.android.build.api.transform.Context import com.android.build.api.transform.QualifiedContent -import com.android.build.gradle.AppPlugin -import com.android.build.gradle.DynamicFeaturePlugin -import com.android.build.gradle.LibraryPlugin import com.android.build.gradle.api.ApplicationVariant import com.android.build.gradle.api.BaseVariant import com.android.build.gradle.api.LibraryVariant @@ -259,7 +256,7 @@ internal object V70 : AGPInterface { override val BaseVariant.allClasses: FileCollection get() = when (this) { is ApplicationVariant -> getFinalArtifactFiles(InternalArtifactType.JAVAC) + project.files("build${File.separator}tmp${File.separator}kotlin-classes${File.separator}${dirName}") - is LibraryVariant -> getFinalArtifactFiles(InternalArtifactType.COMPILE_LIBRARY_CLASSES_JAR) + is LibraryVariant -> getFinalArtifactFiles(InternalArtifactType.AAR_MAIN_JAR) else -> project.files() } diff --git a/booster-android-gradle-v7_1/src/integrationTest/kotlin/com/didiglobal/booster/android/gradle/v7_1/V71IntegrationTest.kt b/booster-android-gradle-v7_1/src/integrationTest/kotlin/com/didiglobal/booster/android/gradle/v7_1/V71IntegrationTest.kt index 7d6a0b755..5421a536e 100644 --- a/booster-android-gradle-v7_1/src/integrationTest/kotlin/com/didiglobal/booster/android/gradle/v7_1/V71IntegrationTest.kt +++ b/booster-android-gradle-v7_1/src/integrationTest/kotlin/com/didiglobal/booster/android/gradle/v7_1/V71IntegrationTest.kt @@ -6,7 +6,6 @@ import com.android.build.gradle.AppExtension import com.android.build.gradle.BaseExtension import com.android.build.gradle.LibraryExtension import com.android.build.gradle.api.BaseVariant -import com.android.builder.core.VariantTypeImpl import com.didiglobal.booster.gradle.AGP import com.didiglobal.booster.gradle.getAndroid import com.didiglobal.booster.kotlinx.search @@ -30,12 +29,11 @@ import kotlin.test.assertNotNull import kotlin.test.assertTrue import kotlin.test.fail -private const val MIN_SDK_VERSION = 18 +private val MIN_SDK_VERSION = System.getProperty("android.minsdk.version").toInt() private const val TARGET_SDK_VERSION = 30 -private val ARGS = arrayOf( - "assemble", "-S", +private val ARGS = System.getProperty("gradle.args").split("\\s+".toRegex()) + listOf( "-Pbooster_version=${Build.VERSION}", "-Pandroid_gradle_version=7.1.0", "-Pcompile_sdk_version=30", @@ -52,7 +50,7 @@ abstract class V71IntegrationTest(private val isLib: Boolean) { @get:Rule val ruleChain: TestRule = rule(projectDir) { rule(LocalProperties(projectDir::getRoot)) { - GradleExecutor(projectDir::getRoot, "7.2", *ARGS) + GradleExecutor(projectDir::getRoot, "7.2", *ARGS.toTypedArray()) } } @@ -138,11 +136,6 @@ abstract class V71IntegrationTest(private val isLib: Boolean) { @Case(TargetSdkVersionTestUnit::class) fun `test AGPInterface#targetSdkVersion`() = Unit - @Test - @Case(VariantTypeTestUnit::class) - fun `test AGPInterface#variantType`() { - } - @Test @Case(AarTestUnit::class) fun `test AGPInterface#aar`() { @@ -333,18 +326,6 @@ class TargetSdkVersionTestUnit : VariantTestCase() { } } -class VariantTypeTestUnit : VariantTestCase() { - override fun apply(variant: BaseVariant) { - val project = AGP.run { variant.project } - val variantType = AGP.run { variant.variantType } - if (project.plugins.hasPlugin("com.android.application")) { - assertEquals(VariantTypeImpl.BASE_APK, variantType) - } else if (project.plugins.hasPlugin("com.android.library")) { - assertEquals(VariantTypeImpl.LIBRARY, variantType) - } - } -} - class AarTestUnit : VariantTestCase() { override fun apply(project: Project) { if (project.plugins.hasPlugin("com.android.library")) { diff --git a/booster-android-gradle-v7_1/src/integrationTest/resources/app.gradle b/booster-android-gradle-v7_1/src/integrationTest/resources/app.gradle index a9db67a64..aa3c5f2d6 100644 --- a/booster-android-gradle-v7_1/src/integrationTest/resources/app.gradle +++ b/booster-android-gradle-v7_1/src/integrationTest/resources/app.gradle @@ -11,7 +11,7 @@ buildscript { classpath("com.didiglobal.booster:booster-gradle-plugin:${project.booster_version}") { exclude group: 'com.google.guava' } - classpath "io.bootstage.testkit:testkit-gradle-plugin:1.1.0" + classpath "io.bootstage.testkit:testkit-gradle-plugin:1.4.0" } } diff --git a/booster-android-gradle-v7_1/src/integrationTest/resources/buildSrc/build.gradle b/booster-android-gradle-v7_1/src/integrationTest/resources/buildSrc/build.gradle index bb9648dce..79a9b104a 100644 --- a/booster-android-gradle-v7_1/src/integrationTest/resources/buildSrc/build.gradle +++ b/booster-android-gradle-v7_1/src/integrationTest/resources/buildSrc/build.gradle @@ -20,5 +20,5 @@ dependencies { implementation("com.didiglobal.booster:booster-android-gradle-api:${project.booster_version}") { exclude group: 'com.google.guava' } - implementation "io.bootstage.testkit:testkit-gradle-plugin:1.1.0" + implementation "io.bootstage.testkit:testkit-gradle-plugin:1.4.0" } diff --git a/booster-android-gradle-v7_1/src/integrationTest/resources/lib.gradle b/booster-android-gradle-v7_1/src/integrationTest/resources/lib.gradle index 64a9540e9..adc9b1ca0 100644 --- a/booster-android-gradle-v7_1/src/integrationTest/resources/lib.gradle +++ b/booster-android-gradle-v7_1/src/integrationTest/resources/lib.gradle @@ -11,7 +11,7 @@ buildscript { classpath("com.didiglobal.booster:booster-gradle-plugin:${project.booster_version}") { exclude group: 'com.google.guava' } - classpath "io.bootstage.testkit:testkit-gradle-plugin:1.1.0" + classpath "io.bootstage.testkit:testkit-gradle-plugin:1.4.0" } } diff --git a/booster-android-gradle-v7_1/src/main/kotlin/com/didiglobal/booster/android/gradle/v7_1/V71.kt b/booster-android-gradle-v7_1/src/main/kotlin/com/didiglobal/booster/android/gradle/v7_1/V71.kt index b04432538..c65921f16 100644 --- a/booster-android-gradle-v7_1/src/main/kotlin/com/didiglobal/booster/android/gradle/v7_1/V71.kt +++ b/booster-android-gradle-v7_1/src/main/kotlin/com/didiglobal/booster/android/gradle/v7_1/V71.kt @@ -7,9 +7,6 @@ import com.android.build.api.artifact.impl.ArtifactsImpl import com.android.build.api.component.impl.ComponentImpl import com.android.build.api.transform.Context import com.android.build.api.transform.QualifiedContent -import com.android.build.gradle.AppPlugin -import com.android.build.gradle.DynamicFeaturePlugin -import com.android.build.gradle.LibraryPlugin import com.android.build.gradle.api.ApplicationVariant import com.android.build.gradle.api.BaseVariant import com.android.build.gradle.api.LibraryVariant @@ -255,7 +252,7 @@ internal object V71 : AGPInterface { override val BaseVariant.allClasses: FileCollection get() = when (this) { is ApplicationVariant -> getFinalArtifactFiles(InternalArtifactType.JAVAC) + project.files("build${File.separator}tmp${File.separator}kotlin-classes${File.separator}${dirName}") - is LibraryVariant -> getFinalArtifactFiles(InternalArtifactType.COMPILE_LIBRARY_CLASSES_JAR) + is LibraryVariant -> getFinalArtifactFiles(InternalArtifactType.AAR_MAIN_JAR) else -> project.files() } diff --git a/booster-android-gradle-v7_2/src/integrationTest/kotlin/com/didiglobal/booster/android/gradle/v7_2/V72IntegrationTest.kt b/booster-android-gradle-v7_2/src/integrationTest/kotlin/com/didiglobal/booster/android/gradle/v7_2/V72IntegrationTest.kt index e3d897001..fd48970da 100644 --- a/booster-android-gradle-v7_2/src/integrationTest/kotlin/com/didiglobal/booster/android/gradle/v7_2/V72IntegrationTest.kt +++ b/booster-android-gradle-v7_2/src/integrationTest/kotlin/com/didiglobal/booster/android/gradle/v7_2/V72IntegrationTest.kt @@ -6,7 +6,6 @@ import com.android.build.gradle.AppExtension import com.android.build.gradle.BaseExtension import com.android.build.gradle.LibraryExtension import com.android.build.gradle.api.BaseVariant -import com.android.builder.core.VariantTypeImpl import com.didiglobal.booster.gradle.AGP import com.didiglobal.booster.gradle.getAndroid import com.didiglobal.booster.kotlinx.search @@ -30,12 +29,11 @@ import kotlin.test.assertNotNull import kotlin.test.assertTrue import kotlin.test.fail -private const val MIN_SDK_VERSION = 18 +private val MIN_SDK_VERSION = System.getProperty("android.minsdk.version").toInt() private const val TARGET_SDK_VERSION = 30 -private val ARGS = arrayOf( - "assemble", "-S", +private val ARGS = System.getProperty("gradle.args").split("\\s+".toRegex()) + listOf( "-Pbooster_version=${Build.VERSION}", "-Pandroid_gradle_version=7.2.0", "-Pcompile_sdk_version=30", @@ -52,7 +50,7 @@ abstract class V72IntegrationTest(private val isLib: Boolean) { @get:Rule val ruleChain: TestRule = rule(projectDir) { rule(LocalProperties(projectDir::getRoot)) { - GradleExecutor(projectDir::getRoot, "7.3.3", *ARGS) + GradleExecutor(projectDir::getRoot, "7.3.3", *ARGS.toTypedArray()) } } @@ -138,11 +136,6 @@ abstract class V72IntegrationTest(private val isLib: Boolean) { @Case(TargetSdkVersionTestUnit::class) fun `test AGPInterface#targetSdkVersion`() = Unit - @Test - @Case(VariantTypeTestUnit::class) - fun `test AGPInterface#variantType`() { - } - @Test @Case(AarTestUnit::class) fun `test AGPInterface#aar`() { @@ -338,18 +331,6 @@ class TargetSdkVersionTestUnit : VariantTestCase() { } } -class VariantTypeTestUnit : VariantTestCase() { - override fun apply(variant: BaseVariant) { - val project = AGP.run { variant.project } - val variantType = AGP.run { variant.variantType } - if (project.plugins.hasPlugin("com.android.application")) { - assertEquals(VariantTypeImpl.BASE_APK, variantType) - } else if (project.plugins.hasPlugin("com.android.library")) { - assertEquals(VariantTypeImpl.LIBRARY, variantType) - } - } -} - class AarTestUnit : VariantTestCase() { override fun apply(project: Project) { if (project.plugins.hasPlugin("com.android.library")) { diff --git a/booster-android-gradle-v7_2/src/integrationTest/resources/app.gradle b/booster-android-gradle-v7_2/src/integrationTest/resources/app.gradle index a9db67a64..aa3c5f2d6 100644 --- a/booster-android-gradle-v7_2/src/integrationTest/resources/app.gradle +++ b/booster-android-gradle-v7_2/src/integrationTest/resources/app.gradle @@ -11,7 +11,7 @@ buildscript { classpath("com.didiglobal.booster:booster-gradle-plugin:${project.booster_version}") { exclude group: 'com.google.guava' } - classpath "io.bootstage.testkit:testkit-gradle-plugin:1.1.0" + classpath "io.bootstage.testkit:testkit-gradle-plugin:1.4.0" } } diff --git a/booster-android-gradle-v7_2/src/integrationTest/resources/buildSrc/build.gradle b/booster-android-gradle-v7_2/src/integrationTest/resources/buildSrc/build.gradle index bb9648dce..79a9b104a 100644 --- a/booster-android-gradle-v7_2/src/integrationTest/resources/buildSrc/build.gradle +++ b/booster-android-gradle-v7_2/src/integrationTest/resources/buildSrc/build.gradle @@ -20,5 +20,5 @@ dependencies { implementation("com.didiglobal.booster:booster-android-gradle-api:${project.booster_version}") { exclude group: 'com.google.guava' } - implementation "io.bootstage.testkit:testkit-gradle-plugin:1.1.0" + implementation "io.bootstage.testkit:testkit-gradle-plugin:1.4.0" } diff --git a/booster-android-gradle-v7_2/src/integrationTest/resources/lib.gradle b/booster-android-gradle-v7_2/src/integrationTest/resources/lib.gradle index 64a9540e9..adc9b1ca0 100644 --- a/booster-android-gradle-v7_2/src/integrationTest/resources/lib.gradle +++ b/booster-android-gradle-v7_2/src/integrationTest/resources/lib.gradle @@ -11,7 +11,7 @@ buildscript { classpath("com.didiglobal.booster:booster-gradle-plugin:${project.booster_version}") { exclude group: 'com.google.guava' } - classpath "io.bootstage.testkit:testkit-gradle-plugin:1.1.0" + classpath "io.bootstage.testkit:testkit-gradle-plugin:1.4.0" } } diff --git a/booster-android-gradle-v7_2/src/main/kotlin/com/didiglobal/booster/android/gradle/v7_2/V72.kt b/booster-android-gradle-v7_2/src/main/kotlin/com/didiglobal/booster/android/gradle/v7_2/V72.kt index 15d178e2b..df713b1a3 100644 --- a/booster-android-gradle-v7_2/src/main/kotlin/com/didiglobal/booster/android/gradle/v7_2/V72.kt +++ b/booster-android-gradle-v7_2/src/main/kotlin/com/didiglobal/booster/android/gradle/v7_2/V72.kt @@ -7,9 +7,6 @@ import com.android.build.api.artifact.impl.ArtifactsImpl import com.android.build.api.component.impl.ComponentImpl import com.android.build.api.transform.Context import com.android.build.api.transform.QualifiedContent -import com.android.build.gradle.AppPlugin -import com.android.build.gradle.DynamicFeaturePlugin -import com.android.build.gradle.LibraryPlugin import com.android.build.gradle.api.ApplicationVariant import com.android.build.gradle.api.BaseVariant import com.android.build.gradle.api.LibraryVariant @@ -265,7 +262,7 @@ internal object V72 : AGPInterface { override val BaseVariant.allClasses: FileCollection get() = when (this) { is ApplicationVariant -> getFinalArtifactFiles(InternalArtifactType.JAVAC) + project.files("build${File.separator}tmp${File.separator}kotlin-classes${File.separator}${dirName}") - is LibraryVariant -> getFinalArtifactFiles(InternalArtifactType.COMPILE_LIBRARY_CLASSES_JAR) + is LibraryVariant -> getFinalArtifactFiles(InternalArtifactType.AAR_MAIN_JAR) else -> project.files() } diff --git a/booster-android-gradle-v7_3/src/integrationTest/kotlin/com/didiglobal/booster/android/gradle/v7_3/V73IntegrationTest.kt b/booster-android-gradle-v7_3/src/integrationTest/kotlin/com/didiglobal/booster/android/gradle/v7_3/V73IntegrationTest.kt index 563ec2fa8..75dfd4b31 100644 --- a/booster-android-gradle-v7_3/src/integrationTest/kotlin/com/didiglobal/booster/android/gradle/v7_3/V73IntegrationTest.kt +++ b/booster-android-gradle-v7_3/src/integrationTest/kotlin/com/didiglobal/booster/android/gradle/v7_3/V73IntegrationTest.kt @@ -6,7 +6,6 @@ import com.android.build.gradle.AppExtension import com.android.build.gradle.BaseExtension import com.android.build.gradle.LibraryExtension import com.android.build.gradle.api.BaseVariant -import com.android.builder.core.VariantTypeImpl import com.didiglobal.booster.gradle.AGP import com.didiglobal.booster.gradle.getAndroid import com.didiglobal.booster.kotlinx.search @@ -30,18 +29,17 @@ import kotlin.test.assertNotNull import kotlin.test.assertTrue import kotlin.test.fail -private const val MIN_SDK_VERSION = 18 +private val MIN_SDK_VERSION = System.getProperty("android.minsdk.version").toInt() private const val TARGET_SDK_VERSION = 30 -private val ARGS = arrayOf( - "assemble", "-S", +private val ARGS = System.getProperty("gradle.args").split("\\s+".toRegex()) + listOf( "-Pbooster_version=${Build.VERSION}", "-Pandroid_gradle_version=7.3.0", "-Pcompile_sdk_version=30", "-Pbuild_tools_version=29.0.2", - "-Pmin_sdk_version=$MIN_SDK_VERSION", - "-Ptarget_sdk_version=$TARGET_SDK_VERSION" + "-Pmin_sdk_version=${MIN_SDK_VERSION}", + "-Ptarget_sdk_version=${TARGET_SDK_VERSION}" ) @Suppress("RemoveCurlyBracesFromTemplate", "FunctionName") @@ -52,7 +50,7 @@ abstract class V73IntegrationTest(private val isLib: Boolean) { @get:Rule val ruleChain: TestRule = rule(projectDir) { rule(LocalProperties(projectDir::getRoot)) { - GradleExecutor(projectDir::getRoot, "7.3.3", *ARGS) + GradleExecutor(projectDir::getRoot, "7.4", *ARGS.toTypedArray()) } } @@ -138,11 +136,6 @@ abstract class V73IntegrationTest(private val isLib: Boolean) { @Case(TargetSdkVersionTestUnit::class) fun `test AGPInterface#targetSdkVersion`() = Unit - @Test - @Case(VariantTypeTestUnit::class) - fun `test AGPInterface#variantType`() { - } - @Test @Case(AarTestUnit::class) fun `test AGPInterface#aar`() { @@ -282,7 +275,9 @@ class VariantScopeTestUnit : VariantTestCase() { class OriginalApplicationIdTestUnit : VariantTestCase() { override fun apply(variant: BaseVariant) { - assertNotNull(AGP.run { variant.originalApplicationId }) + AGP.run { variant.assembleTask }.doFirst { + assertNotNull(AGP.run { variant.originalApplicationId }) + } } } @@ -338,18 +333,6 @@ class TargetSdkVersionTestUnit : VariantTestCase() { } } -class VariantTypeTestUnit : VariantTestCase() { - override fun apply(variant: BaseVariant) { - val project = AGP.run { variant.project } - val variantType = AGP.run { variant.variantType } - if (project.plugins.hasPlugin("com.android.application")) { - assertEquals(VariantTypeImpl.BASE_APK, variantType) - } else if (project.plugins.hasPlugin("com.android.library")) { - assertEquals(VariantTypeImpl.LIBRARY, variantType) - } - } -} - class AarTestUnit : VariantTestCase() { override fun apply(project: Project) { if (project.plugins.hasPlugin("com.android.library")) { diff --git a/booster-android-gradle-v7_3/src/integrationTest/resources/app.gradle b/booster-android-gradle-v7_3/src/integrationTest/resources/app.gradle index a9db67a64..aa3c5f2d6 100644 --- a/booster-android-gradle-v7_3/src/integrationTest/resources/app.gradle +++ b/booster-android-gradle-v7_3/src/integrationTest/resources/app.gradle @@ -11,7 +11,7 @@ buildscript { classpath("com.didiglobal.booster:booster-gradle-plugin:${project.booster_version}") { exclude group: 'com.google.guava' } - classpath "io.bootstage.testkit:testkit-gradle-plugin:1.1.0" + classpath "io.bootstage.testkit:testkit-gradle-plugin:1.4.0" } } diff --git a/booster-android-gradle-v7_3/src/integrationTest/resources/buildSrc/build.gradle b/booster-android-gradle-v7_3/src/integrationTest/resources/buildSrc/build.gradle index bb9648dce..79a9b104a 100644 --- a/booster-android-gradle-v7_3/src/integrationTest/resources/buildSrc/build.gradle +++ b/booster-android-gradle-v7_3/src/integrationTest/resources/buildSrc/build.gradle @@ -20,5 +20,5 @@ dependencies { implementation("com.didiglobal.booster:booster-android-gradle-api:${project.booster_version}") { exclude group: 'com.google.guava' } - implementation "io.bootstage.testkit:testkit-gradle-plugin:1.1.0" + implementation "io.bootstage.testkit:testkit-gradle-plugin:1.4.0" } diff --git a/booster-android-gradle-v7_3/src/integrationTest/resources/lib.gradle b/booster-android-gradle-v7_3/src/integrationTest/resources/lib.gradle index 64a9540e9..adc9b1ca0 100644 --- a/booster-android-gradle-v7_3/src/integrationTest/resources/lib.gradle +++ b/booster-android-gradle-v7_3/src/integrationTest/resources/lib.gradle @@ -11,7 +11,7 @@ buildscript { classpath("com.didiglobal.booster:booster-gradle-plugin:${project.booster_version}") { exclude group: 'com.google.guava' } - classpath "io.bootstage.testkit:testkit-gradle-plugin:1.1.0" + classpath "io.bootstage.testkit:testkit-gradle-plugin:1.4.0" } } diff --git a/booster-android-gradle-v7_3/src/main/kotlin/com/didiglobal/booster/android/gradle/v7_3/V73.kt b/booster-android-gradle-v7_3/src/main/kotlin/com/didiglobal/booster/android/gradle/v7_3/V73.kt index fefa4d24a..eead4116c 100644 --- a/booster-android-gradle-v7_3/src/main/kotlin/com/didiglobal/booster/android/gradle/v7_3/V73.kt +++ b/booster-android-gradle-v7_3/src/main/kotlin/com/didiglobal/booster/android/gradle/v7_3/V73.kt @@ -32,6 +32,7 @@ import org.gradle.api.artifacts.ArtifactCollection import org.gradle.api.artifacts.component.ComponentIdentifier import org.gradle.api.artifacts.result.ResolvedArtifactResult import org.gradle.api.artifacts.result.ResolvedDependencyResult +import org.gradle.api.file.ConfigurableFileCollection import org.gradle.api.file.FileCollection import org.gradle.api.file.FileSystemLocation import org.gradle.api.tasks.TaskProvider @@ -89,16 +90,6 @@ internal object V73 : AGPInterface { } } - private inline fun Sequence.firstOfOrNull(transform: (T) -> R?): R? { - for (element in this) { - val result = transform(element) - if (result != null) { - return result - } - } - return null - } - @Suppress("UnstableApiUsage") private val BaseVariant.artifacts: ArtifactsImpl get() = component.artifacts @@ -168,9 +159,32 @@ internal object V73 : AGPInterface { get() = component.global.hasDynamicFeatures override val BaseVariant.rawAndroidResources: FileCollection - get() = ComponentImpl::class.java.getDeclaredField("allRawAndroidResources").apply { - isAccessible = true - }.get(component) as FileCollection + get() { + val allRes: ConfigurableFileCollection = component.services.fileCollection() + + allRes.from(component.variantDependencies.getArtifactCollection( + AndroidArtifacts.ConsumedConfigType.RUNTIME_CLASSPATH, + ArtifactScope.ALL, + AndroidArtifacts.ArtifactType.ANDROID_RES + ).artifactFiles) + + allRes.from(component.services.fileCollection(variantData.extraGeneratedResFolders) + .builtBy(listOfNotNull(variantData.extraGeneratedResFolders.builtBy))) + + component.taskContainer.generateApkDataTask?.let { + allRes.from(artifacts.get(InternalArtifactType.MICRO_APK_RES)) + } + + allRes.from(component.sources.res.getVariantSources().map { allSources -> + allSources.map { directoryEntries -> + directoryEntries.directoryEntries.map { + it.asFiles(component.services::directoryProperty) + } + } + }) + + return allRes + } override fun BaseVariant.getArtifactCollection( configType: AndroidArtifacts.ConsumedConfigType, @@ -260,7 +274,7 @@ internal object V73 : AGPInterface { override val BaseVariant.allClasses: FileCollection get() = when (this) { is ApplicationVariant -> getFinalArtifactFiles(InternalArtifactType.JAVAC) + project.files("build${File.separator}tmp${File.separator}kotlin-classes${File.separator}${dirName}") - is LibraryVariant -> getFinalArtifactFiles(InternalArtifactType.COMPILE_LIBRARY_CLASSES_JAR) + is LibraryVariant -> getFinalArtifactFiles(InternalArtifactType.AAR_MAIN_JAR) else -> project.files() } diff --git a/booster-gradle-plugin/src/main/kotlin/com/didiglobal/booster/gradle/BoosterTransformInvocation.kt b/booster-gradle-plugin/src/main/kotlin/com/didiglobal/booster/gradle/BoosterTransformInvocation.kt index 5aba2b3a7..71c43c3cd 100644 --- a/booster-gradle-plugin/src/main/kotlin/com/didiglobal/booster/gradle/BoosterTransformInvocation.kt +++ b/booster-gradle-plugin/src/main/kotlin/com/didiglobal/booster/gradle/BoosterTransformInvocation.kt @@ -244,7 +244,7 @@ internal class BoosterTransformInvocation( private fun doVerify() { outputs.sortedBy(File::nameWithoutExtension).forEach { input -> val output = temporaryDir.file(input.name) - val rc = input.dex(output, variant.extension.defaultConfig.targetSdkVersion?.apiLevel ?: DexFormat.API_NO_EXTENDED_OPCODES) + val rc = input.dex(output, targetSdkVersion.apiLevel) println("${if (rc != 0) red("✗") else green("✓")} $input") output.deleteRecursively() } diff --git a/booster-gradle-plugin/src/main/kotlin/com/didiglobal/booster/gradle/ServiceLoader.kt b/booster-gradle-plugin/src/main/kotlin/com/didiglobal/booster/gradle/ServiceLoader.kt index b8b0fa4d5..6f7a0e3e5 100644 --- a/booster-gradle-plugin/src/main/kotlin/com/didiglobal/booster/gradle/ServiceLoader.kt +++ b/booster-gradle-plugin/src/main/kotlin/com/didiglobal/booster/gradle/ServiceLoader.kt @@ -26,9 +26,9 @@ private class ServiceLoaderImpl( try { provider.getConstructor(*types).newInstance(*args) as T } catch (e: NoSuchMethodException) { - provider.newInstance() as T + provider.getDeclaredConstructor().newInstance() as T } - } catch (e: ClassNotFoundException) { + } catch (e: Throwable) { throw ServiceConfigurationError("Provider $provider not found") } } @@ -66,15 +66,7 @@ internal fun lookupTransformers(classLoader: ClassLoader): Set { - return newServiceLoader(classLoader, ClassLoader::class.java).load(classLoader) -} - -/** - * Load [VariantProcessor]s with the specified [classLoader] + * Load [VariantProcessor]s with the specified [project] */ @Throws(ServiceConfigurationError::class) internal fun loadVariantProcessors(project: Project): List { @@ -87,7 +79,7 @@ private fun parse(u: URL) = try { it.isNotEmpty() && it.isNotBlank() && !it.startsWith('#') }.map(String::trim).filter(::isJavaClassName) } catch (e: Throwable) { - emptyList() + emptyList() } private fun isJavaClassName(text: String): Boolean { @@ -97,7 +89,7 @@ private fun isJavaClassName(text: String): Boolean { for (i in 1 until text.length) { val cp = text.codePointAt(i) - if (!Character.isJavaIdentifierPart(cp) && cp != '.'.toInt()) { + if (!Character.isJavaIdentifierPart(cp) && cp != '.'.code) { throw ServiceConfigurationError("Illegal provider-class name: $text") } } diff --git a/booster-graph-dot/src/main/kotlin/com/didiglobal/booster/graph/dot/DotGraph.kt b/booster-graph-dot/src/main/kotlin/com/didiglobal/booster/graph/dot/DotGraph.kt index 09cbf8fb2..a514069d0 100644 --- a/booster-graph-dot/src/main/kotlin/com/didiglobal/booster/graph/dot/DotGraph.kt +++ b/booster-graph-dot/src/main/kotlin/com/didiglobal/booster/graph/dot/DotGraph.kt @@ -6,10 +6,11 @@ import com.didiglobal.booster.graph.Graph import com.didiglobal.booster.graph.GraphRenderer import com.didiglobal.booster.graph.GroupedNode import com.didiglobal.booster.graph.Node -import com.didiglobal.booster.kotlinx.* +import com.didiglobal.booster.kotlinx.OS +import com.didiglobal.booster.kotlinx.RGB +import com.didiglobal.booster.kotlinx.WebSafeColorPalette +import com.didiglobal.booster.kotlinx.touch import java.io.File -import java.io.FileNotFoundException -import java.io.IOException import kotlin.reflect.full.memberProperties private val DOT = CommandService.fromPath("dot${OS.executableSuffix}") @@ -24,27 +25,27 @@ sealed class DotGraph : GraphRenderer { object DIGRAPH : DotGraph() { override fun render(graph: Graph, options: GraphRenderer.Options, prettify: (N) -> String): CharSequence { - return StringBuilder().apply { - appendln("digraph \"${graph.title}\" {") - appendln(" graph [bgcolor=\"transparent\",pad=\"0.555\"];") - appendln(" node [color=\"#00BFC4\",fillcolor=\"#00BFC440\",fontcolor=\"#333333\",fontname=Helvetica,shape=box,style=filled];") - appendln(" edge [fontname=Helvetica];") - appendln(" rankdir = ${options["rankdir"] ?: "TB"};") + return buildString { + appendLine("digraph \"${graph.title}\" {") + appendLine(" graph [bgcolor=\"transparent\",pad=\"0.555\"];") + appendLine(" node [color=\"#00BFC4\",fillcolor=\"#00BFC440\",fontcolor=\"#333333\",fontname=Helvetica,shape=box,style=filled];") + appendLine(" edge [fontname=Helvetica];") + appendLine(" rankdir = ${options["rankdir"] ?: "TB"};") graph.nodes.filterIsInstance>().groupBy { it.groupBy() ?: "" }.entries.withIndex().forEach { (index, entry) -> val color = RGB.valueOf(WebSafeColorPalette.random(0x000000, 0xffffff)) - appendln(" subgraph cluster_${index} {") - appendln(" style=\"rounded,dashed\";") - appendln(" label=\"${entry.key}\";") - appendln(" fgcolor=\"${color}\";") + appendLine(" subgraph cluster_${index} {") + appendLine(" style=\"rounded,dashed\";") + appendLine(" label=\"${entry.key}\";") + appendLine(" fgcolor=\"${color}\";") entry.value.map { node -> @Suppress("UNCHECKED_CAST") (node as N) }.forEach { node -> - appendln(" \"${prettify(node)}\";") + appendLine(" \"${prettify(node)}\";") } - appendln(" }") + appendLine(" }") } graph.nodes.joinTo(this, "\n ", " ", "\n") { node -> @@ -56,7 +57,7 @@ sealed class DotGraph : GraphRenderer { val color = RGB.valueOf(WebSafeColorPalette.random(0x000000, 0xffffff)).toString() // except white color "\"${prettify(edge.from)}\" -> \"${prettify(edge.to)}\" [color=\"#$color\",fontcolor=\"#$color\"];" } - appendln("}") + appendLine("}") } } diff --git a/gradle/booster.gradle b/gradle/booster.gradle index e53909d3f..53f356615 100644 --- a/gradle/booster.gradle +++ b/gradle/booster.gradle @@ -25,11 +25,19 @@ sourceSets { } compileKotlin { - kotlinOptions.jvmTarget = JavaVersion.VERSION_1_8 + kotlinOptions{ + jvmTarget = JavaVersion.VERSION_1_8 + apiVersion = "1.5" + freeCompilerArgs = ["-Xno-optimized-callable-references"] + } } compileTestKotlin { - kotlinOptions.jvmTarget = JavaVersion.VERSION_1_8 + kotlinOptions{ + jvmTarget = JavaVersion.VERSION_1_8 + apiVersion = "1.5" + freeCompilerArgs = ["-Xno-optimized-callable-references"] + } } dependencies { diff --git a/gradle/functional-test.gradle b/gradle/functional-test.gradle index b686abb3d..be18d001e 100644 --- a/gradle/functional-test.gradle +++ b/gradle/functional-test.gradle @@ -26,10 +26,16 @@ task functionalTest(type: Test) { testLogging { events "passed", "skipped", "failed", "standardError" } + systemProperty('gradle.args', 'buildEnv dependencies assemble -S') + systemProperty 'android.minsdk.version', 18 } check.dependsOn functionalTest compileFunctionalTestKotlin { - kotlinOptions.jvmTarget = JavaVersion.VERSION_1_8 + kotlinOptions { + jvmTarget = JavaVersion.VERSION_1_8 + apiVersion = "1.5" + freeCompilerArgs = ["-Xno-optimized-callable-references"] + } } \ No newline at end of file diff --git a/gradle/integration-test.gradle b/gradle/integration-test.gradle index 7693ebf2d..7813476df 100644 --- a/gradle/integration-test.gradle +++ b/gradle/integration-test.gradle @@ -26,12 +26,18 @@ task integrationTest(type: Test) { testLogging { events "passed", "skipped", "failed", "standardOut", "standardError" } + systemProperty('gradle.args', 'buildEnv dependencies assemble -S') + systemProperty 'android.minsdk.version', 18 } check.dependsOn integrationTest compileIntegrationTestKotlin { - kotlinOptions.jvmTarget = JavaVersion.VERSION_1_8 + kotlinOptions { + jvmTarget = JavaVersion.VERSION_1_8 + apiVersion = "1.5" + freeCompilerArgs = ["-Xno-optimized-callable-references"] + } } tasks.withType(ProcessResources).configureEach {