Skip to content

Commit

Permalink
重构demo为test。重新组织目录结构以便后续添加多插件测试。缩短了test的模块名,由于packagePlugin插件不支持自定义模块…
Browse files Browse the repository at this point in the history
…名,修改了packagePlugin插件。
  • Loading branch information
shifujun committed May 6, 2019
1 parent 9089e34 commit bd35988
Show file tree
Hide file tree
Showing 238 changed files with 169 additions and 143 deletions.
2 changes: 1 addition & 1 deletion buildScripts/gradle/maven.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ task testSdk() {
dependsOn gradle.includedBuild('core').task(':transform:test')
dependsOn gradle.includedBuild('core').task(':gradle-plugin:test')
dependsOn gradle.includedBuild('core').task(':manager:connectedDebugAndroidTest')
dependsOn ':projects:demo:host-apk:connectedDebugAndroidTest'
dependsOn ':dynamic-host-app:connectedDebugAndroidTest'
}

apply plugin: 'maven-publish'
Expand Down
91 changes: 0 additions & 91 deletions projects/demo/plugin-app/demo-plugin/build.gradle

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ private fun createGenerateConfigTask(project: Project, buildType: PluginBuildTyp

val pluginApkTasks: MutableList<String> = mutableListOf()
for (i in buildType.pluginApks) {
val task = ":" + (i.projectPath.replace("/", ":") + ":${i.buildTask}")
val task = i.buildTask
println("pluginApkProjects task = $task")
pluginApkTasks.add(task)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,7 @@ open class ShadowPluginHelper {
}

fun getPluginFile(project: Project, pluginConfig: PluginApkConfig, checkExist: Boolean): File {
val pluginFileParent = pluginConfig.buildTask.replace("assemble", "").toLowerCase()
val pluginApk = "${project.rootDir}/${pluginConfig.projectPath}/build" +
"/outputs/apk/$pluginFileParent/${pluginConfig.apkName}"
val pluginFile = File(pluginApk)
val pluginFile = File(project.rootDir, pluginConfig.apkPath)
if (checkExist && !pluginFile.exists()) {
throw IllegalArgumentException(pluginFile.absolutePath + " , plugin file not exist...")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ open class PluginApkConfig {
var businessName = ""

var apkName = ""
var projectPath = ""
var apkPath = ""
var buildTask = ""
var dependsOn: Array<String> = emptyArray()
var hostWhiteList: Array<String> = emptyArray()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ shadow {
pluginApk1 {
businessName = 'demo'
partKey = 'demo_main'
buildTask = 'assembleDebug'
buildTask = ':plugin1:assembleDebug'
apkName = 'plugin1-debug.apk'
projectPath = 'plugin1'
apkPath = 'plugin1/build/outputs/apk/debug/plugin1-debug.apk'
dependsOn = ['Core', 'Base']
hostWhiteList = ["androidx.test.espresso",
"com.tencent.shadow.demo.interfaces"]
Expand All @@ -72,9 +72,9 @@ shadow {
pluginApks {
pluginApk1 {
partKey = 'demo_main'
buildTask = 'assembleDebug'
buildTask = ':plugin1:assembleDebug'
apkName = 'plugin1-debug.apk'
projectPath = 'plugin1'
apkPath = 'plugin1/build/outputs/apk/debug/plugin1-debug.apk'
dependsOn = ['Core', 'Base']
hostWhiteList = ["androidx.test.espresso",
"com.tencent.shadow.demo.interfaces"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ shadow {
pluginApks {
pluginApk1 {
partKey = 'demo_main'
buildTask = 'assembleDebug'
buildTask = ':plugin2:assembleDebug'
apkName = 'plugin2-debug.apk'
//这里因为单元测试时,会把项目根目录设置成case1的根目录
projectPath = '/plugin2'
apkPath = 'plugin2/build/outputs/apk/debug/plugin2-debug.apk'
dependsOn = ['Core', 'Base']
hostWhiteList = ["androidx.test.espresso",
"com.tencent.shadow.demo.interfaces"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ android {
}
sourceSets {
debug {
assets.srcDir('build/generated/assets/pluginmanager-apk/debug/')
assets.srcDir('build/generated/assets/dynamic-manager/debug/')
assets.srcDir('build/generated/assets/plugin-zip/debug/')
}
release {
assets.srcDir('build/generated/assets/pluginmanager-apk/release/')
assets.srcDir('build/generated/assets/dynamic-manager/release/')
assets.srcDir('build/generated/assets/plugin-zip/release/')
}
}
Expand All @@ -46,7 +46,7 @@ dependencies {

implementation 'com.tencent.shadow.core:common'
implementation 'com.tencent.shadow.dynamic:dynamic-host'
implementation project(':projects:demo:test-util')
implementation project(':constant')

testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:core:1.1.1-alpha02'
Expand All @@ -56,7 +56,7 @@ dependencies {
implementation 'androidx.test.espresso:espresso-idling-resource:3.2.0-alpha02'
androidTestImplementation "androidx.test:runner:1.1.2-alpha02"

implementation project(':projects:demo:host_interface')
implementation project(':plugin-use-host-code-lib')
}

def createCopyTask(projectName, buildType, name, apkName, inputFile, taskName) {
Expand All @@ -76,14 +76,14 @@ def createCopyTask(projectName, buildType, name, apkName, inputFile, taskName) {

def generateAssets(generateAssetsTask, buildType) {

def moduleName = 'pluginmanager-apk'
def moduleName = 'dynamic-manager'
def pluginManagerApkFile = file(
"${project(":projects:demo:pluginmanager-apk").getBuildDir()}" +
"${project(":dynamic-manager").getBuildDir()}" +
"/outputs/apk/${buildType}/" +
"${moduleName}-${buildType}.apk"
)
generateAssetsTask.dependsOn createCopyTask(
':projects:demo:pluginmanager-apk',
':dynamic-manager',
buildType,
moduleName,
'pluginmanager.apk',
Expand All @@ -93,7 +93,7 @@ def generateAssets(generateAssetsTask, buildType) {

def demoPluginZip = file("${getRootProject().getBuildDir()}/plugin-${buildType}.zip")
generateAssetsTask.dependsOn createCopyTask(
':projects:demo:plugin-app:demo-plugin',
':plugin-main-app',
buildType,
'plugin-zip',
"plugin-${buildType}.zip",
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ dependencies {
implementation 'com.tencent.shadow.core:loader'
implementation 'com.tencent.shadow.dynamic:dynamic-loader'
implementation 'com.tencent.shadow.dynamic:dynamic-loader-impl'
implementation project(':projects:demo:test-util')
implementation project(':constant')

compileOnly 'com.tencent.shadow.core:runtime-debug'
compileOnly 'com.tencent.shadow.core:common-debug'
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ dependencies {
implementation 'com.tencent.shadow.dynamic:dynamic-manager'
implementation 'com.tencent.shadow.core:manager'
implementation 'com.tencent.shadow.dynamic:dynamic-loader'
implementation project(':projects:demo:test-util')
implementation project(':constant')

compileOnly 'com.tencent.shadow.core:common-debug'
compileOnly 'com.tencent.shadow.dynamic:dynamic-host-debug'
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ android {
}
sourceSets {
debug {
assets.srcDir('build/generated/assets/demo-plugin/debug/')
assets.srcDir('build/generated/assets/plugin-main-app/debug/')
}
release {
assets.srcDir('build/generated/assets/demo-plugin/release/')
assets.srcDir('build/generated/assets/plugin-main-app/release/')
}
}
lintOptions {
Expand Down Expand Up @@ -73,9 +73,9 @@ def createCopyTask(projectName, buildType, name, apkName) {

tasks.whenTaskAdded { task ->
if (task.name == "generateDebugAssets") {
task.dependsOn createCopyTask(':projects:demo:plugin-app:demo-plugin', 'debug', 'demo-plugin', 'plugin.apk')
task.dependsOn createCopyTask(':plugin-main-app', 'debug', 'plugin-main-app', 'plugin.apk')
}
if (task.name == "generateReleaseAssets") {
task.dependsOn createCopyTask(':projects:demo:plugin-app:demo-plugin', 'release', 'demo-plugin', 'plugin.apk')
task.dependsOn createCopyTask(':plugin-main-app', 'release', 'plugin-main-app', 'plugin.apk')
}
}
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apply plugin: 'java-library'

group 'com.tencent.shadow.host_interface'
group 'com.tencent.shadow.test.lib.plugin-use-host-code-lib'

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ android {
}

dependencies {
implementation project(':projects:demo:plugin-app:demo-main')
implementation project(':plugin-main-lib')
}

105 changes: 105 additions & 0 deletions projects/test/plugin/plugin-main/plugin-main-app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
apply from: "../plugin-main-app-no-shadow/build.gradle"

android {
defaultConfig {
applicationId "com.tencent.shadow.demo_host"
}
}

buildscript {
repositories {
maven {
url "http://maven.oa.com/nexus/content/repositories/jcenter"
}
maven {
url "http://maven.oa.com/nexus/content/repositories/google-maven/"
}
}

dependencies {
classpath 'com.tencent.shadow.core:runtime-debug'
classpath 'com.tencent.shadow.core:gradle-plugin'
classpath 'org.javassist:javassist:3.22.0-GA'
}
}

apply plugin: 'com.tencent.shadow.plugin'


shadow {
transform {
// useHostContext = ['abc']
}

packagePlugin {
pluginTypes {
debug {
loaderApkConfig = new Tuple2('dynamic-loader-debug.apk', ':dynamic-loader:assembleDebug')
runtimeApkConfig = new Tuple2('dynamic-runtime-debug.apk', ':dynamic-runtime:assembleDebug')
pluginApks {
pluginApk1 {
businessName = 'demo'
partKey = 'demo_main'
buildTask = ':plugin-main-app:assembleDebug'
apkName = 'plugin-main-app-debug.apk'
apkPath = 'projects/test/plugin/plugin-main/plugin-main-app/build/outputs/apk/debug/plugin-main-app-debug.apk'
hostWhiteList = ["androidx.test.espresso",//这个包添加是为了插件demo中可以访问测试框架的类
"com.tencent.shadow.demo.interfaces"]//测试插件访问宿主白名单类
}
pluginApk2 {
businessName = 'plugin-multidex'
partKey = 'plugin-multidex-v1_0_2'
buildTask = ':plugin-multidex-v1_0_2:assembleDebug'
apkName = 'plugin-multidex-v1_0_2-debug.apk'
apkPath = 'projects/test/plugin/plugin-multidex/plugin-multidex-v1_0_2/build/outputs/apk/debug/plugin-multidex-v1_0_2-debug.apk'
}
pluginApk3 {
businessName = 'plugin-multidex'
partKey = 'plugin-multidex-v2_0_1'
buildTask = ':plugin-multidex-v2_0_1:assembleDebug'
apkName = 'plugin-multidex-v2_0_1-debug.apk'
apkPath = 'projects/test/plugin/plugin-multidex/plugin-multidex-v2_0_1/build/outputs/apk/debug/plugin-multidex-v2_0_1-debug.apk'
}
}
}

release {
loaderApkConfig = new Tuple2('dynamic-loader-release.apk', ':dynamic-loader:assembleRelease')
runtimeApkConfig = new Tuple2('dynamic-runtime-release.apk', ':dynamic-runtime:assembleRelease')
pluginApks {
pluginApk1 {
businessName = 'demo'
partKey = 'demo_main'
buildTask = ':plugin-main-app:assembleRelease'
apkName = 'plugin-main-app-release.apk'
apkPath = 'projects/test/plugin/plugin-main/plugin-main-app/build/outputs/apk/release/plugin-main-app-release.apk'
hostWhiteList = ["androidx.test.espresso",//这个包添加是为了插件demo中可以访问测试框架的类
"com.tencent.shadow.demo.interfaces"]//测试插件访问宿主白名单类
}
pluginApk2 {
businessName = 'plugin-multidex'
partKey = 'plugin-multidex-v1_0_2'
buildTask = ':plugin-multidex-v1_0_2:assembleRelease'
apkName = 'plugin-multidex-v1_0_2-release.apk'
apkPath = 'projects/test/plugin/plugin-multidex/plugin-multidex-v1_0_2/build/outputs/apk/release/plugin-multidex-v1_0_2-release-unsigned.apk'
}
pluginApk3 {
businessName = 'plugin-multidex'
partKey = 'plugin-multidex-v2_0_1'
buildTask = ':plugin-multidex-v2_0_1:assembleRelease'
apkName = 'plugin-multidex-v2_0_1-release.apk'
apkPath = 'projects/test/plugin/plugin-multidex/plugin-multidex-v2_0_1/build/outputs/apk/release/plugin-multidex-v2_0_1-release-unsigned.apk'
}
}
}
}

loaderApkProjectPath = 'projects/test/host/dynamic/dynamic-loader'

runtimeApkProjectPath = 'projects/test/host/dynamic/dynamic-runtime'

version = 4
compactVersion = [1, 2, 3]
uuidNickName = "1.1.5"
}
}
Loading

0 comments on commit bd35988

Please sign in to comment.