Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/g000sha256/keep
The plugin for preserving necessary declarations from obfuscation
https://github.com/g000sha256/keep
android kotlin obfuscation obfuscator proguard r8
Last synced: 26 days ago
JSON representation
The plugin for preserving necessary declarations from obfuscation
- Host: GitHub
- URL: https://github.com/g000sha256/keep
- Owner: g000sha256
- License: apache-2.0
- Created: 2024-09-17T16:11:16.000Z (4 months ago)
- Default Branch: master
- Last Pushed: 2024-12-04T20:14:35.000Z (29 days ago)
- Last Synced: 2024-12-04T21:24:18.215Z (29 days ago)
- Topics: android, kotlin, obfuscation, obfuscator, proguard, r8
- Language: Kotlin
- Homepage:
- Size: 31.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Keep
[![Maven Central](https://img.shields.io/maven-central/v/dev.g000sha256/keep-plugin?label=Maven%20Central&labelColor=171B35&color=E38E33)](https://central.sonatype.com/artifact/dev.g000sha256/keep-plugin)
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
```kotlin
repositories {
mavenCentral()
}
```### Apply plugin
```kotlin
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
```kotlin
@KeepAPI
class TestClass
``````kotlin
@KeepAPI
class TestParentClass {@KeepAPI
class TestInnerClass}
```### Getters and Setters
```kotlin
@KeepAPI
class TestClass {@get:KeepAPI
val testValue: Int = 0}
``````kotlin
@KeepAPI
class TestClass {@set:KeepAPI
var testValue: Int = 0}
``````kotlin
@KeepAPI
class TestClass {@get:KeepAPI
@set:KeepAPI
var testValue: Int = 0}
```### Constructors
```kotlin
@KeepAPI
class TestClass @KeepAPI constructor(val testValue: Int)
``````kotlin
@KeepAPI
class TestClass @KeepAPI constructor(@get:KeepAPI val testValue: Int)
```### Methods
```kotlin
@KeepAPI
class TestClass {@KeepAPI
fun testMethod() {
}}
```