Skip to content

Commit

Permalink
Merge pull request #142 from chenenyu/dev
Browse files Browse the repository at this point in the history
1.7.2
  • Loading branch information
chenenyu authored Apr 29, 2020
2 parents 492e4c0 + 1bab1a5 commit 0a023b9
Show file tree
Hide file tree
Showing 22 changed files with 255 additions and 39 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ build
/captures
.externalNativeBuild

publish.gradle
#publish.gradle
/repo
2 changes: 1 addition & 1 deletion Sample/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ android {

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "androidx.appcompat:appcompat:${rootProject.ext.androidxVersion}"
implementation "androidx.appcompat:appcompat:1.1.0"
implementation project(':module1')
implementation project(':module2')
testImplementation 'junit:junit:4.12'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ public void afterTextChanged(Editable s) {
}
});

Router.addGlobalInterceptor(new GlobalInterceptor());

// 动态添加路由
Router.handleRouteTable(new RouteTable() {
@Override
Expand Down Expand Up @@ -124,6 +126,7 @@ public void callback(RouteStatus status, Uri uri, String message) {

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == 0 && resultCode == RESULT_OK) {
String result = data.getStringExtra("extra");
Toast.makeText(this, result, Toast.LENGTH_SHORT).show();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
Uri uri = getIntent().getData();
if (uri != null) {
Log.d("SchemeFilterActivity", "uri: " + uri.toString());
if (!"router://filter".equals(uri.toString())) {
Router.build(uri).go(this);
}
// if (!"router://filter".equals(uri.toString())) {
// Router.build(uri).go(this);
// }
// 调用skipImplicitMatcher() 防止隐式启动死循环
Router.build(uri).skipImplicitMatcher().go(this);
finish();
}
}
Expand Down
2 changes: 1 addition & 1 deletion Sample/module1/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ android {

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "androidx.appcompat:appcompat:${rootProject.ext.androidxVersion}"
implementation "androidx.appcompat:appcompat:1.1.0"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
2 changes: 1 addition & 1 deletion Sample/module2/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ android {

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "androidx.appcompat:appcompat:${rootProject.ext.androidxVersion}"
implementation "androidx.appcompat:appcompat:1.1.0"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
3 changes: 2 additions & 1 deletion annotation/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ ext {
BINTRAY_NAME = 'router-annotation'
}

apply from: 'https://raw.githubusercontent.com/chenenyu/gradle-bintray-plugin/master/publish.gradle'
apply from: '../gradle/publish.gradle'
//apply from: 'https://raw.githubusercontent.com/chenenyu/gradle-bintray-plugin/master/publish.gradle'
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
buildscript {
ext.kotlin_version = '1.3.31'
ext.kotlin_version = '1.3.71'
repositories {
maven { url 'repo' }
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.1'
classpath 'com.android.tools.build:gradle:3.6.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4"
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.5"
if (Boolean.valueOf(applyRemotePlugin)) {
classpath "com.chenenyu.router:gradle-plugin:${PLUGIN_VERSION}"
}
Expand All @@ -31,5 +31,5 @@ ext {
minSdkVersion = 16
targetSdkVersion = 29

androidxVersion = "1.1.0-beta01"
// androidxVersion = "1.1.0"
}
2 changes: 1 addition & 1 deletion buildSrc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ if (!Boolean.valueOf(applyRemotePlugin)) {
dependencies {
compile gradleApi()
compile localGroovy()
compile 'com.android.tools.build:gradle:3.4.1'
compile 'com.android.tools.build:gradle:3.6.3'
}

sourceSets {
Expand Down
5 changes: 3 additions & 2 deletions compiler/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ targetCompatibility = JavaVersion.VERSION_1_8

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.squareup:javapoet:1.9.0'
compile 'com.squareup:javapoet:1.12.1'
// compile project(':annotation')
compile "com.chenenyu.router:annotation:${ANNOTATION_VERSION}"
}
Expand All @@ -21,4 +21,5 @@ ext {
BINTRAY_NAME = 'router-compiler'
}

apply from: 'https://raw.githubusercontent.com/chenenyu/gradle-bintray-plugin/master/publish.gradle'
apply from: '../gradle/publish.gradle'
//apply from: 'https://raw.githubusercontent.com/chenenyu/gradle-bintray-plugin/master/publish.gradle'
5 changes: 3 additions & 2 deletions gradle-plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ repositories {
dependencies {
implementation gradleApi()
implementation localGroovy()
compileOnly 'com.android.tools.build:gradle:3.4.1'
compileOnly 'com.android.tools.build:gradle:3.6.3'
}

ext {
Expand All @@ -21,4 +21,5 @@ ext {
BINTRAY_NAME = 'router-gradle-plugin'
}

apply from: 'https://raw.githubusercontent.com/chenenyu/gradle-bintray-plugin/master/publish.gradle'
apply from: '../gradle/publish.gradle'
//apply from: 'https://raw.githubusercontent.com/chenenyu/gradle-bintray-plugin/master/publish.gradle'
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import org.gradle.api.plugins.ExtraPropertiesExtension
class RouterPlugin implements Plugin<Project> {
static final String APT_OPTION_NAME = "moduleName"

String DEFAULT_ROUTER_RUNTIME_VERSION = "1.7.1"
String DEFAULT_ROUTER_COMPILER_VERSION = "1.7.1"
String DEFAULT_ROUTER_RUNTIME_VERSION = "1.7.2"
String DEFAULT_ROUTER_COMPILER_VERSION = "1.7.2"

String androidBuildGradleVersion

Expand Down
8 changes: 5 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ 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
android.useAndroidX=true

# apply router plugin
applyRemotePlugin=false
# router gradle plugin version
PLUGIN_VERSION=1.7.1
PLUGIN_VERSION=1.7.2
# router library version
ROUTER_VERSION=1.7.1
ROUTER_VERSION=1.7.2
# compiler library version
COMPILER_VERSION=1.7.1
COMPILER_VERSION=1.7.2
# annotation library version
ANNOTATION_VERSION=0.4.0
173 changes: 173 additions & 0 deletions gradle/publish.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
// https://github.com/chenenyu/gradle-bintray-plugin
apply plugin: 'maven-publish'
apply plugin: 'com.jfrog.bintray'

if (!project.ext.has('GROUP') || !project.ext.has('ARTIFACT') || !project.ext.has('VERSION')) {
throw new MissingPropertyException("Extra properties['GROUP', 'ARTIFACT', 'VERSION'] are required.")
}

boolean isAndroidModule = false
boolean isJavaModule = false
if (project.plugins.hasPlugin('com.android.library')) {
isAndroidModule = true
} else if (project.plugins.hasPlugin('java')) {
isJavaModule = true
} else {
throw new UnknownPluginException('Just support android/java projects now.')
}

// task to generate source.jar
task sourcesJar(type: Jar) {
group 'build'
archiveClassifier.set('sources')
}

// task to generate javadoc
if (isAndroidModule) {
sourcesJar {
from android.sourceSets.main.java.srcDirs
}

task javadoc(type: Javadoc) {
group 'documentation'
options.encoding = 'UTF-8'
source = android.sourceSets.main.java.srcDirs
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
failOnError false
}
} else if (isJavaModule) {
sourcesJar {
from sourceSets.main.java.srcDirs
}

javadoc {
options.encoding = 'UTF-8'
failOnError false
}
}

// task to generate javadoc.jar
task javadocJar(type: Jar, dependsOn: javadoc) {
group 'build'
from javadoc.getDestinationDir()
archiveClassifier.set('javadoc')
}

// handle aar artifact

// The following types/formats are supported:
// - Instances of MavenArtifact.
// - Instances of AbstractArchiveTask, for example jar.
// - Instances of PublishArtifact
// - Maps containing a 'source' entry, for example [source: '/path/to/file', extension: 'zip'].
// - Anything that can be converted to a file, as per Project.file()
def aarArtifact = null
if (isAndroidModule) {
if (project.ext.has('AAR')) {
aarArtifact = project.ext.AAR
} else {
project.afterEvaluate {
def bundleAarTask = project.tasks.findByPath('bundleRelease')
if (!bundleAarTask) {
bundleAarTask = project.tasks.findByPath('bundleReleaseAar') // gradle plugin 3.2
}
if (bundleAarTask && (bundleAarTask instanceof AbstractArchiveTask)) {
aarArtifact = bundleAarTask
}
if (!aarArtifact) {
throw new MissingPropertyException("Extra properties['AAR'] are required.")
}
}
}
}

def synchronized verifyDependency(Dependency it) {
return it.group != null && it.group != 'unspecified' && it.name != 'unspecified' &&
it.version != null && it.version != 'unspecified'
}

project.afterEvaluate {
publishing {
publications {
Bintray(MavenPublication) {
groupId project.ext.GROUP
artifactId project.ext.ARTIFACT
version project.ext.VERSION

artifact sourcesJar
artifact javadocJar
if (isAndroidModule) {
artifact aarArtifact
} else if (isJavaModule) {
from components.java
// artifact jar
}

pom {
if (isAndroidModule) {
packaging 'aar'
} else if (isJavaModule) {
packaging 'jar'
}
if (isAndroidModule) {
withXml {
def dependenciesNode = asNode().appendNode('dependencies')
configurations.compile.dependencies.each {
if (verifyDependency(it)) {
def dependencyNode = dependenciesNode.appendNode('dependency')
dependencyNode.appendNode('groupId', it.group)
dependencyNode.appendNode('artifactId', it.name)
dependencyNode.appendNode('version', it.version)
}
}
configurations.implementation.dependencies.each {
if (verifyDependency(it)) {
def dependencyNode = dependenciesNode.appendNode('dependency')
dependencyNode.appendNode('groupId', it.group)
dependencyNode.appendNode('artifactId', it.name)
dependencyNode.appendNode('version', it.version)
}
}
configurations.api.dependencies.each {
if (verifyDependency(it)) {
def dependencyNode = dependenciesNode.appendNode('dependency')
dependencyNode.appendNode('groupId', it.group)
dependencyNode.appendNode('artifactId', it.name)
dependencyNode.appendNode('version', it.version)
}
}
}
}
}
}
}
}

Properties properties = new Properties()
if (project.rootProject.file('local.properties').exists()) {
properties.load(project.rootProject.file('local.properties').newDataInputStream())
}
bintray {
user = properties.containsKey('BINTRAY_USER') ? properties.get('BINTRAY_USER') : ""
key = properties.containsKey('BINTRAY_API_KEY') ? properties.get('BINTRAY_API_KEY') : ""
publications = ['Bintray']
publish = project.ext.has('PUBLISH') ? project.ext.PUBLISH : true
override = project.ext.has('OVERRIDE') ? project.ext.OVERRIDE : false
dryRun = project.ext.has('DRYRUN') ? project.ext.DRYRUN : false
pkg {
repo = project.ext.has('BINTRAY_REPO') ? project.ext.BINTRAY_REPO : 'maven'
name = project.ext.has('BINTRAY_NAME') ? project.ext.BINTRAY_NAME : project.ext.ARTIFACT
licenses = project.ext.has('LICENSES') ? project.ext.LICENSES : ['Apache-2.0']
vcsUrl = project.ext.has('VCS_URL') ? project.ext.VCS_URL : ''
if (project.ext.has('USER_ORG')) {
userOrg = project.ext.USER_ORG
}
publicDownloadNumbers = true

version {
name = project.ext.VERSION
vcsTag = project.ext.VERSION
}
}
}
}
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Mon Apr 29 17:02:49 CST 2019
#Tue Apr 28 18:52:44 CST 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
5 changes: 3 additions & 2 deletions router/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
testImplementation 'junit:junit:4.12'
compileOnly 'androidx.annotation:annotation:1.1.0'
compileOnly "androidx.fragment:fragment:${rootProject.ext.androidxVersion}"
compileOnly "androidx.fragment:fragment:1.2.4"
// api project(':annotation')
api "com.chenenyu.router:annotation:${ANNOTATION_VERSION}"
}
Expand All @@ -46,4 +46,5 @@ ext {
BINTRAY_NAME = 'router'
}

apply from: 'https://raw.githubusercontent.com/chenenyu/gradle-bintray-plugin/master/publish.gradle'
apply from: '../gradle/publish.gradle'
//apply from: 'https://raw.githubusercontent.com/chenenyu/gradle-bintray-plugin/master/publish.gradle'
6 changes: 6 additions & 0 deletions router/src/main/java/com/chenenyu/router/AbsRouter.java
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,12 @@ public IRouter activityOptionsBundle(Bundle activityOptionsBundle) {
return this;
}

@Override
public IRouter skipImplicitMatcher() {
mRouteRequest.setSkipImplicitMatcher(true);
return this;
}

@Override
public IRouter skipInterceptors() {
mRouteRequest.setSkipInterceptors(true);
Expand Down
5 changes: 5 additions & 0 deletions router/src/main/java/com/chenenyu/router/IRouter.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ public interface IRouter {
*/
IRouter activityOptionsBundle(Bundle activityOptionsBundle);

/**
* Skip {@link com.chenenyu.router.matcher.AbsImplicitMatcher}.
*/
IRouter skipImplicitMatcher();

/**
* Skip all the interceptors.
*/
Expand Down
Loading

0 comments on commit 0a023b9

Please sign in to comment.