Skip to content

Commit

Permalink
兼容 Gradle 4.4 + Android Gradle Plugin 3.0.x/3.1.x (#13)
Browse files Browse the repository at this point in the history
* feat(plugin-gradle): 支持 Gradle 4.4 + AGP 3.1.4

*** BREAKING CHANGE ***

implementation 依赖不是传递的,excludeLib 配置不能如之前的版本一样
剔除所有依赖的包

例如:只剔除 support-v4 无法剔除其依赖的其它包,需要一一列出来

excludeLib "com.android.support:support-v4:${androidVersion.supportLib}"
excludeLib "com.android.support:support-core-ui:${androidVersion.supportLib}"
excludeLib "com.android.support:support-compat:${androidVersion.supportLib}"
excludeLib "com.android.support:support-media-compat:${androidVersion.supportLib}"
excludeLib "com.android.support:support-core-utils:${androidVersion.supportLib}"
excludeLib "com.android.support:support-fragment:${androidVersion.supportLib}"
excludeLib "com.android.support:versionedparcelable:${androidVersion.supportLib}"
excludeLib "android.arch.lifecycle:runtime:${androidVersion.archLib}"
excludeLib "android.arch.lifecycle:common:${androidVersion.archLib}"
excludeLib "android.arch.core:common:${androidVersion.archLib}"

* feat(host-gradle): 支持 Gradle 4.4 + AGP 3.1.4

同时兼容
- Gradle 3.3 + AGP 2.3.3
- Gradle 4.4 + AGP 3.0.x

修改内容:
host-gradle 插件生成宿主依赖的 maven 库清单

* fix(plugin-view): crash when show notification

the small icon resource id should be placed in host

* fix(plugin-gradle): 生成的依赖描述文件为空

* fix(plugin-gradle): 剔除第三方依赖库失效

* chore: 注释开发调试时使用的 mavenLocal 仓库

* doc: 添加 CHANGELOG.md 文档

增加 release notes 文档

* fix: javadoc issue when publish to bintray
  • Loading branch information
shaobin0604 committed Jan 14, 2019
1 parent 363c059 commit 1f027f5
Show file tree
Hide file tree
Showing 37 changed files with 1,998 additions and 349 deletions.
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

# v3.1.2 @2019-01-14

## Features

- 兼容 Gradle 4.4 + Android Gradle Plugin 3.0.x/3.1.x

## Behavior Changes

- Gradle 4.x + Android Gradle Plugin 3.x
- 编译插件使用的 phantom-plugin-gradle gradle 插件提供的剔除公共库功能 `excludeLib` **不会**自动剔除指定库依赖的其它库,需要单独配
置。详见 [phantom-sample/plugin-component/build.gradle](phantom-sample/plugin-component/build.gradle)中对 `support-v4`
库及其依赖库的 `excludeLib` 配置
- Gradle 3.3 + Android Gradle Plugin 2.3.3
- 编译插件使用的 phantom-plugin-gradle gradle 插件提供的剔除公共库功能 `excludeLib` ****自动将指定库及其依赖的其它库全部剔除。

## Build Changes

- 升级到 Gradle 4.4 + Android Gradle Plugin 3.1.4

# v3.0.0 @2018-10-22

初始版本发布,详细说明见 [README](README.md)
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[![license](http://img.shields.io/badge/license-Apache2.0-brightgreen.svg?style=flat)](https://github.com/ManbangGroup/Phantom/blob/master/LICENSE)
[![Release Version](https://img.shields.io/badge/release-3.0.0-brightgreen.svg)](https://github.com/ManbangGroup/Phantom/releases)
[![Release Version](https://img.shields.io/badge/release-3.1.2-brightgreen.svg)](https://github.com/ManbangGroup/Phantom/releases)

# Phantom — 唯一零 Hook 稳定占坑类 Android 热更新插件化方案

Expand Down Expand Up @@ -36,7 +36,7 @@ Phantom 是满帮集团开源的一套稳定、灵活、兼容性好的 Android
```groovy
buildscript {
dependencies {
classpath 'com.wlqq.phantom:phantom-host-gradle:3.0.0'
classpath 'com.wlqq.phantom:phantom-host-gradle:3.1.2'
}
}
```
Expand All @@ -45,7 +45,7 @@ buildscript {

```groovy
dependencies {
compile 'com.wlqq.phantom:phantom-host-lib:3.0.0'
compile 'com.wlqq.phantom:phantom-host-lib:3.1.2'
}
apply plugin: 'com.wlqq.phantom.host'
Expand Down Expand Up @@ -88,7 +88,7 @@ if (ret.isSuccess() && ret.plugin.start()) {
```groovy
buildscript {
dependencies {
classpath 'com.wlqq.phantom:phantom-plugin-gradle:3.0.0'
classpath 'com.wlqq.phantom:phantom-plugin-gradle:3.1.2'
}
}
```
Expand All @@ -108,7 +108,7 @@ android {
}
dependencies {
provided 'com.wlqq.phantom:phantom-plugin-lib:3.0.0'
provided 'com.wlqq.phantom:phantom-plugin-lib:3.1.2'
compile 'com.android.support:support-v4:28.0.0'
}
Expand Down Expand Up @@ -137,7 +137,7 @@ phantomPluginConfig {
}
```

#### 在插件 `AndroidManifest.xml` 中申明对宿主 Phantom 插件框架版本依赖(目前版本名是 3.0.0,对应版本号为 30000)
#### 在插件 `AndroidManifest.xml` 中申明对宿主 Phantom 插件框架最低版本依赖

```xml
<meta-data
Expand Down
51 changes: 19 additions & 32 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,32 +15,37 @@
*/

// Top-level build file where you can add configuration options common to all sub-projects/modules.
apply from: "version.gradle"

buildscript {
repositories {
// mavenLocal()
jcenter()
maven {
url 'https://maven.google.com'
url 'http://maven.aliyun.com/'
}
jcenter()
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath "com.android.tools.build:gradle:3.1.4"

classpath 'com.wlqq.phantom:phantom-host-gradle:3.0.0'
classpath 'com.wlqq.phantom:phantom-plugin-gradle:3.0.0'
classpath 'com.wlqq.phantom:phantom-host-gradle:3.1.2'
classpath 'com.wlqq.phantom:phantom-plugin-gradle:3.1.2'

classpath 'com.novoda:bintray-release:0.4.0' // 0.4.0 以上的版本不支持目前使用的 Gradle 3.3
classpath 'com.novoda:bintray-release:0.9'
}
}

allprojects {
repositories {
// mavenLocal()
jcenter()
maven {
url 'https://maven.google.com'
url 'http://maven.aliyun.com/'
}
jcenter()
google()
mavenCentral()
}

tasks.withType(Javadoc) {
Expand All @@ -52,40 +57,22 @@ allprojects {
}
}

ext {
// android build tools version
COMPILE_SDK_VERSION = 28
BUILD_TOOLS_VERSION = '28.0.3'
MIN_SDK_VERSION = 14
TARGET_SDK_VERSION = 22

// gradle maven dependencies version
ANDROID_SUPPORT_LIB_VERSION = '28.0.0'
ANDROID_MULTIDEX_VERSION = '1.0.3'
JUNIT_VERSION = '4.12'
ANDROID_TEST_SUPPORT_VERSION = '0.5'
ESPRESSO_VERSION = '2.2.2'
UIAUTOMATOR_VERSION = '2.1.2'

// phantom version
PHANTOM_VERSION_NAME = '3.0.0'
PHANTOM_VERSION_CODE = 30000
}

subprojects { subProject ->
subProject.tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}

tasks.withType(Javadoc).all { enabled = false }

afterEvaluate { project ->
if (project.hasProperty("android")) {
android {
compileSdkVersion COMPILE_SDK_VERSION
buildToolsVersion BUILD_TOOLS_VERSION
compileSdkVersion androidVersion.compileSdk
buildToolsVersion androidVersion.buildTools

defaultConfig {
minSdkVersion MIN_SDK_VERSION
targetSdkVersion TARGET_SDK_VERSION
minSdkVersion androidVersion.minSdk
targetSdkVersion androidVersion.targetSdk
}

lintOptions {
Expand Down
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#android.enableAapt2=false
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
2 changes: 1 addition & 1 deletion maven-version/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
apply plugin: 'java'

dependencies {
testCompile "junit:junit:$JUNIT_VERSION"
testCompile "junit:junit:${testVersion.junit}"
compile fileTree(dir: 'libs', include: ['*.jar'])
}

Expand Down
5 changes: 2 additions & 3 deletions phantom-communication-lib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ targetCompatibility = JavaVersion.VERSION_1_7

dependencies {
compileOnly 'com.google.android:android:4.+'
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
testImplementation 'junit:junit:4.12'
}

tasks.withType(JavaCompile) {
Expand All @@ -31,7 +30,7 @@ tasks.withType(JavaCompile) {

ext {
POM_ARTIFACT_ID = 'phantom-communication-lib'
POM_VERSION_NAME = rootProject.ext.PHANTOM_VERSION_NAME
POM_VERSION_NAME = phantomVersion.communicationLib
POM_DESC = 'phantom communication library'
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public interface IService extends ServiceInfo {
* @param method 方法名,见 {@link RemoteMethod#name()}
* @param args 调用参数列表
* @return 调用方法的返回值
* @throws MethodNotFoundException
* @throws MethodNotFoundException 若方法名不存在
* @see RemoteMethod#name()
*/
Object call(String method, Object... args) throws MethodNotFoundException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,43 +27,7 @@
import java.util.List;

/**
* <p>
* 管理插件或宿主提供给其他插件/宿主调用的功能接口。
* <p>
* 本类提供功能模块的注册、卸载、查询和获取功能。
* <p>
* 为了方便管理,注册 {@link #registerService(String, String, Object)} 功能模块的时候必须指定模块所属类别。<br/>
* 例如,同一个插件提供多个功能模块,他们应该属于同一类别,在插件被卸载的时候,该插件注册的功能模块也应该被卸载。<br/>
* 被注册的功能模块需要用 {@link RemoteMethod}注解来标记提供供给外部调用的方法使用。例如:
* <pre>{@code
* public class PluginService {
* @RemoteMethod(name="pluginMessage")
* public String pluginMsg(String back){
* return "from plugin " + back;
* }
* }}
* </pre>
* <p>
* <p>
* <p>
* <code>name="pluginMessage"</code> 表示外部调用 <code>pluginMsg</code> 方法时使用的名称,例如:
* <pre>{@code
* IService service = PhantomServiceManager.getService("plugin1");
* String message = (String)service.call("pluginMessage", "hi");
* }
* </pre>
* 除了使用 <code>IService</code> 的 <code>call</code> 方法来调用功能模块的方法外还可以将 <code>service</code> 转换成自定义接口来调用,
* 调用端首先需要自定义一个接口,接口中的方法,就是要调用的模块的方法,例如:
* <pre>{@code
* public interface PluginService {
* //接口方法声明与实现类中的注解名字一样
* public String pluginMessage(String back);
* }
*
* PluginService ps = PhantomServiceManager.asInterface(service, PluginService.class);
* String message = ps.pluginMessage("hi");
* }
* </pre>
* 管理插件或宿主提供给其他插件/宿主调用的功能接口,提供功能模块的注册、卸载、查询和获取功能。
*/
public class PhantomServiceManager {

Expand All @@ -82,9 +46,11 @@ private PhantomServiceManager() {
/**
* 初始化 {@link PhantomServiceManager},<b>必须</b>在调用该类其他方法之前调用该方法
*
* @param hostPackage 宿主包名
* @param hostVersionName 宿主版本名
* @param hostVersionCode 宿主版本号
* @param hostPackage 宿主包名
* @param hostVersionName 宿主版本名
* @param hostVersionCode 宿主版本号
* @param phantomVersionName Phantom 版本名
* @param phantomVersionCode Phantom 版本号
*/
public static synchronized void init(String hostPackage,
String hostVersionName,
Expand Down Expand Up @@ -331,6 +297,7 @@ public static IService getService(String name) {
/**
* 根据名字获取功能模块,返回找到的第一个名字为 name 的功能模块,并转换为 type 参数指定的接口类型,否则返回 null
*
* @param <T> interface 类型
* @param name 服务名字格式 packageName/name,如果参数 name 中省去了 packageName,则被认为是查找宿主中的服务 sHostPackage/name
* @param type 返回的对象类型, type 为必须为一个 interface
* @return 成功返回 type 的一个对象,否则返回 null
Expand Down Expand Up @@ -364,6 +331,7 @@ public static boolean hasService(String name) {
/**
* 将功能模块 service 转换成自定义接口,方便调用。
*
* @param <T> interface 类型
* @param service 需要转换的功能模块
* @param type 自定义接口
* @return 自定义接口的实现类
Expand Down
6 changes: 4 additions & 2 deletions phantom-host-gradle/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ apply plugin: 'groovy'
dependencies {
compile gradleApi()//gradle sdk
compile localGroovy()//groovy sdk
compile 'com.android.tools.build:gradle:2.3.3'
compileOnly "com.android.tools.build:gradle:${androidVersion.androidGradlePlugin}"
// https://mvnrepository.com/artifact/org.jooq/joor-java-6
compile group: 'org.jooq', name: 'joor-java-6', version: '0.9.10'
}

ext {
POM_ARTIFACT_ID = 'phantom-host-gradle'
POM_VERSION_NAME = rootProject.ext.PHANTOM_VERSION_NAME
POM_VERSION_NAME = phantomVersion.hostGradle
POM_DESC = 'phantom host gradle plugin'
}

Expand Down

0 comments on commit 1f027f5

Please sign in to comment.