Skip to content

Commit

Permalink
update script and readme
Browse files Browse the repository at this point in the history
  • Loading branch information
chenenyu committed Aug 3, 2018
1 parent 97a7409 commit 2026fb4
Show file tree
Hide file tree
Showing 12 changed files with 65 additions and 58 deletions.
73 changes: 34 additions & 39 deletions README.md
Expand Up @@ -2,53 +2,54 @@

# Router

建议浏览[中文wiki](https://github.com/chenenyu/Router/wiki). It's better than you think.
[中文wiki](https://github.com/chenenyu/Router/wiki). 方便的话给个star!❤️

![screenshot](static/screenshot.gif)

## Getting started

* Add dependencies by adding the following lines to your `build.gradle`:
#### [Branch 1.5 see here](https://github.com/chenenyu/Router/tree/1.5)

* Add router gradle plugin to your project-level `build.gradle`, as shown below.

```Groovy
android {
defaultConfig {
...
javaCompileOptions {
annotationProcessorOptions {
// 每个使用Router的module都要配置该参数
arguments = ["moduleName": project.name]
}
}
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:+'
classpath "com.chenenyu.router:gradle-plugin:版本号"
}
}
dependencies {
implementation 'com.chenenyu.router:router:版本号'
// 每个使用了Router注解的module都要添加该注解处理器
annotationProcessor 'com.chenenyu.router:compiler:版本号'
}
```
latest `router-gradle-plugin` version: ![Download](https://api.bintray.com/packages/chenenyu/maven/router-gradle-plugin/images/download.svg)

latest `router` version: ![Download](https://api.bintray.com/packages/chenenyu/maven/router/images/download.svg)

latest `compiler` version: ![compiler](https://api.bintray.com/packages/chenenyu/maven/router-compiler/images/download.svg)
* Apply router plugin in your module-level 'build.gradle'.

## 基本用法
```Groovy
apply plugin: 'com.android.application' // apply plugin: 'com.android.library'
apply plugin: 'com.chenenyu.router'
```

1. 初始化
**注意**: 在rootProject的`build.gradle`文件中, 可以指定插件引用的library版本.

```java
Router.initialize(new Configuration.Builder()
// 调试模式,开启后会打印log
.setDebuggable(BuildConfig.DEBUG)
// 模块名(即project.name),每个使用Router的module都要在这里注册
.registerModules("lib_module", "other_module", "app_module")
.build());
```groovy
ext {
routerVersion = 'x.y.z'
compilerVersion = 'x.y.z'
}
```
latest `router` version: ![Download](https://api.bintray.com/packages/chenenyu/maven/router/images/download.svg)

latest `compiler` version: ![compiler](https://api.bintray.com/packages/chenenyu/maven/router-compiler/images/download.svg)


2. 添加拦截器(可选)
## 基本用法

* 添加拦截器(可选)

```java
@Interceptor("SampleInterceptor")
Expand All @@ -61,7 +62,7 @@ public class SampleInterceptor implements RouteInterceptor {
}
```

3. 添加注解
* 添加注解

```java
// 给Activity添加注解,指定了路径和拦截器(可选)
Expand All @@ -85,7 +86,7 @@ public class TestFragment extends Fragment {
}
```

4. 跳转
* 跳转

```java
// 简单跳转
Expand All @@ -101,6 +102,7 @@ Router.build("test").go(this, new RouteCallback() {
// do something
}
});

// 获取路由对应的intent
Router.build("test").getIntent();
// 获取注解的Fragment
Expand All @@ -111,15 +113,8 @@ Router.build("test").getFragment();

建议浏览 [wiki](https://github.com/chenenyu/Router/wiki).

## ProGuard

```
# Router
-keep class com.chenenyu.router.** {*;}
-keep class * implements com.chenenyu.router.template.** {*;}
```

## 谁在使用Rouer
## 谁在使用Router

<div>
<a href="http://sj.qq.com/myapp/detail.htm?apkName=com.sankuai.erp.mcashier">
Expand Down
4 changes: 3 additions & 1 deletion Sample/app/build.gradle
@@ -1,5 +1,7 @@
apply plugin: 'com.android.application'
apply plugin: 'com.chenenyu.router'
if (Boolean.valueOf(applyRouterPlugin)) {
apply plugin: 'com.chenenyu.router'
}

android {
compileSdkVersion rootProject.ext.compileSdkVersion
Expand Down
4 changes: 3 additions & 1 deletion Sample/kotlin-app/build.gradle
@@ -1,7 +1,9 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'com.chenenyu.router'
if (Boolean.valueOf(applyRouterPlugin)) {
apply plugin: 'com.chenenyu.router'
}

android {
compileSdkVersion rootProject.ext.compileSdkVersion
Expand Down
4 changes: 3 additions & 1 deletion Sample/module1/build.gradle
@@ -1,5 +1,7 @@
apply plugin: 'com.android.library'
apply plugin: 'com.chenenyu.router'
if (Boolean.valueOf(applyRouterPlugin)) {
apply plugin: 'com.chenenyu.router'
}

android {
compileSdkVersion rootProject.ext.compileSdkVersion
Expand Down
4 changes: 3 additions & 1 deletion Sample/module2/build.gradle
@@ -1,5 +1,7 @@
apply plugin: 'com.android.library'
apply plugin: 'com.chenenyu.router'
if (Boolean.valueOf(applyRouterPlugin)) {
apply plugin: 'com.chenenyu.router'
}

android {
compileSdkVersion rootProject.ext.compileSdkVersion
Expand Down
2 changes: 1 addition & 1 deletion annotation/build.gradle
Expand Up @@ -3,7 +3,7 @@ apply plugin: 'java'
ext {
GROUP = 'com.chenenyu.router'
ARTIFACT = 'annotation'
VERSION = property("ANNOTATION_VERSION")
VERSION = ANNOTATION_VERSION
BINTRAY_NAME = 'router-annotation'
}

Expand Down
6 changes: 4 additions & 2 deletions build.gradle
@@ -1,15 +1,17 @@
buildscript {
ext.kotlin_version = '1.2.51'
repositories {
maven { url 'repo' }
google()
jcenter()
maven { url 'repo' }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0-beta05'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.0"
classpath "com.chenenyu.router:gradle-plugin:1.6.0"
if (Boolean.valueOf(applyRouterPlugin)) {
classpath "com.chenenyu.router:gradle-plugin:${PLUGIN_VERSION}"
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions compiler/build.gradle
Expand Up @@ -8,13 +8,13 @@ dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.squareup:javapoet:1.9.0'
// compile project(':annotation')
compile "com.chenenyu.router:annotation:${property("ANNOTATION_VERSION")}"
compile "com.chenenyu.router:annotation:${ANNOTATION_VERSION}"
}

ext {
GROUP = 'com.chenenyu.router'
ARTIFACT = 'compiler'
VERSION = property("COMPILER_VERSION")
VERSION = COMPILER_VERSION
BINTRAY_NAME = 'router-compiler'
}

Expand Down
2 changes: 1 addition & 1 deletion gradle-plugin/build.gradle
Expand Up @@ -15,7 +15,7 @@ dependencies {
ext {
GROUP = 'com.chenenyu.router'
ARTIFACT = 'gradle-plugin'
VERSION = property('PLUGIN_VERSION')
VERSION = PLUGIN_VERSION
BINTRAY_NAME = 'router-gradle-plugin'
}

Expand Down
8 changes: 5 additions & 3 deletions gradle.properties
Expand Up @@ -11,11 +11,13 @@ org.gradle.jvmargs=-Xmx1536m
# 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
# apply router plugin
applyRouterPlugin=true
# router gradle plugin version
PLUGIN_VERSION=1.6.0-alpha1
PLUGIN_VERSION=1.6.0-beta1
# router library version
ROUTER_VERSION=1.6.0-alpha1
ROUTER_VERSION=1.6.0
# compiler library version
COMPILER_VERSION=1.6.0-alpha1
COMPILER_VERSION=1.6.0
# annotation library version
ANNOTATION_VERSION=0.4.0
6 changes: 3 additions & 3 deletions release.sh
@@ -1,13 +1,13 @@
# annotation
./gradlew clean publish -p annotation
./gradlew clean pBPTML -p annotation
./gradlew bintrayUpload -p annotation

# compiler
./gradlew clean publish -p compiler
./gradlew clean pBPTML -p compiler
./gradlew bintrayUpload -p compiler

# router
./gradlew clean publish -p router
./gradlew clean pBPTML -p router
./gradlew bintrayUpload -p router

# gradle-plugin
Expand Down
6 changes: 3 additions & 3 deletions router/build.gradle
Expand Up @@ -8,7 +8,7 @@ android {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName property("ROUTER_VERSION")
versionName ROUTER_VERSION
}

buildTypes {
Expand All @@ -31,13 +31,13 @@ dependencies {
testImplementation 'junit:junit:4.12'
compileOnly "com.android.support:support-v4:24.2.0"
// api project(':annotation')
api "com.chenenyu.router:annotation:${property("ANNOTATION_VERSION")}"
api "com.chenenyu.router:annotation:${ANNOTATION_VERSION}"
}

ext {
GROUP = 'com.chenenyu.router'
ARTIFACT = 'router'
VERSION = property("ROUTER_VERSION")
VERSION = ROUTER_VERSION
BINTRAY_NAME = 'router'
}

Expand Down

0 comments on commit 2026fb4

Please sign in to comment.