Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ package com.qihoo360.replugin.gradle.host
class AppConstant {

/** 版本号 */
def static final VER = "${RP_VERSION}"
def static final VER = "3.1.0"

/** 打印信息时候的前缀 */
def static final TAG = "< replugin-host-v${VER} >"
Expand Down
136 changes: 136 additions & 0 deletions replugin-matrix-gradle/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
# RePlugin Matrix Gradle Plugin

RePlugin Matrix Gradle是一个Gradle插件,为RePlugin项目提供Matrix APM(Android性能监控)集成。

该Gradle插件主要负责在编译期中集成Matrix APM功能,为RePlugin宿主应用和插件提供性能监控能力。

## 主要功能

### APM监控组件
* **IO Canary** - 文件I/O监控,检测文件读写性能问题
* **Battery Canary** - 电量消耗监控,检测耗电异常
* **SQLite Canary** - 数据库操作监控,检测数据库性能问题
* **Memory Canary** - 内存泄漏检测,监控内存使用情况

### Trace监控
* **方法调用追踪** - 监控方法执行时间和调用栈
* **启动性能分析** - 分析应用启动耗时
* **卡顿检测** - 检测UI线程卡顿情况

### 资源优化
* **无用资源移除** - 自动移除未使用的资源文件

## 使用方法

### 1. 在项目中应用插件

```gradle
// 在app的build.gradle中应用插件
apply plugin: 'replugin-matrix-gradle'
```

### 2. 配置Matrix参数

```gradle
repluginMatrixConfig {
// 是否启用Matrix集成
enable = true

// APM组件配置
apm {
enable = true
ioCanary = true // IO监控
batteryCanary = true // 电量监控
sqliteCanary = true // 数据库监控
memoryCanary = true // 内存监控
}

// Trace配置
trace {
enable = true
baseMethodMapFile = "app/mapping.txt" // 方法映射文件
blackListFile = "blackMethodList.txt" // 黑名单文件
}

// 资源优化配置
removeUnusedResources {
enable = false
variant = 'release'
needSign = true
}
}
```

### 3. 可用任务

* `rpMatrixInit` - 初始化Matrix APM配置
* `rpMatrixGenerateConfig` - 生成Matrix配置文件

### 4. 运行任务

```bash
# 初始化Matrix配置
./gradlew rpMatrixInit

# 生成Matrix配置文件
./gradlew rpMatrixGenerateConfig
```

## 集成效果

启用Matrix插件后,将自动:

1. 添加Matrix APM依赖库
2. 配置Matrix监控组件
3. 生成Matrix配置文件
4. 在编译过程中集成监控代码

## 依赖要求

* Android Gradle Plugin 7.0+
* Gradle 7.0+
* Matrix APM 2.0.8+

## 配置示例

完整的配置示例:

```gradle
apply plugin: 'com.android.application'
apply plugin: 'replugin-host-gradle' // RePlugin宿主插件
apply plugin: 'replugin-matrix-gradle' // Matrix APM插件

android {
// Android配置
}

repluginHostConfig {
// RePlugin宿主配置
}

repluginMatrixConfig {
enable = true
apm {
enable = true
ioCanary = true
batteryCanary = true
sqliteCanary = true
memoryCanary = true
}
trace {
enable = true
baseMethodMapFile = "app/mapping.txt"
}
}
```

## 注意事项

1. 该插件需要在Android Application插件之后应用
2. Matrix监控会对应用性能产生轻微影响,建议在Debug版本中启用
3. 生产环境使用时请仔细评估性能影响
4. 确保Matrix APM依赖库版本兼容

## 技术支持

有关RePlugin Matrix Gradle的详细描述,请访问我们的Wiki,以了解更多的内容。
37 changes: 37 additions & 0 deletions replugin-matrix-gradle/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright (C) 2005-2017 Qihoo 360 Inc.
*
* 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.
*/

plugins {
id 'java'
id 'groovy'
id 'maven-publish'
}

repositories {
google()
mavenCentral()
}

dependencies {
implementation 'org.codehaus.groovy:groovy:2.4.7'

implementation gradleApi()
implementation localGroovy()
}

project.ext.RP_ARTIFACT_ID = 'replugin-matrix-gradle'
// Temporarily disable publishing to test basic build
// apply from: '../rp-publish.gradle'
33 changes: 33 additions & 0 deletions replugin-matrix-gradle/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#
# Copyright (C) 2005-2017 Qihoo 360 Inc.
#
# 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.
#

# Project-wide Gradle settings.

# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.

# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html

# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx1536m

# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
Binary file not shown.
22 changes: 22 additions & 0 deletions replugin-matrix-gradle/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#
# Copyright (C) 2005-2017 Qihoo 360 Inc.
#
# 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.
#

#Mon Dec 28 10:00:20 PST 2015
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip
Loading