完美解决编译循环依赖,传递依赖问题,加速编译速度
This commit is contained in:
@@ -10,9 +10,16 @@ android {
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
debug {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
matchingFallbacks = ['default'] // instead use this
|
||||
}
|
||||
release {
|
||||
minifyEnabled true
|
||||
zipAlignEnabled true
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
matchingFallbacks = ['default'] // instead use this
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -22,12 +29,10 @@ dependencies {
|
||||
implementation 'androidx.appcompat:appcompat:1.0.2'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
|
||||
implementation 'com.google.android.material:material:1.0.0'
|
||||
testImplementation 'junit:junit:4.12'
|
||||
androidTestImplementation 'androidx.test:runner:1.2.0'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
|
||||
|
||||
implementation project(":component-core")
|
||||
implementation project(":component-support-core")
|
||||
implementation component(':library')
|
||||
implementation component(':librarykotlin')
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
package com.plugin.component;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.test.InstrumentationRegistry;
|
||||
import androidx.test.runner.AndroidJUnit4;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Instrumented test, which will execute on an Android device.
|
||||
*
|
||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||
*/
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class ExampleInstrumentedTest {
|
||||
@Test
|
||||
public void useAppContext() {
|
||||
// Context of the app under test.
|
||||
Context appContext = InstrumentationRegistry.getTargetContext();
|
||||
|
||||
assertEquals("com.plugin.module", appContext.getPackageName());
|
||||
}
|
||||
}
|
||||
@@ -5,8 +5,8 @@ import android.os.Bundle;
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
import com.plugin.component.support.anno.MethodCost;
|
||||
import com.plugin.library.IProvideFromLibrary;
|
||||
import com.plugin.library.ISdk2;
|
||||
import com.plugin.librarykotlin.IKotlinSdk;
|
||||
import com.plugin.module.R;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
@@ -38,7 +38,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
stringBuilder.append(SdkManager.getSdk(ISdk2.class).getSdk2Name());
|
||||
stringBuilder.append("\n");
|
||||
stringBuilder.append(SdkManager.getSdk(IKotlinSdk.class).getKotlinSdkName());
|
||||
stringBuilder.append(SdkManager.getSdk(IProvideFromLibrary.class).provideString());
|
||||
((TextView) findViewById(R.id.text)).setText(stringBuilder);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<resources>
|
||||
<string name="app_name">Module-Plugin</string>
|
||||
<string name="app_name">完美组件化</string>
|
||||
<string name="action_settings">Settings</string>
|
||||
</resources>
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
package com.plugin.component;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Example local unit test, which will execute on the development machine (host).
|
||||
*
|
||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||
*/
|
||||
public class ExampleUnitTest {
|
||||
@Test
|
||||
public void addition_isCorrect() {
|
||||
assertEquals(4, 2 + 2);
|
||||
}
|
||||
}
|
||||
38
build.gradle
38
build.gradle
@@ -4,20 +4,22 @@ buildscript {
|
||||
ext.component_version = '0.0.1'
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
url uri('./repo')
|
||||
}
|
||||
maven {url 'https://dl.bintray.com/yummylau/maven'}
|
||||
// maven {
|
||||
// url uri('./repo')
|
||||
// }
|
||||
// maven {url 'https://dl.bintray.com/yummylau/maven'}
|
||||
google()
|
||||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:3.3.0'
|
||||
classpath "com.effective.plugins:component:$component_version"
|
||||
classpath "com.effective.plugins:component-support:$component_version"
|
||||
// classpath "com.effective.plugins:component:$component_version"
|
||||
// classpath "com.effective.plugins:component-support:$component_version"
|
||||
//调试需要
|
||||
classpath "com.effective.plugins:component-plugin"
|
||||
classpath "com.effective.plugins:component-support-plugin"
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
classpath 'com.quinn.hunter:hunter-transform:0.9.0'
|
||||
classpath 'com.novoda:bintray-release:0.9'
|
||||
// classpath 'com.novoda:bintray-release:0.9'
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
// in the individual module build.gradle files
|
||||
}
|
||||
@@ -25,10 +27,10 @@ buildscript {
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
maven {
|
||||
url uri('./repo')
|
||||
}
|
||||
maven {url 'https://bintray.com/yummylau/maven'}
|
||||
// maven {
|
||||
// url uri('./repo')
|
||||
// }
|
||||
// maven {url 'https://bintray.com/yummylau/maven'}
|
||||
google()
|
||||
jcenter()
|
||||
}
|
||||
@@ -47,7 +49,7 @@ component {
|
||||
|
||||
mainModuleName 'app'
|
||||
|
||||
exclude ':librarywithoutplugin'
|
||||
include ':app,library,libraryKotlin,libraryKotlin2'
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
@@ -62,13 +64,3 @@ componentSupport {
|
||||
|
||||
methodCostEnable true
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -26,11 +26,7 @@ android {
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||
|
||||
implementation 'androidx.appcompat:appcompat:1.0.2'
|
||||
testImplementation 'junit:junit:4.12'
|
||||
androidTestImplementation 'androidx.test:runner:1.2.0'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
package com.effective.android.module;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.test.InstrumentationRegistry;
|
||||
import androidx.test.runner.AndroidJUnit4;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Instrumented test, which will execute on an Android device.
|
||||
*
|
||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||
*/
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class ExampleInstrumentedTest {
|
||||
@Test
|
||||
public void useAppContext() {
|
||||
// Context of the app under test.
|
||||
Context appContext = InstrumentationRegistry.getTargetContext();
|
||||
|
||||
assertEquals("com.effective.android.module.test", appContext.getPackageName());
|
||||
}
|
||||
}
|
||||
@@ -20,13 +20,17 @@ public class SdkManager {
|
||||
if (sdkImplObjectOrClass.getClass().isInterface()) {
|
||||
throw new IllegalArgumentException("register service object must not be interface.");
|
||||
}
|
||||
Class realComponentClass = sdkImplObjectOrClass instanceof Class ? (Class) sdkImplObjectOrClass : sdkImplObjectOrClass.getClass();
|
||||
Class realComponentClass = componentObjectOrClass instanceof Class ? (Class) componentObjectOrClass : componentObjectOrClass.getClass();
|
||||
Class realImplClass = sdkImplObjectOrClass instanceof Class ? (Class) sdkImplObjectOrClass : sdkImplObjectOrClass.getClass();
|
||||
if (!sdkKey.isAssignableFrom(realImplClass)) {
|
||||
throw new IllegalArgumentException(String.format("register service object must implement interface %s.", sdkKey));
|
||||
}
|
||||
Log.d(TAG, String.format("register sdk[ %s ] in component[ %s ] success, with %s", sdkKey, realComponentClass, realImplClass));
|
||||
componentInfo.registerSdk(sdkKey, sdkImplObjectOrClass);
|
||||
if (sdkImplObjectOrClass instanceof Class) {
|
||||
Log.d(TAG, String.format("register sdk[ %s ] in component[ %s ] success, with [ %s ]", sdkKey, realComponentClass, realImplClass));
|
||||
} else {
|
||||
Log.d(TAG, String.format("register sdk[ %s ] in component[ %s ] success, with object[ %s ]", sdkKey, realComponentClass, sdkImplObjectOrClass.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
public static void unregister(Class sdkKey) {
|
||||
@@ -66,21 +70,24 @@ public class SdkManager {
|
||||
result = componentInfo.getSdk(sdkKey);
|
||||
if (result instanceof Class) {
|
||||
try {
|
||||
Log.d(TAG, String.format("getting sdk[ %s ] can't find any impl object, new an impl [ %s ] object for sdk.", sdkKey, result));
|
||||
result = ((Class) result).newInstance();
|
||||
componentInfo.registerSdk(sdkKey, result);
|
||||
Log.d(TAG, String.format("before getting sdk[ %s ] , newInstance for sdk success.", sdkKey));
|
||||
Log.d(TAG, String.format("get sdk[ %s ] success. ", result.getClass()));
|
||||
Log.d(TAG, String.format("new impl [ %s ] success, object is [ %s ]. ", result.getClass(), result.toString()));
|
||||
return (T) result;
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
Log.d(TAG, String.format("new impl [ %s ] fail, reason is %s. ", result.getClass(), e.getMessage()));
|
||||
} catch (InstantiationException e) {
|
||||
e.printStackTrace();
|
||||
Log.d(TAG, String.format("new impl [ %s ] fail, reason is %s . ", result.getClass(), e.getMessage()));
|
||||
}
|
||||
}
|
||||
if (result == null || result instanceof Class) {
|
||||
Log.d(TAG, String.format("get sdk[ %s ] fail. ", sdkKey));
|
||||
} else {
|
||||
Log.d(TAG, String.format("get sdk[ %s ] success. ", result.getClass()));
|
||||
Log.d(TAG, String.format("get sdk[ %s ] success, impl's object is [ %s ] ", sdkKey, result.toString()));
|
||||
return (T) result;
|
||||
}
|
||||
}
|
||||
Log.d(TAG, String.format("get sdk[ %s ] fail, no component has it.", sdkKey));
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
package com.effective.android.module;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Example local unit test, which will execute on the development machine (host).
|
||||
*
|
||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||
*/
|
||||
public class ExampleUnitTest {
|
||||
@Test
|
||||
public void addition_isCorrect() {
|
||||
assertEquals(4, 2 + 2);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
apply plugin: 'groovy'
|
||||
apply plugin: 'maven'
|
||||
apply plugin: 'com.novoda.bintray-release'
|
||||
//apply plugin: 'com.novoda.bintray-release'
|
||||
|
||||
group = 'com.effective.plugins'
|
||||
archivesBaseName = 'component'
|
||||
@@ -43,13 +43,13 @@ repositories {
|
||||
}
|
||||
|
||||
|
||||
publish {
|
||||
userOrg = 'yummylau'
|
||||
groupId = 'com.effective.plugins'
|
||||
artifactId = 'component'
|
||||
publishVersion = '0.0.1'
|
||||
desc = 'Android component plugin'
|
||||
website = 'https://github.com/YummyLau/ComponentPlugin'
|
||||
}
|
||||
//publish {
|
||||
// userOrg = 'yummylau'
|
||||
// groupId = 'com.effective.plugins'
|
||||
// artifactId = 'component'
|
||||
// publishVersion = '0.0.1'
|
||||
// desc = 'Android component plugin'
|
||||
// website = 'https://github.com/YummyLau/ComponentPlugin'
|
||||
//}
|
||||
|
||||
|
||||
|
||||
@@ -19,6 +19,8 @@ import com.plugin.component.utils.ProjectUtil
|
||||
import com.plugin.component.utils.PublicationUtil
|
||||
import org.gradle.api.Plugin
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.internal.impldep.aQute.bnd.build.Run
|
||||
import sun.rmi.runtime.Log
|
||||
|
||||
/**
|
||||
* ./gradlew --no-daemon ComponentPlugin -Dorg.gradle.debug=true
|
||||
@@ -48,11 +50,12 @@ class ComponentPlugin implements Plugin<Project> {
|
||||
|
||||
//解析 component
|
||||
//比如 A 声明 component(':library') 且 A是可运行的
|
||||
//则A需要导入 library 中 sdk 和 impl 模块,其中 sdk 为模块内可见 implementation,impl 为纯 impl,其依赖的 sdk 需要模块哇可见 api
|
||||
//则A需要导入 library 中 sdk 和 impl 模块,其中 sdk 为模块内可见 implementation,impl 为纯 impl,其依赖的 sdk 需要模块外见 api
|
||||
project.dependencies.metaClass.component { String value ->
|
||||
return PublicationUtil.parseComponent(projectInfo, value)
|
||||
}
|
||||
|
||||
|
||||
//独立模块内 依赖sdk为api,由于该模块可能被依赖,所以sdk需要模块外暴露
|
||||
List<PublicationOption> publications = PublicationManager.getInstance().getPublicationByProject(project)
|
||||
project.dependencies {
|
||||
@@ -238,7 +241,7 @@ class ComponentPlugin implements Plugin<Project> {
|
||||
if (it instanceof AppPlugin || it instanceof LibraryPlugin) {
|
||||
childProject.pluginManager.apply(Constants.PLUGIN_COMPONENT)
|
||||
childProject.dependencies {
|
||||
implementation Constants.CORE_DEPENDENCY
|
||||
// implementation Constants.CORE_DEPENDENCY
|
||||
}
|
||||
if (projectInfo.aloneEnable) {
|
||||
childProject.extensions.findByType(BaseExtension.class).registerTransform(new ScanCodeTransform(childProject))
|
||||
@@ -263,6 +266,35 @@ class ComponentPlugin implements Plugin<Project> {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
project.getGradle().projectsEvaluated {
|
||||
if (Runtimes.sCompileModuleName != null) {
|
||||
//获取编译入口模块
|
||||
ProjectInfo projectInfo = Runtimes.getProjectInfo(Runtimes.sCompileModuleName)
|
||||
List<String> dependenceComponents = projectInfo.dependenceComponents
|
||||
Set<String> hasAdded = new HashSet()
|
||||
hasAdded.add(Runtimes.sCompileModuleName)
|
||||
Project currentProject = projectInfo.project
|
||||
while (!dependenceComponents.isEmpty()) {
|
||||
String component = dependenceComponents.get(0)
|
||||
if (!hasAdded.contains(component)) {
|
||||
hasAdded.add(component)
|
||||
currentProject.dependencies {
|
||||
implementation projectInfo.project.project(':' + component)
|
||||
}
|
||||
ProjectInfo componentInfo = Runtimes.getProjectInfo(component)
|
||||
List<String> componentDependenceComponents = componentInfo.dependenceComponents
|
||||
for (String string : componentDependenceComponents) {
|
||||
if (!hasAdded.contains(string)) {
|
||||
dependenceComponents.add(string)
|
||||
}
|
||||
}
|
||||
currentProject = componentInfo.project
|
||||
}
|
||||
dependenceComponents.remove(0)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isValidPluginModule(Project project, Set<String> includeModules, Set<String> excludeModules, boolean includeModel) {
|
||||
|
||||
@@ -23,6 +23,7 @@ class Runtimes {
|
||||
//基本公用配信息
|
||||
public static String sAndroidJarPath
|
||||
public static String sMainModuleName
|
||||
public static String sCompileModuleName
|
||||
public static int sCompileSdkVersion
|
||||
public static CompileOption sCompileOption
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ class ProjectInfo {
|
||||
public boolean isAssemble = false //是否是asAssemble
|
||||
public boolean isDebug = false //是否是debug
|
||||
public String compileModuleName //入口模块名字
|
||||
public List<String> dependenceComponents = new ArrayList<>() //使用 component 配置导入的模块
|
||||
|
||||
ProjectInfo(Project project) {
|
||||
this.project = project
|
||||
@@ -75,6 +76,7 @@ class ProjectInfo {
|
||||
compileModuleName = Constants.DEFAULT_MAIN_MODULE_NAME
|
||||
}
|
||||
}
|
||||
Runtimes.sCompileModuleName = compileModuleName
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.plugin.component.utils
|
||||
|
||||
import com.plugin.component.Constants
|
||||
import com.plugin.component.Runtimes
|
||||
import com.plugin.component.extension.module.BuildGradleInfo
|
||||
import com.plugin.component.extension.module.ProjectInfo
|
||||
import com.plugin.component.extension.module.SourceFile
|
||||
import com.plugin.component.extension.module.SourceSet
|
||||
@@ -16,7 +17,7 @@ class PublicationUtil {
|
||||
return publication.groupId + '-' + publication.artifactId
|
||||
}
|
||||
|
||||
static getPublicationId(String groupId,String artifactId) {
|
||||
static getPublicationId(String groupId, String artifactId) {
|
||||
return groupId + '-' + artifactId
|
||||
}
|
||||
|
||||
@@ -32,6 +33,7 @@ class PublicationUtil {
|
||||
return ':' + publication.groupId + '-' + publication.artifactId + ':'
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 解析 component 依赖
|
||||
* @param projectInfo
|
||||
@@ -42,14 +44,12 @@ class PublicationUtil {
|
||||
String key = ProjectUtil.getComponentValue(value)
|
||||
PublicationOption publication = Runtimes.getSdkPublication(key)
|
||||
if (publication != null) {
|
||||
if (projectInfo.aloneEnableAndNoSync()) {
|
||||
//解决多渠道依赖时缺失依赖project渠道信息的问题,0.1.1 版本
|
||||
// Map<String,Object> map = new HashMap<>()
|
||||
// map.put("path",value)
|
||||
// map.put("configuration",'default')
|
||||
// return projectInfo.project.getDependencies().project(map)
|
||||
//gradle版本升级解决
|
||||
return projectInfo.project.project(':' + value)
|
||||
if (projectInfo.isAssemble) {
|
||||
projectInfo.dependenceComponents.add(key)
|
||||
projectInfo.project.dependencies {
|
||||
api getPublication(publication)
|
||||
}
|
||||
return "com.netease.freecard:freeflow:1.1.1"
|
||||
} else {
|
||||
return getPublication(publication)
|
||||
}
|
||||
|
||||
@@ -26,11 +26,7 @@ android {
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||
|
||||
implementation 'androidx.appcompat:appcompat:1.0.2'
|
||||
testImplementation 'junit:junit:4.12'
|
||||
androidTestImplementation 'androidx.test:runner:1.2.0'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
|
||||
}
|
||||
//
|
||||
//publish {
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
package com.plugin.component.support;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.test.InstrumentationRegistry;
|
||||
import androidx.test.runner.AndroidJUnit4;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Instrumented test, which will execute on an Android device.
|
||||
*
|
||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||
*/
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class ExampleInstrumentedTest {
|
||||
@Test
|
||||
public void useAppContext() {
|
||||
// Context of the app under test.
|
||||
Context appContext = InstrumentationRegistry.getTargetContext();
|
||||
|
||||
assertEquals("com.plugin.component.support.test", appContext.getPackageName());
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package com.plugin.component.support;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Example local unit test, which will execute on the development machine (host).
|
||||
*
|
||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||
*/
|
||||
public class ExampleUnitTest {
|
||||
@Test
|
||||
public void addition_isCorrect() {
|
||||
assertEquals(4, 2 + 2);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
apply plugin: 'groovy'
|
||||
apply plugin: 'maven'
|
||||
apply plugin: 'com.novoda.bintray-release'
|
||||
//apply plugin: 'com.novoda.bintray-release'
|
||||
|
||||
group = 'com.effective.plugins'
|
||||
archivesBaseName = 'component-support'
|
||||
@@ -39,13 +39,13 @@ repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
publish {
|
||||
userOrg = 'yummylau'
|
||||
groupId = 'com.effective.plugins'
|
||||
artifactId = 'component-support'
|
||||
publishVersion = '0.0.1'
|
||||
desc = 'Android component support plugin'
|
||||
website = 'https://github.com/YummyLau/ComponentPlugin'
|
||||
}
|
||||
//publish {
|
||||
// userOrg = 'yummylau'
|
||||
// groupId = 'com.effective.plugins'
|
||||
// artifactId = 'component-support'
|
||||
// publishVersion = '0.0.1'
|
||||
// desc = 'Android component support plugin'
|
||||
// website = 'https://github.com/YummyLau/ComponentPlugin'
|
||||
//}
|
||||
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ class ComponentSupportPlugin implements Plugin<Project> {
|
||||
void addPluginToProject(Project project) {
|
||||
project.apply plugin: Constants.SUPPORT_PLUGIN
|
||||
project.dependencies {
|
||||
implementation Constants.SUPPORT_DEPENDENCY
|
||||
// implementation Constants.SUPPORT_DEPENDENCY
|
||||
}
|
||||
Logger.buildOutput("project[" + project.name + "]implementation " + Constants.SUPPORT_DEPENDENCY)
|
||||
Logger.buildOutput("project[" + project.name + "]apply plugin: " + Constants.SUPPORT_PLUGIN)
|
||||
|
||||
@@ -23,5 +23,4 @@ systemProp.http.proxyPort=8001
|
||||
systemProp.https.proxyHost=127.0.0.1
|
||||
systemProp.https.proxyPort=8001
|
||||
|
||||
mainmodulename=app
|
||||
|
||||
|
||||
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -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-5.1.1-all.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
|
||||
|
||||
@@ -16,21 +16,19 @@ android {
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
debug {
|
||||
}
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||
implementation 'androidx.appcompat:appcompat:1.0.2'
|
||||
testImplementation 'junit:junit:4.12'
|
||||
androidTestImplementation 'androidx.test:runner:1.2.0'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
|
||||
implementation component(':librarykotlin')
|
||||
implementation project(":component-core")
|
||||
implementation project(":component-support-core")
|
||||
implementation component(':libraryKotlin')
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -7,16 +7,9 @@ component {
|
||||
sdk {
|
||||
groupId 'com.effective.android'
|
||||
artifactId 'librarySdk'
|
||||
// version '1.0.0' // 初次配置时不设置,发布至maven时设置
|
||||
dependencies {
|
||||
// 只支持 compileOnly 和 implementation
|
||||
implementation 'com.google.code.gson:gson:2.8.1'
|
||||
}
|
||||
}
|
||||
|
||||
impl {
|
||||
groupId 'com.effective.android'
|
||||
artifactId 'libraryImpl'
|
||||
// version '1.0.0' // 初次配置时不设置,发布至maven时设置
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
package com.plugin.library;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.test.InstrumentationRegistry;
|
||||
import androidx.test.runner.AndroidJUnit4;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Instrumented test, which will execute on an Android device.
|
||||
*
|
||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||
*/
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class ExampleInstrumentedTest {
|
||||
@Test
|
||||
public void useAppContext() {
|
||||
// Context of the app under test.
|
||||
Context appContext = InstrumentationRegistry.getTargetContext();
|
||||
|
||||
assertEquals("com.plugin.library.test", appContext.getPackageName());
|
||||
}
|
||||
}
|
||||
@@ -5,10 +5,8 @@ import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import com.plugin.component.ComponentManager;
|
||||
import com.plugin.component.SdkManager;
|
||||
import com.plugin.librarykotlin.IKotlinSdk;
|
||||
|
||||
public class LibraryMainActivity extends AppCompatActivity {
|
||||
|
||||
@@ -17,6 +15,6 @@ public class LibraryMainActivity extends AppCompatActivity {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.main_activity_layout);
|
||||
ComponentManager.init(getApplication());
|
||||
((TextView) findViewById(R.id.text)).setText(SdkManager.getSdk(IKotlinSdk.class).getKotlinSdkName());
|
||||
((TextView) findViewById(R.id.text)).setText(SdkManager.getSdk(IProvideFromLibrary.class).provideString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
|
||||
@@ -3,16 +3,22 @@ package com.plugin.library;
|
||||
import android.app.Application;
|
||||
import android.util.Log;
|
||||
|
||||
import com.plugin.component.ComponentManager;
|
||||
import com.plugin.component.SdkManager;
|
||||
import com.plugin.component.anno.AutoInjectComponent;
|
||||
import com.plugin.component.IComponent;
|
||||
import com.plugin.librarykotlin.IProvideFromKotlin;
|
||||
|
||||
|
||||
@AutoInjectComponent(impl = {SdkImpl.class, SdkImpl2.class})
|
||||
@AutoInjectComponent(impl = {SdkShareImpl.class, ProvideFromLibraryImpl.class})
|
||||
public class Component implements IComponent {
|
||||
|
||||
public static IProvideFromKotlin sdk;
|
||||
|
||||
@Override
|
||||
public void attachComponent(Application application) {
|
||||
Log.d("component-plugin", "Component#attachComponent");
|
||||
ComponentManager.init(application);
|
||||
sdk = SdkManager.getSdk(IProvideFromKotlin.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.plugin.library;
|
||||
|
||||
import com.plugin.component.anno.AutoInjectImpl;
|
||||
|
||||
@AutoInjectImpl(sdk = {IProvideFromLibrary.class})
|
||||
public class ProvideFromLibraryImpl implements IProvideFromLibrary {
|
||||
|
||||
@Override
|
||||
public String provideString() {
|
||||
return Component.sdk.provideString() + "\n" + "[I'am library] add by library";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package com.plugin.library;
|
||||
|
||||
import com.plugin.component.anno.AutoInjectImpl;
|
||||
|
||||
@AutoInjectImpl(sdk = ISdk.class)
|
||||
public class SdkImpl implements ISdk {
|
||||
|
||||
@Override
|
||||
public String getSdkName() {
|
||||
return "from sdk";
|
||||
}
|
||||
}
|
||||
@@ -2,15 +2,17 @@ package com.plugin.library;
|
||||
|
||||
import com.plugin.component.anno.AutoInjectImpl;
|
||||
|
||||
@AutoInjectImpl(sdk = {ISdk2.class, ISdk3.class})
|
||||
public class SdkImpl2 implements ISdk2, ISdk3 {
|
||||
@AutoInjectImpl(sdk = {ISdk.class, ISdk2.class})
|
||||
public class SdkShareImpl implements ISdk, ISdk2 {
|
||||
|
||||
@Override
|
||||
public String getSdkName() {
|
||||
return "from sdk";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSdk2Name() {
|
||||
return "from sdk2";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSdk3Name() {
|
||||
return "from sdk3";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.plugin.library;
|
||||
|
||||
public interface IProvideFromLibrary {
|
||||
|
||||
String provideString();
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
package com.plugin.library;
|
||||
|
||||
public interface ISdk3 {
|
||||
String getSdk3Name();
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package com.plugin.library;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Example local unit test, which will execute on the development machine (host).
|
||||
*
|
||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||
*/
|
||||
public class ExampleUnitTest {
|
||||
@Test
|
||||
public void addition_isCorrect() {
|
||||
assertEquals(4, 2 + 2);
|
||||
}
|
||||
}
|
||||
34
libraryKotlin/build.gradle
Normal file
34
libraryKotlin/build.gradle
Normal file
@@ -0,0 +1,34 @@
|
||||
apply plugin: 'com.android.library'
|
||||
apply plugin: 'kotlin-android'
|
||||
apply plugin: 'kotlin-android-extensions'
|
||||
|
||||
android {
|
||||
compileSdkVersion 29
|
||||
buildToolsVersion "29.0.1"
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion 19
|
||||
targetSdkVersion 29
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
debug {
|
||||
}
|
||||
release {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||
implementation 'androidx.appcompat:appcompat:1.0.2'
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
||||
implementation project(":component-core")
|
||||
implementation project(":component-support-core")
|
||||
implementation component(':libraryKotlin2')
|
||||
}
|
||||
@@ -7,17 +7,11 @@ component {
|
||||
sdk {
|
||||
groupId 'com.effective.android'
|
||||
artifactId 'libraryKotlinSdk'
|
||||
// version '1.0.0' // 初次配置时不设置,发布至maven时设置
|
||||
|
||||
dependencies {
|
||||
// 只支持 compileOnly 和 implementation
|
||||
implementation 'com.google.code.gson:gson:2.8.1'
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
||||
}
|
||||
}
|
||||
|
||||
impl {
|
||||
groupId 'com.effective.android'
|
||||
artifactId 'libraryKotlinImpl'
|
||||
// version '1.0.0' // 初次配置时不设置,发布至maven时设置
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,11 @@
|
||||
package com.plugin.librarykotlin
|
||||
|
||||
import android.os.Bundle
|
||||
import android.widget.TextView
|
||||
import android.widget.Toast
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.plugin.component.ComponentManager
|
||||
import com.plugin.component.SdkManager
|
||||
import com.plugin.library.ISdk
|
||||
|
||||
import com.plugin.librarykotlin.R
|
||||
|
||||
class LibraryKotlinMainActivity : AppCompatActivity() {
|
||||
|
||||
@@ -15,6 +13,6 @@ class LibraryKotlinMainActivity : AppCompatActivity() {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.main_activity_layout)
|
||||
ComponentManager.init(application)
|
||||
Toast.makeText(this, SdkManager.getSdk(ISdk::class.java)!!.sdkName, Toast.LENGTH_LONG).show()
|
||||
(findViewById<TextView>(R.id.text)).text = SdkManager.getSdk(IProvideFromKotlin::class.java)!!.provideString()
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,12 @@
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@android:color/black"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
</LinearLayout>
|
||||
@@ -2,16 +2,25 @@ package com.plugin.librarykotlin
|
||||
|
||||
import android.app.Application
|
||||
import android.util.Log
|
||||
import com.plugin.component.ComponentManager
|
||||
|
||||
import com.plugin.component.IComponent
|
||||
import com.plugin.component.SdkManager
|
||||
import com.plugin.component.anno.AutoInjectComponent
|
||||
import com.plugin.librarykotlin2.IProvideFromLibraryKotlin2
|
||||
|
||||
|
||||
@AutoInjectComponent(impl = [KotlinSdkImpl::class])
|
||||
@AutoInjectComponent(impl = [ProvideFromKotlinImpl::class])
|
||||
class KotlinComponent : IComponent {
|
||||
|
||||
companion object {
|
||||
lateinit var sdk : IProvideFromLibraryKotlin2
|
||||
}
|
||||
|
||||
override fun attachComponent(application: Application) {
|
||||
Log.d("component-plugin", "KotlinComponent#attachComponent")
|
||||
ComponentManager.init(application)
|
||||
sdk = SdkManager.getSdk(IProvideFromLibraryKotlin2::class.java)!!
|
||||
}
|
||||
|
||||
override fun detachComponent() {
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.plugin.librarykotlin
|
||||
|
||||
import com.plugin.component.anno.AutoInjectImpl
|
||||
|
||||
@AutoInjectImpl(sdk = [IProvideFromKotlin::class])
|
||||
class ProvideFromKotlinImpl : IProvideFromKotlin {
|
||||
|
||||
override fun provideString(): String = KotlinComponent.sdk.provideString() + "\n" + "[I'am libraryKotlin] add by libraryKotlin"
|
||||
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.plugin.librarykotlin
|
||||
|
||||
interface IProvideFromKotlin {
|
||||
|
||||
fun provideString(): String
|
||||
}
|
||||
34
libraryKotlin2/build.gradle
Normal file
34
libraryKotlin2/build.gradle
Normal file
@@ -0,0 +1,34 @@
|
||||
apply plugin: 'com.android.library'
|
||||
apply plugin: 'kotlin-android'
|
||||
apply plugin: 'kotlin-android-extensions'
|
||||
|
||||
android {
|
||||
compileSdkVersion 29
|
||||
buildToolsVersion "29.0.1"
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion 19
|
||||
targetSdkVersion 29
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
debug {
|
||||
}
|
||||
release {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||
implementation 'androidx.appcompat:appcompat:1.0.2'
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
||||
implementation project(":component-core")
|
||||
implementation project(":component-support-core")
|
||||
implementation component(':library')
|
||||
}
|
||||
17
libraryKotlin2/component.gradle
Normal file
17
libraryKotlin2/component.gradle
Normal file
@@ -0,0 +1,17 @@
|
||||
component {
|
||||
|
||||
debug {
|
||||
applicationName 'com.plugin.libraryKolin2.LibraryKotlinApplication'
|
||||
}
|
||||
|
||||
sdk {
|
||||
groupId 'com.effective.android'
|
||||
artifactId 'libraryKotlinSdk2'
|
||||
|
||||
dependencies {
|
||||
// 只支持 compileOnly 和 implementation
|
||||
implementation 'com.google.code.gson:gson:2.8.1'
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
||||
}
|
||||
}
|
||||
}
|
||||
0
libraryKotlin2/consumer-rules.pro
Normal file
0
libraryKotlin2/consumer-rules.pro
Normal file
2
libraryKotlin2/src/main/AndroidManifest.xml
Normal file
2
libraryKotlin2/src/main/AndroidManifest.xml
Normal file
@@ -0,0 +1,2 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.plugin.librarykotlin2" />
|
||||
21
libraryKotlin2/src/main/debug/AndroidManifest.xml
Normal file
21
libraryKotlin2/src/main/debug/AndroidManifest.xml
Normal file
@@ -0,0 +1,21 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.plugin.librarykotlin2">
|
||||
|
||||
<application
|
||||
android:name=".LibraryKotlinApplication"
|
||||
android:allowBackup="true"
|
||||
android:label="@string/app_name"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/Theme.AppCompat.Light">
|
||||
<activity android:name=".LibraryKotlinMainActivity">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.plugin.librarykotlin2
|
||||
|
||||
import android.app.Application
|
||||
|
||||
|
||||
class LibraryKotlinApplication : Application()
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.plugin.librarykotlin2
|
||||
|
||||
import android.os.Bundle
|
||||
import android.widget.TextView
|
||||
import android.widget.Toast
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.plugin.component.ComponentManager
|
||||
import com.plugin.component.SdkManager
|
||||
|
||||
//import com.plugin.library.ISdk
|
||||
|
||||
class LibraryKotlinMainActivity : AppCompatActivity() {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.main_activity_layout)
|
||||
ComponentManager.init(application)
|
||||
(findViewById<TextView>(R.id.text)).text = SdkManager.getSdk(IProvideFromLibraryKotlin2::class.java)!!.provideString()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
</LinearLayout>
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.plugin.librarykotlin2
|
||||
|
||||
import android.app.Application
|
||||
import android.util.Log
|
||||
import com.plugin.component.ComponentManager
|
||||
|
||||
import com.plugin.component.IComponent
|
||||
import com.plugin.component.SdkManager
|
||||
import com.plugin.component.anno.AutoInjectComponent
|
||||
import com.plugin.library.ISdk
|
||||
|
||||
|
||||
@AutoInjectComponent(impl = [ProvideFromLibraryKotlin2Impl::class])
|
||||
class Kotlin2Component : IComponent {
|
||||
|
||||
companion object {
|
||||
lateinit var sdk: ISdk
|
||||
}
|
||||
|
||||
override fun attachComponent(application: Application) {
|
||||
Log.d("component-plugin", "KotlinComponent#attachComponent")
|
||||
ComponentManager.init(application)
|
||||
sdk = SdkManager.getSdk(ISdk::class.java)!!
|
||||
}
|
||||
|
||||
override fun detachComponent() {
|
||||
Log.d("component-plugin", "KotlinComponent#detachComponent")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.plugin.librarykotlin2
|
||||
|
||||
import com.plugin.component.anno.AutoInjectImpl
|
||||
|
||||
@AutoInjectImpl(sdk = [IProvideFromLibraryKotlin2::class])
|
||||
class ProvideFromLibraryKotlin2Impl : IProvideFromLibraryKotlin2 {
|
||||
|
||||
// override fun provideString(): String = "[I'am libraryKotlin2] add by libraryKotlin2"
|
||||
|
||||
override fun provideString(): String = "[I'am libraryKotlin2,breaking loop component,'" +
|
||||
Kotlin2Component.sdk.sdkName + "' from library " +
|
||||
"] add by libraryKotlin2"
|
||||
//
|
||||
// override fun provideString(): String = "[I'am libraryKotlin2" +
|
||||
// "] add by libraryKotlin2"
|
||||
}
|
||||
3
libraryKotlin2/src/main/res/values/strings.xml
Normal file
3
libraryKotlin2/src/main/res/values/strings.xml
Normal file
@@ -0,0 +1,3 @@
|
||||
<resources>
|
||||
<string name="app_name">libraryKotlin2</string>
|
||||
</resources>
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.plugin.librarykotlin2
|
||||
|
||||
interface IProvideFromLibraryKotlin2 {
|
||||
|
||||
fun provideString(): String
|
||||
}
|
||||
1
libraryWithoutPlugin/.gitignore
vendored
Normal file
1
libraryWithoutPlugin/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/build
|
||||
@@ -10,25 +10,18 @@ android {
|
||||
targetSdkVersion 29
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
debug {
|
||||
}
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||
|
||||
implementation 'androidx.appcompat:appcompat:1.0.2'
|
||||
testImplementation 'junit:junit:4.12'
|
||||
androidTestImplementation 'androidx.test:runner:1.2.0'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
|
||||
}
|
||||
21
libraryWithoutPlugin/proguard-rules.pro
vendored
Normal file
21
libraryWithoutPlugin/proguard-rules.pro
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
||||
2
libraryWithoutPlugin/src/main/debug/AndroidManifest.xml
Normal file
2
libraryWithoutPlugin/src/main/debug/AndroidManifest.xml
Normal file
@@ -0,0 +1,2 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.plugin.librarywithoutplugin" />
|
||||
1
libraryWithoutSdk/.gitignore
vendored
Normal file
1
libraryWithoutSdk/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/build
|
||||
@@ -1,20 +1,19 @@
|
||||
apply plugin: 'com.android.library'
|
||||
apply plugin: 'kotlin-android'
|
||||
apply plugin: 'kotlin-android-extensions'
|
||||
|
||||
android {
|
||||
compileSdkVersion 29
|
||||
compileSdkVersion 'android-P'
|
||||
buildToolsVersion "29.0.1"
|
||||
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion 19
|
||||
targetSdkVersion 29
|
||||
minSdkVersion 'P'
|
||||
targetSdkVersion 'P'
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
|
||||
consumerProguardFiles 'consumer-rules.pro'
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
@@ -28,14 +27,10 @@ android {
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||
|
||||
implementation 'androidx.appcompat:appcompat:1.0.2'
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
||||
implementation 'androidx.appcompat:appcompat:1.1.0'
|
||||
implementation 'androidx.core:core-ktx:1.1.0'
|
||||
testImplementation 'junit:junit:4.12'
|
||||
androidTestImplementation 'androidx.test:runner:1.2.0'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
||||
implementation component(':library')
|
||||
}
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
0
libraryWithoutSdk/consumer-rules.pro
Normal file
0
libraryWithoutSdk/consumer-rules.pro
Normal file
21
libraryWithoutSdk/proguard-rules.pro
vendored
Normal file
21
libraryWithoutSdk/proguard-rules.pro
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.plugin.librarywithoutsdk
|
||||
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
|
||||
import org.junit.Assert.*
|
||||
|
||||
/**
|
||||
* Instrumented test, which will execute on an Android device.
|
||||
*
|
||||
* See [testing documentation](http://d.android.com/tools/testing).
|
||||
*/
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
class ExampleInstrumentedTest {
|
||||
@Test
|
||||
fun useAppContext() {
|
||||
// Context of the app under test.
|
||||
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
|
||||
assertEquals("com.plugin.librarywithoutsdk.test", appContext.packageName)
|
||||
}
|
||||
}
|
||||
2
libraryWithoutSdk/src/main/AndroidManifest.xml
Normal file
2
libraryWithoutSdk/src/main/AndroidManifest.xml
Normal file
@@ -0,0 +1,2 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.plugin.librarywithoutsdk" />
|
||||
3
libraryWithoutSdk/src/main/res/values/strings.xml
Normal file
3
libraryWithoutSdk/src/main/res/values/strings.xml
Normal file
@@ -0,0 +1,3 @@
|
||||
<resources>
|
||||
<string name="app_name">librarywithoutsdk</string>
|
||||
</resources>
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.plugin.librarywithoutsdk
|
||||
|
||||
import org.junit.Test
|
||||
|
||||
import org.junit.Assert.*
|
||||
|
||||
/**
|
||||
* Example local unit test, which will execute on the development machine (host).
|
||||
*
|
||||
* See [testing documentation](http://d.android.com/tools/testing).
|
||||
*/
|
||||
class ExampleUnitTest {
|
||||
@Test
|
||||
fun addition_isCorrect() {
|
||||
assertEquals(4, 2 + 2)
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package com.plugin.librarykotlin;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.test.InstrumentationRegistry;
|
||||
import androidx.test.runner.AndroidJUnit4;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Instrumented test, which will execute on an Android device.
|
||||
*
|
||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||
*/
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class ExampleInstrumentedTest {
|
||||
@Test
|
||||
public void useAppContext() {
|
||||
// Context of the app under test.
|
||||
Context appContext = InstrumentationRegistry.getTargetContext();
|
||||
|
||||
assertEquals("com.plugin.librarykotlin.test", appContext.getPackageName());
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
package com.plugin.librarykotlin
|
||||
|
||||
import com.plugin.component.anno.AutoInjectImpl
|
||||
|
||||
@AutoInjectImpl(sdk = [IKotlinSdk::class])
|
||||
class KotlinSdkImpl : IKotlinSdk {
|
||||
|
||||
override fun getKotlinSdkName(): String = "KotlinSdkImpl"
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
package com.plugin.librarykotlin
|
||||
|
||||
interface IKotlinSdk {
|
||||
fun getKotlinSdkName(): String
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package com.plugin.librarykotlin;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Example local unit test, which will execute on the development machine (host).
|
||||
*
|
||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||
*/
|
||||
public class ExampleUnitTest {
|
||||
@Test
|
||||
public void addition_isCorrect() {
|
||||
assertEquals(4, 2 + 2);
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package com.plugin.librarywithoutplugin;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.test.InstrumentationRegistry;
|
||||
import androidx.test.runner.AndroidJUnit4;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Instrumented test, which will execute on an Android device.
|
||||
*
|
||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||
*/
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class ExampleInstrumentedTest {
|
||||
@Test
|
||||
public void useAppContext() {
|
||||
// Context of the app under test.
|
||||
Context appContext = InstrumentationRegistry.getTargetContext();
|
||||
|
||||
assertEquals("com.plugin.librarywithoutplugin.test", appContext.getPackageName());
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package com.plugin.librarywithoutplugin;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Example local unit test, which will execute on the development machine (host).
|
||||
*
|
||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||
*/
|
||||
public class ExampleUnitTest {
|
||||
@Test
|
||||
public void addition_isCorrect() {
|
||||
assertEquals(4, 2 + 2);
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -1 +0,0 @@
|
||||
323c566d519066b2f9f1d0fb3e462bed
|
||||
@@ -1 +0,0 @@
|
||||
10c250036ef4dc74ad69b49f88ff46249fab2810
|
||||
@@ -1,40 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.effective.plugins</groupId>
|
||||
<artifactId>component-support</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.android.tools.build</groupId>
|
||||
<artifactId>gradle</artifactId>
|
||||
<version>3.3.0</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.ow2.asm</groupId>
|
||||
<artifactId>asm</artifactId>
|
||||
<version>7.1</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.ow2.asm</groupId>
|
||||
<artifactId>asm-commons</artifactId>
|
||||
<version>7.1</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.ow2.asm</groupId>
|
||||
<artifactId>asm-util</artifactId>
|
||||
<version>7.1</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.quinn.hunter</groupId>
|
||||
<artifactId>hunter-transform</artifactId>
|
||||
<version>0.9.3</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -1 +0,0 @@
|
||||
57b91efb6b444a30449c7547de22be63
|
||||
@@ -1 +0,0 @@
|
||||
379fe41af554964b6d8e9ba88969eaac09cef512
|
||||
@@ -1,12 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<metadata>
|
||||
<groupId>com.effective.plugins</groupId>
|
||||
<artifactId>component-support</artifactId>
|
||||
<versioning>
|
||||
<release>1.0.0</release>
|
||||
<versions>
|
||||
<version>1.0.0</version>
|
||||
</versions>
|
||||
<lastUpdated>20190903114514</lastUpdated>
|
||||
</versioning>
|
||||
</metadata>
|
||||
@@ -1 +0,0 @@
|
||||
f7e382b40aa6e33ae3b494538c04ef82
|
||||
@@ -1 +0,0 @@
|
||||
1b73a1d422ca4682fbd822e39e02274c20ceeac5
|
||||
Binary file not shown.
@@ -1 +0,0 @@
|
||||
211471bd90527e683120e0caaffc2220
|
||||
@@ -1 +0,0 @@
|
||||
df0119bc232fc236ec3a7ddf35d430218f18501a
|
||||
@@ -1,46 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.effective.plugins</groupId>
|
||||
<artifactId>component</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.android.tools.build</groupId>
|
||||
<artifactId>gradle</artifactId>
|
||||
<version>3.3.0</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-compiler-embeddable</artifactId>
|
||||
<version>1.3.50</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.ow2.asm</groupId>
|
||||
<artifactId>asm</artifactId>
|
||||
<version>7.1</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.ow2.asm</groupId>
|
||||
<artifactId>asm-commons</artifactId>
|
||||
<version>7.1</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.ow2.asm</groupId>
|
||||
<artifactId>asm-util</artifactId>
|
||||
<version>7.1</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.quinn.hunter</groupId>
|
||||
<artifactId>hunter-transform</artifactId>
|
||||
<version>0.9.3</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -1 +0,0 @@
|
||||
4b26ab196bb3266b15c80ab5f607edd6
|
||||
@@ -1 +0,0 @@
|
||||
c816db5ff2a5f044901775be109cea6fa3ab89cc
|
||||
@@ -1,12 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<metadata>
|
||||
<groupId>com.effective.plugins</groupId>
|
||||
<artifactId>component</artifactId>
|
||||
<versioning>
|
||||
<release>1.0.0</release>
|
||||
<versions>
|
||||
<version>1.0.0</version>
|
||||
</versions>
|
||||
<lastUpdated>20190903114831</lastUpdated>
|
||||
</versioning>
|
||||
</metadata>
|
||||
@@ -1 +0,0 @@
|
||||
b121a699fd41c7385cf047cbc3b04228
|
||||
@@ -1 +0,0 @@
|
||||
3480b734c0ef4625e62cf0e7a678a457e3e039b4
|
||||
@@ -1,13 +1,14 @@
|
||||
include ':app', ':library', ':librarykotlin', ':librarywithoutplugin'
|
||||
include ':app'
|
||||
include ':library', ':libraryKotlin', ':libraryWithoutPlugin', ':libraryWithoutSdk', ':libraryKotlin2'
|
||||
|
||||
//发布调试 core
|
||||
//include ':component-core'
|
||||
//include ':component-support-core'
|
||||
include ':component-core'
|
||||
include ':component-support-core'
|
||||
|
||||
//发布插件
|
||||
include ':component-plugin'
|
||||
include ':component-support-plugin'
|
||||
//include ':component-plugin'
|
||||
//include ':component-support-plugin'
|
||||
|
||||
//调试插件
|
||||
//includeBuild './component-plugin'
|
||||
//includeBuild './component-support-plugin'
|
||||
includeBuild './component-plugin'
|
||||
includeBuild './component-support-plugin'
|
||||
|
||||
Reference in New Issue
Block a user