# annotation-ohos **Repository Path**: binai/annotation-ohos ## Basic Information - **Project Name**: annotation-ohos - **Description**: 一个鸿蒙(HarmonyOS)Annotation注解的封装库。在应用开发中,使用此库中的注解,可以提交开发效率,降低开发难度。 - **Primary Language**: Java - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 1 - **Created**: 2021-09-29 - **Last Updated**: 2021-09-29 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # annotation-ohos #### 介绍 一个鸿蒙(HarmonyOS)系统Annotation注解的封装库。在应用开发中,使用此库中的注解,可以提交开发效率,降低开发难度。 #### 安装教程 1. 在项目根目录的build.gradle添加中央仓库 ```gradle repositories { //... mavenCentral() } ``` 2. 在module(如:entry)的build.gradle引用 ```Gradle dependencies { //... implementation 'io.gitee.binai:ohosx-annotation:1.0.0' } ``` #### 注解说明 | 注解/Annotation | 描述/Description | | --------------- | ------------------------------------------------------------ | | `@Keep` | 注解在不需要混淆的java类、属性和方法上,标记此类、属性和方法不需要进行混淆操作。 | | | | #### 使用说明 1. 在工程module下面的build.gradle文件中开启代码混淆功能。 ```tex buildTypes { release { proguardOpt { proguardEnabled true rulesFiles 'proguard-rules.pro' } } debug { proguardOpt { proguardEnabled true rulesFiles 'proguard-rules.pro' } } } ``` 2. 在proguard-rules.pro文件中添加混淆规则。 ```protobuf #打印混淆信息 -verbose #代码优化选项,不加该行会将没有用到的类删除,这里为了验证时间结果而使用,在实际生产环境中可根据实际需要选择是否使用 -dontshrink -dontwarn com.talkweb.ohosx.annotation.Keep #保留注解,如果不添加改行会导致我们的@Keep注解失效 -keepattributes *Annotation* -keep @com.talkweb.ohosx.annotation.Keep class **{ @com.talkweb.ohosx.annotation.Keep ; @com.talkweb.ohosx.annotation.Keep ; } ``` 3. 对代码不需要参与混淆的类、属性和方法进行@Keep注解标记。 ```java @Keep public class KeepTest { @Keep private String username; private int userAge; public String getUsername() { return username; } public void setUsername(String username) { this.username = username; } @Keep public int getUserAge() { return userAge; } public void setUserAge(int userAge) { this.userAge = userAge; } } ``` #### License ```text Copyright 2021 aibin Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ```