Skip to content

Latest commit

 

History

History
111 lines (78 loc) · 1.84 KB

README.md

File metadata and controls

111 lines (78 loc) · 1.84 KB

Keep

Maven Central

The Gradle plugin simplifies the process of preserving necessary declarations from obfuscation when using the R8 tool. It provides the KeepAPI and KeepReflection annotations, along with corresponding R8 rules that are automatically applied to your project based on the annotations used.

Initialization

Add plugin repository

repositories {
    mavenCentral()
}

Apply plugin

plugins {
    id("dev.g000sha256.keep") version "0.0.1"
}

Usage

The KeepAPI and KeepReflection annotations are used similarly but serve different purposes.

  • Use the KeepReflection annotation to preserve declarations accessed via reflection.
  • Use the KeepAPI annotation to preserve API declarations in library modules.

Important

Annotating methods and fields does not automatically preserve the class name. Don't forget to add the annotation to the class if necessary.

Class name only

@KeepAPI
class TestClass
@KeepAPI
class TestParentClass {

    @KeepAPI
    class TestInnerClass

}

Getters and Setters

@KeepAPI
class TestClass {

    @get:KeepAPI
    val testValue: Int = 0

}
@KeepAPI
class TestClass {

    @set:KeepAPI
    var testValue: Int = 0

}
@KeepAPI
class TestClass {

    @get:KeepAPI
    @set:KeepAPI
    var testValue: Int = 0

}

Constructors

@KeepAPI
class TestClass @KeepAPI constructor(val testValue: Int)
@KeepAPI
class TestClass @KeepAPI constructor(@get:KeepAPI val testValue: Int)

Methods

@KeepAPI
class TestClass {

    @KeepAPI
    fun testMethod() {
    }

}