Skip to content

Commit 7092f24

Browse files
authored
Merge pull request #562 from Tencent/dev
Update README & Samples
2 parents 7e493ab + c295a02 commit 7092f24

File tree

101 files changed

+2494
-1329
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+2494
-1329
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
/gradle/oss-android-template.gradle
1212
build_macos
1313
build_ios
14+
reports
1415

1516
## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9)
1617
*.xcscmblueprint

README.md

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
![Matrix-icon](assets/img/readme/header.png)
22

3-
[![license](http://img.shields.io/badge/license-BSD3-brightgreen.svg?style=flat)](https://github.com/Tencent/matrix/blob/master/LICENSE)[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/Tencent/matrix/pulls)[![WeChat Approved](https://img.shields.io/badge/Wechat%20Approved-0.6.6-red.svg)](https://github.com/Tencent/matrix/wiki)
3+
[![license](http://img.shields.io/badge/license-BSD3-brightgreen.svg?style=flat)](https://github.com/Tencent/matrix/blob/master/LICENSE)[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/Tencent/matrix/pulls)[![WeChat Approved](https://img.shields.io/badge/Wechat%20Approved-0.8.0-red.svg)](https://github.com/Tencent/matrix/wiki)
44

55
(中文版本请参看[这里](#matrix_cn))
66

@@ -169,10 +169,11 @@ At this point, Matrix has been integrated into the app and is beginning to colle
169169
- **Compatible with Android P.**
170170

171171
## Getting Started
172+
***The JCenter repository will stop service on February 1, 2022. So we uploaded Matrix(since 0.8.0) to the MavenCentral repository.***
172173

173174
1. Configure `MATRIX_VERSION` in gradle.properties.
174175
``` gradle
175-
MATRIX_VERSION=0.6.6
176+
MATRIX_VERSION=0.8.0
176177
```
177178

178179
2. Add `matrix-gradle-plugin` in your build.gradle:
@@ -225,6 +226,8 @@ At this point, Matrix has been integrated into the app and is beginning to colle
225226
}
226227
```
227228

229+
Matrix gradle plugin could work with Android Gradle Plugin 3.5.0/4.0.0/4.1.0 currently.
230+
228231
5. Implement `DynamicConfig` to change parameters of Matrix.
229232
``` java
230233
public class DynamicConfigImplDemo implements IDynamicConfig {
@@ -289,11 +292,11 @@ You can get more about Matrix output at the wiki [The output of Matrix](https://
289292

290293
#### APK Checker Usage
291294

292-
APK Checker can run independently in Jar ([matrix-apk-canary-0.6.6.jar](https://jcenter.bintray.com/com/tencent/matrix/matrix-apk-canary/0.6.6/matrix-apk-canary-0.6.6.jar)) mode, usage:
295+
APK Checker can run independently in Jar ([matrix-apk-canary-0.8.0.jar](https://repo.maven.apache.org/maven2/com/tencent/matrix/matrix-apk-canary/0.8.0/matrix-apk-canary-0.8.0.jar)) mode, usage:
293296

294297

295298
```shell
296-
java -jar matrix-apk-canary-0.6.6.jar
299+
java -jar matrix-apk-canary-0.8.0.jar
297300
Usages:
298301
--config CONFIG-FILE-PATH
299302
or
@@ -352,7 +355,7 @@ Matrix is under the BSD license. See the [LICENSE](https://github.com/Tencent/Ma
352355
353356
# <a name="matrix_cn">Matrix</a>
354357
![Matrix-icon](assets/img/readme/header.png)
355-
[![license](http://img.shields.io/badge/license-BSD3-brightgreen.svg?style=flat)](https://github.com/Tencent/matrix/blob/master/LICENSE)[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/Tencent/matrix/pulls) [![WeChat Approved](https://img.shields.io/badge/Wechat%20Approved-0.6.6-red.svg)](https://github.com/Tencent/matrix/wiki)
358+
[![license](http://img.shields.io/badge/license-BSD3-brightgreen.svg?style=flat)](https://github.com/Tencent/matrix/blob/master/LICENSE)[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/Tencent/matrix/pulls) [![WeChat Approved](https://img.shields.io/badge/Wechat%20Approved-0.8.0-red.svg)](https://github.com/Tencent/matrix/wiki)
356359
357360
**Matrix** 是一款微信研发并日常使用的应用性能接入框架,支持iOS, macOS和Android。
358361
Matrix 通过接入各种性能监控方案,对性能监控项的异常数据进行采集和分析,输出相应的问题分析、定位与优化建议,从而帮助开发者开发出更高质量的应用。
@@ -470,7 +473,6 @@ Matrix-android 当前监控范围包括:应用安装包大小,帧率变化
470473
- IO Canary:
471474
检测文件 IO 问题,包括:文件 IO 监控和 Closeable Leak 监控
472475

473-
474476
## 特性
475477

476478
与常规的 APM 工具相比,Matrix 拥有以下特点:
@@ -507,10 +509,11 @@ Matrix-android 当前监控范围包括:应用安装包大小,帧率变化
507509
- 兼容到 Android P
508510

509511
## 使用方法
512+
***由于 JCenter 服务将于 2022 年 2 月 1 日下线,我们已将 Matrix 新版本(>= 0.8.0) maven repo 发布至 MavenCentral。***
510513

511514
1. 在你项目根目录下的 gradle.properties 中配置要依赖的 Matrix 版本号,如:
512515
``` gradle
513-
MATRIX_VERSION=0.6.6
516+
MATRIX_VERSION=0.8.0
514517
```
515518

516519
2. 在你项目根目录下的 build.gradle 文件添加 Matrix 依赖,如:
@@ -519,6 +522,7 @@ Matrix-android 当前监控范围包括:应用安装包大小,帧率变化
519522
classpath ("com.tencent.matrix:matrix-gradle-plugin:${MATRIX_VERSION}") { changing = true }
520523
}
521524
```
525+
522526
3. 接着,在 app/build.gradle 文件中添加 Matrix 各模块的依赖,如:
523527
``` gradle
524528
dependencies {
@@ -541,6 +545,8 @@ Matrix-android 当前监控范围包括:应用安装包大小,帧率变化
541545
}
542546
```
543547
548+
目前 Matrix gradle plugin 支持 Android Gradle Plugin 3.5.0/4.0.0/4.1.0。
549+
544550
4. 实现 PluginListener,接收 Matrix 处理后的数据, 如:
545551
``` java
546552
public class TestPluginListener extends DefaultPluginListener {
@@ -624,10 +630,10 @@ Matrix 分析后的输出字段的含义请查看 [Matrix 输出内容的含义
624630
625631
#### APK Checker
626632
627-
APK Check 以独立的 jar 包提供 ([matrix-apk-canary-0.6.6.jar](https://jcenter.bintray.com/com/tencent/matrix/matrix-apk-canary/0.6.6/matrix-apk-canary-0.6.6.jar)),你可以运行:
633+
APK Check 以独立的 jar 包提供 ([matrix-apk-canary-0.8.0.jar](https://repo.maven.apache.org/maven2/com/tencent/matrix/matrix-apk-canary/0.8.0/matrix-apk-canary-0.8.0.jar)),你可以运行:
628634
629635
```cmd
630-
java -jar matrix-apk-canary-0.6.6.jar
636+
java -jar matrix-apk-canary-0.8.0.jar
631637
```
632638
633639
查看 Usages 来使用它。

matrix/matrix-android/build.gradle

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,47 +4,59 @@ buildscript {
44

55
mavenLocal()
66
google()
7-
jcenter()
7+
mavenCentral()
88

9+
jcenter() // Need 'org.jetbrains.trove4j:trove4j:20160824'
910
}
1011

1112
gradle.ext.KOTLIN_VERSION = "1.3.72"
1213

1314
dependencies {
1415
// classpath
15-
classpath 'com.android.tools.build:gradle:3.2.1'
16-
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
16+
classpath 'com.android.tools.build:gradle:4.1.0'
1717
classpath 'digital.wup:android-maven-publish:3.6.2'
1818
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$gradle.KOTLIN_VERSION"
1919
}
2020

2121
}
2222

23-
//for upload
24-
//apply from: rootProject.file('gradle/oss-android-template.gradle')
25-
23+
Properties localProperties = new Properties()
24+
localProperties.load(project.rootProject.file('local.properties').newDataInputStream())
25+
def SigningFromLocalProperties(properties, project, String prop) {
26+
if (properties.getProperty(prop)) {
27+
project.ext[prop] = properties.getProperty(prop)
28+
}
29+
}
2630
allprojects {
2731
repositories {
2832

2933
mavenLocal()
3034
google()
31-
jcenter()
35+
mavenCentral()
3236

37+
jcenter() // Need 'com.tencent.tinker:tinker-ziputils:1.9.2'
3338
}
3439

3540
tasks.withType(Javadoc).all {
3641
enabled = false // TODO:
3742
options.setEncoding('UTF-8')
3843
}
44+
45+
SigningFromLocalProperties(localProperties, project, 'REPOSITORY_USERNAME' as String)
46+
SigningFromLocalProperties(localProperties, project, 'REPOSITORY_PASSWORD' as String)
47+
SigningFromLocalProperties(localProperties, project, 'signing.keyId' as String)
48+
SigningFromLocalProperties(localProperties, project, 'signing.password' as String)
49+
SigningFromLocalProperties(localProperties, project, 'signing.secretKeyRingFile' as String)
50+
3951
}
4052

4153

4254
ext {
4355
// For android sub-projects
4456
minSdkVersion = 19
4557
targetSdkVersion = 23
46-
compileSdkVersion = 28
47-
buildToolsVersion = '28.0.3'
58+
compileSdkVersion = 29
59+
buildToolsVersion = '29.0.2'
4860

4961
javaVersion = JavaVersion.VERSION_1_8
5062

@@ -53,7 +65,8 @@ ext {
5365
PUBLISH_CHANNEL = "${PUBLISH_CHANNEL}"
5466

5567
POM_PACKAGING = "pom"
56-
POM_DESCRIPTION = "matrix"
68+
POM_NAME = "Matrix for Android"
69+
POM_DESCRIPTION = "Matrix is an APM (Application Performance Manage) used in Wechat to monitor, locate and analyse performance problems. It is a plugin style, non-invasive solution and is currently available on iOS, macOS and Android."
5770

5871
POM_URL = "https://github.com/Tencent/Matrix"
5972
POM_SCM_URL = "https://github.com/Tencent/Matrix.git"

matrix/matrix-android/checkstyle.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,13 @@
8888
<!-- Checks for whitespace -->
8989
<!-- See http://checkstyle.sf.net/config_whitespace.html -->
9090
<module name="GenericWhitespace"/>
91-
<module name="EmptyForIteratorPad"/>
91+
<!-- <module name="EmptyForIteratorPad"/>-->
9292
<module name="MethodParamPad"/>
9393

9494

9595
<module name="NoWhitespaceAfter"/>
9696
<module name="NoWhitespaceBefore"/>
97-
<module name="OperatorWrap"/>
97+
<!-- <module name="OperatorWrap"/>-->
9898
<module name="ParenPad"/>
9999
<module name="TypecastParenPad"/>
100100
<module name="WhitespaceAfter"/>

matrix/matrix-android/gradle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryErro
1515
#Tue Jun 20 10:24:33 CST 2017
1616

1717

18-
VERSION_NAME_PREFIX=0.8.0
18+
VERSION_NAME_PREFIX=0.8.1
1919
VERSION_NAME_SUFFIX=
20-
## two options: Internal (for wechat), External (for outsize person)
20+
## two options: Internal (for wechat), External (for public repo)
2121
PUBLISH_CHANNEL=Internal

matrix/matrix-android/gradle/WeChatNativeDepend.gradle

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,13 +210,30 @@ def getExtractedNativeDependenciesDir() {
210210
return new File(getNativeDependencyRoot(), EXTRACTED_NATIVE_DEPENDENCIES_DIR_NAME)
211211
}
212212

213+
def cleanDirectory(directory) {
214+
if (!directory.exists()) {
215+
return
216+
} else if (!directory.isDirectory()) {
217+
return
218+
} else {
219+
File[] files = directory.listFiles();
220+
if (files == null) {
221+
return
222+
}
223+
224+
for (File file: files) {
225+
org.gradle.util.GFileUtils.forceDelete(file)
226+
}
227+
}
228+
}
229+
213230
def copyExportedHeaders(targetVariant) {
214231
def exportedArtifactsDir = getExportedNativeArtifactsDir(targetVariant)
215232
def exportedHeadersDir = new File(exportedArtifactsDir, HEADERS_DIR_NAME)
216233
if (!exportedHeadersDir.exists()) {
217234
exportedHeadersDir.mkdirs()
218235
} else {
219-
org.gradle.util.GFileUtils.cleanDirectory(exportedHeadersDir)
236+
cleanDirectory(exportedHeadersDir)
220237
}
221238
def headerFilters = getExportedHeaderFilters(targetVariant)
222239
copy {
@@ -262,7 +279,7 @@ def mountCopyNativePrebuiltsAction(targetVariant) {
262279
def bundleTask = targetVariant.getPackageLibrary() as Zip
263280
targetVariant.getExternalNativeBuildTasks().each { nativeBuildTask ->
264281
nativeBuildTask.doLast {
265-
org.gradle.util.GFileUtils.cleanDirectory(exportedPrebuiltsDir)
282+
cleanDirectory(exportedPrebuiltsDir)
266283
copy {
267284
duplicatesStrategy DuplicatesStrategy.FAIL
268285
includeEmptyDirs = false
@@ -462,7 +479,7 @@ def generateBuildInfoModule() {
462479
if (!buildInfoModuleDir.exists()) {
463480
buildInfoModuleDir.mkdirs()
464481
} else {
465-
org.gradle.util.GFileUtils.cleanDirectory(buildInfoModuleDir)
482+
cleanDirectory(buildInfoModuleDir)
466483
}
467484

468485
def hasBuildVersion = project.extensions.findByName('wechatPublish') != null

matrix/matrix-android/gradle/android-publish-private.gradle

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,6 @@ android.libraryVariants.all { variant ->
133133

134134
}
135135

136-
// require gradle 4.x +
137-
if (GradleVersion.current() < GradleVersion.version('4.0')) {
138-
throw new GradleException('android-publish.gradle need Gradle 4.0 or newer')
139-
}
140-
141136
def publicationName = "component${variant.name.capitalize()}"
142137

143138
// Declare publications

matrix/matrix-android/gradle/android-publish.gradle

Lines changed: 14 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
apply plugin: 'maven-publish'
1010
apply plugin: 'digital.wup.android-maven-publish'
1111
apply plugin: 'signing'
12-
apply plugin: 'com.jfrog.bintray'
13-
1412

1513
def isReleaseBuild() {
1614
return version.contains("SNAPSHOT") == false
@@ -42,14 +40,6 @@ def getRepositoryPassword() {
4240
return hasProperty('REPOSITORY_PASSWORD') ? REPOSITORY_PASSWORD : readPropertyFromLocalProperties('REPOSITORY_PASSWORD')
4341
}
4442

45-
def getBintrayUser() {
46-
return hasProperty('BINTRAY_USER') ? BINTRAY_USER : readPropertyFromLocalProperties('BINTRAY_USER')
47-
}
48-
49-
def getBintrayKey() {
50-
return hasProperty('BINTRAY_APIKEY') ? BINTRAY_APIKEY : readPropertyFromLocalProperties('BINTRAY_APIKEY')
51-
}
52-
5343
def pomConfig = {
5444
scm {
5545
url POM_SCM_URL
@@ -70,9 +60,11 @@ def pomConfig = {
7060
name POM_DEVELOPER_NAME
7161
}
7262
}
63+
64+
name POM_NAME
65+
url POM_URL
7366
}
7467

75-
def bintrayPublicationNames = []
7668
android.libraryVariants.all { variant ->
7769
// Skipped debug variants
7870
if (variant.buildType.name == "debug") {
@@ -143,14 +135,7 @@ android.libraryVariants.all { variant ->
143135
}
144136
}
145137

146-
// require gradle 4.x +
147-
if (GradleVersion.current() < GradleVersion.version('4.0')) {
148-
throw new GradleException('android-publish.gradle need Gradle 4.0 or newer')
149-
}
150-
151-
// For bintrayUpload
152138
def publicationName = "component${variant.name.capitalize()}"
153-
bintrayPublicationNames.add(publicationName)
154139

155140
// Declare publications
156141
publishing.publications {
@@ -168,11 +153,22 @@ android.libraryVariants.all { variant ->
168153
// append additional configurations
169154
pom.withXml {
170155
asNode().children().last() + pomConfig
156+
asNode().appendNode('description', POM_DESCRIPTION) // Needed by MavenCentral
171157
}
172158
}
173159
}
174160
}
175161

162+
if (project.hasProperty("signing.keyId")) {
163+
signing {
164+
publishing.publications.all { publication ->
165+
sign publication
166+
}
167+
}
168+
} else {
169+
println "[W] No signing configurations."
170+
}
171+
176172
/**
177173
* Setup custom maven repo
178174
*/
@@ -186,30 +182,6 @@ publishing.repositories {
186182
}
187183
}
188184

189-
/**
190-
* Then update bintray configurations
191-
*/
192-
afterEvaluate {
193-
bintray {
194-
user = getBintrayUser()
195-
key = getBintrayKey()
196-
publications = bintrayPublicationNames
197-
198-
pkg {
199-
repo = 'maven'
200-
userOrg = BINTRAY_ORGANIZATION
201-
name = "${GROUP}:${POM_ARTIFACT_ID}"
202-
licenses = BINTRAY_LICENCE
203-
vcsUrl = POM_SCM_URL
204-
websiteUrl = POM_URL
205-
issueTrackerUrl = POM_ISSUE_URL
206-
publicDownloadNumbers = true
207-
publish = true
208-
dryRun = false
209-
}
210-
}
211-
}
212-
213185
if (JavaVersion.current().isJava8Compatible()) {
214186
allprojects {
215187
tasks.withType(Javadoc) {
@@ -248,12 +220,4 @@ task buildAndPublishRepo(type: Copy, dependsOn: ['build', 'publish']) {
248220
}
249221
}
250222

251-
tasks.getByName("bintrayUpload") {
252-
it.doFirst {
253-
if (!isReleaseBuild()) {
254-
throw new GradleException("bintrayUpload only support release version")
255-
}
256-
}
257-
}
258-
259223
apply from: rootProject.file('gradle/check.gradle')

0 commit comments

Comments
 (0)