Skip to content

Commit

Permalink
fix #1
Browse files Browse the repository at this point in the history
  • Loading branch information
joker committed Aug 20, 2019
1 parent 3795288 commit 59349c0
Show file tree
Hide file tree
Showing 52 changed files with 765 additions and 587 deletions.
21 changes: 15 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ buildscript {
apply plugin: 'thinAnnotation'
thinAnnotation {
// 是否开启插件
enable true
// 目标注解类的路径
shrinkClass = ['com/joker/maindexkeep/annotations/RuntimeAnn', 'com/joker/maindexkeep/annotations/Type']
// 目标包的路径
shrinkPackage = ['com/joker/maindexkeep/shrink']
shrinkClass 'com/joker/maindexkeep/annotations/RuntimeAnn'
// 删除 com/joker/maindexkeep/shrink/ 下所有注解
shrinkPackage('com/joker/maindexkeep/shrink/', { true })
// 删除 com/joker/maindexkeep/shrink2/ 下除 RUNTIME 之外的所有注解
shrinkPackage 'com/joker/maindexkeep/shrink2/'
}
```

Expand All @@ -50,4 +50,13 @@ thinAnnotation {

使用后:butterknife 包注解类全部删除,所有使用该注解的地方也都会被清除注解

![](http://imglf5.nosdn0.126.net/img/UnlRcDgySWkxbnZUbjBCSXdnUFozanN2dzFqaU4xREZZalNtc2JrSGw0WXNQWEQ5NlpQNUlnPT0.png?imageView&thumbnail=2238y1484&type=png&quality=96&stripmeta=0)
![](http://imglf5.nosdn0.126.net/img/UnlRcDgySWkxbnZUbjBCSXdnUFozanN2dzFqaU4xREZZalNtc2JrSGw0WXNQWEQ5NlpQNUlnPT0.png?imageView&thumbnail=2238y1484&type=png&quality=96&stripmeta=0)

## CHANGELOG

0.0.3:

- fix [issue#1](https://github.com/jokermonn/thinAnnotation/issues/1)
- 使用方式稍作改变
- 丰富 thinAnnotation log
- 使用 kotlin
22 changes: 19 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'com.getkeepsafe.dexcount'
apply plugin: 'thinAnnotation'

Expand All @@ -17,8 +19,18 @@ android {
multiDexKeepFile file('./maindex-keep.txt')
}

signingConfigs {
release {
keyAlias 'key0'
storeFile file("${project.projectDir}/key.keystore")
keyPassword 'thinann'
storePassword 'thinann'
}
}

buildTypes {
release {
signingConfig signingConfigs.release
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
Expand All @@ -30,9 +42,12 @@ android {
}

thinAnnotation {
enable = true
shrinkClass = ['com/joker/maindexkeep/annotations/RuntimeAnn']
shrinkPackage = ['com/joker/maindexkeep/shrink']
enable true
shrinkClass 'com/joker/maindexkeep/annotations/RuntimeAnn'
// com/joker/maindexkeep/shrink/ 删除所有注解
shrinkPackage('com/joker/maindexkeep/shrink/', { true })
// com/joker/maindexkeep/shrink2/ 删除除 RUNTIME 之外的所有注解
shrinkPackage 'com/joker/maindexkeep/shrink2/'
}

dependencies {
Expand Down Expand Up @@ -76,4 +91,5 @@ dependencies {
implementation 'com.android.support:preference-v7:28.0.0'
implementation 'com.jakewharton:butterknife:8.4.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.4.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.41"
}
Binary file added app/key.keystore
Binary file not shown.
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
android:enabled="true"
android:exported="true"
android:name=".MultiProcessService"
android:process="t:second">
android:process=":second">
</service>

<activity android:name=".MainActivity">
Expand Down
19 changes: 0 additions & 19 deletions app/src/main/java/com/joker/maindexkeep/App.java

This file was deleted.

19 changes: 19 additions & 0 deletions app/src/main/java/com/joker/maindexkeep/App.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.joker.maindexkeep

import android.content.Context
import android.support.multidex.MultiDex
import android.support.multidex.MultiDexApplication
import android.util.Log
import com.joker.maindexkeep.model.AppReference

class App : MultiDexApplication() {
override fun attachBaseContext(base: Context) {
super.attachBaseContext(base)
val useless = AppReference()
}

override fun onCreate() {
MultiDex.install(this)
super.onCreate()
}
}
23 changes: 0 additions & 23 deletions app/src/main/java/com/joker/maindexkeep/MainActivity.java

This file was deleted.

22 changes: 22 additions & 0 deletions app/src/main/java/com/joker/maindexkeep/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.joker.maindexkeep

import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import com.joker.maindexkeep.annotations.RuntimeAnn

/**
* 方法/类被运行时注解所修饰,所以当前类将会被打入 maindex
*/
@RuntimeAnn
class MainActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
}

@RuntimeAnn
internal fun mainRuntime() {
println("hello, world")
}
}
19 changes: 0 additions & 19 deletions app/src/main/java/com/joker/maindexkeep/MultiProcessService.java

This file was deleted.

16 changes: 16 additions & 0 deletions app/src/main/java/com/joker/maindexkeep/MultiProcessService.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.joker.maindexkeep

import android.app.Service
import android.content.Intent
import android.os.IBinder

/**
* manifest 中有注释
*/
class MultiProcessService : Service() {

override fun onBind(intent: Intent): IBinder? {
// TODO: Return the communication channel to the service.
throw UnsupportedOperationException("Not yet implemented")
}
}
21 changes: 0 additions & 21 deletions app/src/main/java/com/joker/maindexkeep/SecondActivity.java

This file was deleted.

22 changes: 22 additions & 0 deletions app/src/main/java/com/joker/maindexkeep/SecondActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.joker.maindexkeep

import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import android.widget.TextView
import butterknife.BindView
import com.joker.maindexkeep.annotations.RuntimeAnn

/**
* [BindView] 是运行时注解,所以当前类将会被打入 maindex
*/
class SecondActivity : AppCompatActivity() {

@BindView(R.id.tv)
internal var tv: TextView? = null

@RuntimeAnn
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_second)
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.joker.maindexkeep.annotations

import android.support.annotation.StringDef
import com.joker.maindexkeep.annotations.AnnotationWrapper.Nothing.Companion.A
import com.joker.maindexkeep.annotations.AnnotationWrapper.Nothing.Companion.B
import com.joker.maindexkeep.model.AnnotationWrapperReference
import kotlin.annotation.AnnotationRetention.SOURCE

/**
* 由于包含注解内部类,所以本身及本身引用的 [AnnotationWrapperReference]及 [AnnotationWrapperReference]
* 的引用类都将会被打入 maindex
*/
class AnnotationWrapper {

fun test() {
val reference = AnnotationWrapperReference()
}

@kotlin.annotation.Retention(SOURCE)
@StringDef(A, B)
annotation class Nothing {
companion object {
const val A = "a"
const val B = "b"
}
}
}
11 changes: 0 additions & 11 deletions app/src/main/java/com/joker/maindexkeep/annotations/ClassAnn.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.joker.maindexkeep.annotations

import kotlin.annotation.AnnotationRetention.BINARY

@kotlin.annotation.Retention(BINARY)
@Target(AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER,
AnnotationTarget.PROPERTY_SETTER)
annotation class ClassAnn

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.joker.maindexkeep.annotations

import kotlin.annotation.AnnotationRetention.RUNTIME

@kotlin.annotation.Retention(RUNTIME)
@Target(AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER,
AnnotationTarget.PROPERTY_SETTER, AnnotationTarget.CLASS, AnnotationTarget.FILE,
AnnotationTarget.ANNOTATION_CLASS)
annotation class RuntimeAnn
13 changes: 0 additions & 13 deletions app/src/main/java/com/joker/maindexkeep/annotations/Type.java

This file was deleted.

14 changes: 14 additions & 0 deletions app/src/main/java/com/joker/maindexkeep/annotations/Type.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.joker.maindexkeep.annotations

import android.support.annotation.StringDef
import kotlin.annotation.AnnotationRetention.RUNTIME

@RuntimeAnn
@kotlin.annotation.Retention(RUNTIME)
@StringDef(Type.A, Type.B)
annotation class Type {
companion object {
const val A = "a"
const val B = "b"
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package com.joker.maindexkeep.model

class AnnotationWrapperReference : AnnotationWrapperReferenceBase()

0 comments on commit 59349c0

Please sign in to comment.