diff --git a/base/src/proguard/KeepClassSpecification.java b/base/src/proguard/KeepClassSpecification.java index d054571a..5a6fea02 100644 --- a/base/src/proguard/KeepClassSpecification.java +++ b/base/src/proguard/KeepClassSpecification.java @@ -84,6 +84,49 @@ public class KeepClassSpecification extends ClassSpecification } + /** + * Creates a new KeepClassSpecification. + * + * @param markClassesAndMembers specifies whether to mark the classes. + * @param markConditionally specifies whether to mark the classes and + * class members conditionally. If true, + * classes and class members are marked, on + * the condition that all specified class + * members are present. + * @param markDescriptorClasses specifies whether to mark the classes in + * the descriptors of the marked class members. + * @param markCodeAttributes specified whether to mark the code attributes + * of the marked class methods. + * @param allowShrinking specifies whether shrinking is allowed. + * @param allowOptimization specifies whether optimization is allowed. + * @param allowObfuscation specifies whether obfuscation is allowed. + * @param condition an optional extra condition. + * @param classSpecification the specification of classes and class + * members. + */ + @Deprecated + public KeepClassSpecification(boolean markClassesAndMembers, + boolean markConditionally, + boolean markDescriptorClasses, + boolean markCodeAttributes, + boolean allowShrinking, + boolean allowOptimization, + boolean allowObfuscation, + ClassSpecification condition, + ClassSpecification classSpecification) + { + this(markClassesAndMembers, + markClassesAndMembers, + markConditionally, + markDescriptorClasses, + markCodeAttributes, + allowShrinking, + allowOptimization, + allowObfuscation, + condition, + classSpecification); + } + // Implementations for Object. @Override diff --git a/gradle-plugin/src/test/kotlin/proguard/gradle/ProGuardPluginLegacyAGPIntegrationTest.kt b/gradle-plugin/src/test/kotlin/proguard/gradle/ProGuardPluginLegacyAGPIntegrationTest.kt index 4973913e..e8c762a1 100644 --- a/gradle-plugin/src/test/kotlin/proguard/gradle/ProGuardPluginLegacyAGPIntegrationTest.kt +++ b/gradle-plugin/src/test/kotlin/proguard/gradle/ProGuardPluginLegacyAGPIntegrationTest.kt @@ -15,6 +15,7 @@ import testutils.AndroidProject import testutils.applicationModule import testutils.createGradleRunner import testutils.createTestKitDir +import testutils.libraryModule class ProGuardPluginLegacyAGPIntegrationTest : FreeSpec({ val testKitDir = createTestKitDir() @@ -81,4 +82,77 @@ class ProGuardPluginLegacyAGPIntegrationTest : FreeSpec({ } } } + + "Given a library project with the legacy integration" - { + val project = autoClose(AndroidProject( + gradleDotProperties = """ + |android.enableR8=false + |android.enableR8.libraries=false + |android.useAndroidX=true + """.trimMargin(), buildDotGradle = """ + buildscript { + repositories { + mavenCentral() // For anything else. + google() // For the Android plugin. + flatDir { + dirs "${System.getProperty("local.repo")}" + } + } + dependencies { + classpath "com.android.tools.build:gradle:4.2.0" + classpath ":proguard-gradle:${System.getProperty("proguard.version")}" + } + + configurations.all { + resolutionStrategy { + dependencySubstitution { + substitute module('net.sf.proguard:proguard-gradle') with module("com.guardsquare:proguard-gradle:${System.getProperty("proguard.version")}") + } + } + } + } + allprojects { + repositories { + google() + mavenCentral() + } + } + """.trimIndent()).apply { + addModule(libraryModule( + "library", + buildDotGradle = """ + plugins { + id 'com.android.library' + } + + dependencies { + implementation 'androidx.appcompat:appcompat:1.2.0' + } + + android { + compileSdkVersion 29 + defaultConfig { + targetSdkVersion 29 + minSdkVersion 14 + } + buildTypes { + release { + minifyEnabled true + proguardFile getDefaultProguardFile('proguard-android.txt') + } + debug {} + } + } + """)) + }.create()) + + "When the project is evaluated" - { + val result = createGradleRunner(project.rootDir, testKitDir, "clean", "assembleRelease", "--info").build() + + "Then the build should success" { + result.output shouldContain "ProGuard, version ${System.getProperty("proguard.version")}" + result.task(":library:assembleRelease")?.outcome shouldBe TaskOutcome.SUCCESS + } + } + } })