Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

实现组件对内对外的代码都放在组件内部,对外的改后缀名为.api,编译之前自动copy&rename为.java文件 #75

Open
wants to merge 58 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 57 commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
5c00f77
Update README.md
mqzhangw Nov 21, 2017
a68ded1
Merge remote-tracking branch 'origin/master' into anno
Dec 13, 2017
8dd3e8b
UI router by Uri
Dec 14, 2017
3d5385d
auto fen uirouter
Dec 19, 2017
2679edb
add BaseCompRouter
Dec 19, 2017
4466249
remove host in routenode
Dec 20, 2017
b86a2de
auto generate HostUIRoutertable.txt
Dec 20, 2017
7e72c51
upload to jenter
Dec 20, 2017
ca3cb1a
add throw function to data delivering;
leobert-lan Dec 21, 2017
6380b6a
update to 1.0.0
Dec 21, 2017
6233581
update READE
Dec 22, 2017
4ad4389
update READE
Dec 22, 2017
12df535
Update LICENSE
mqzhangw Dec 22, 2017
58348a9
Update README.md
mqzhangw Dec 22, 2017
0472880
Update README.md
mqzhangw Dec 22, 2017
2f4ab31
Update README.md
mqzhangw Dec 22, 2017
cd89627
Update README.md
mqzhangw Dec 25, 2017
b00b874
Update README.md
mqzhangw Dec 26, 2017
361cd52
Update README.md
mqzhangw Dec 26, 2017
3d9cda3
Update README.md
mqzhangw Dec 27, 2017
2815fe5
update proguard-rules.pro
Dec 27, 2017
c4fa36f
Merge branch 'master' of https://github.com/luojilab/DDComponentForAn…
Dec 27, 2017
8f97d98
Update README.md
mqzhangw Dec 28, 2017
a9a825a
add kotlin demo
Jan 3, 2018
f9f42fe
update kotlin demo
Jan 3, 2018
d7dd0c7
Update README.md
mqzhangw Jan 3, 2018
ec8065f
use UTF-8
Jan 4, 2018
03bc239
Merge branch 'master' of https://github.com/luojilab/DDComponentForAn…
Jan 4, 2018
2129861
add application in componentkotlin
Jan 5, 2018
4ebfa03
Update README.md
mqzhangw Jan 6, 2018
9c1c2ff
Update README.md
mqzhangw Jan 8, 2018
0c84f22
add a working-flow guide for re-architecting with DDComponent
leobert-lan Jan 9, 2018
02d0dc0
fix misspell
Jan 12, 2018
b31110e
1、替换maven之类的上传脚本为本地文件
Jan 15, 2018
74024d1
1、替换maven之类的上传脚本为本地文件
ouyangpeng Jan 15, 2018
818ff7f
1、实现使用Native方式来跳转 activity
Jan 15, 2018
dc31605
1、实现使用Native方式来跳转 activity
ouyangpeng Jan 15, 2018
e2e3f55
1、重命名相关的方法
Jan 15, 2018
7bc0b6c
1、重命名相关的方法
ouyangpeng Jan 15, 2018
91238b9
1、删除gradle文件中部分冗余的语法
ouyangpeng Jan 16, 2018
bec939f
1、删除gradle文件中部分冗余的语法
ouyangpeng Jan 16, 2018
8d38914
Merge branch 'master' of https://github.com/ouyangpeng/DDComponentFor…
ouyangpeng Jan 16, 2018
7432b97
1、Merge remote-tracking branch 'upstream/master'
ouyangpeng Jan 16, 2018
69915b7
1、Merge remote-tracking branch 'upstream/master'
ouyangpeng Jan 16, 2018
e31d7e7
1、更新两个文件的字符编码
ouyangpeng Jan 16, 2018
55999a8
1、移除冗余代码
ouyangpeng Jan 16, 2018
e32f6cb
1、初步实现 copy所有项目中的 .api文件 到 ApiComponentService 中,然后改名为 .java
ouyangpeng Jan 17, 2018
6858918
1、更新from脚本为自动扫描project
ouyangpeng Jan 17, 2018
887f441
1、先将 要copy的 gradle脚本 应用到每个组件中去,这样的缺点是:会重复多次扫描复制操作
ouyangpeng Jan 18, 2018
ddad6d5
1、因为每个组件都需要依赖于 ApiComponentService 工程,因此只需要在这里初始化 copy & rename 操作即可
ouyangpeng Jan 18, 2018
a9027a7
1、删除无用冗余代码
ouyangpeng Jan 18, 2018
c8e7583
1、Merge remote-tracking branch 'upstream/master'
ouyangpeng Jan 18, 2018
34056fa
1、将所有的对外暴露的接口和数据结构 都移动到 api目录
ouyangpeng Jan 18, 2018
c2d6747
1、copy的升级版本,可以通过判断是sync还是assemble打包来确定要编译的组件
ouyangpeng Jan 19, 2018
6e38642
1、优化冗余代码
ouyangpeng Jan 19, 2018
4e819a0
1、修改README.md
ouyangpeng Jan 19, 2018
f50e45c
1、readercomponent 组件单独运行,实现 onActivityResult 方法
ouyangpeng Jan 19, 2018
9a74821
解决编译出现Failed to delete ... classes.jar的bug
ouyangpeng Jun 13, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ApiComponentService/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
31 changes: 31 additions & 0 deletions ApiComponentService/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
apply plugin: 'com.android.library'
apply from: "${rootDir}/copy2.gradle"
android {
compileSdkVersion 26
buildToolsVersion "26.0.1"

defaultConfig {
minSdkVersion 15
targetSdkVersion 26
versionCode 1
versionName "1.0"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile project(':basicres')
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
testCompile 'junit:junit:4.12'
}
25 changes: 25 additions & 0 deletions ApiComponentService/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /Users/klee/Library/Android/sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# 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
5 changes: 5 additions & 0 deletions ApiComponentService/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.luojilab">
<application />
</manifest>
3 changes: 3 additions & 0 deletions ApiComponentService/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<resources>
<string name="app_name">componentservice</string>
</resources>
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/luojilab/DDComponentForAndroid/pulls)
[![License](https://img.shields.io/badge/License-Apache%202.0-orange.svg)](https://github.com/luojilab/DDComponentForAndroid/blob/master/LICENSE)

### 部分想法
在得到的DDComponent基础上,加上了部分的想法实现

+ 1、实现组件对内对外的代码都放在组件内部,对外的改后缀名为.api,编译之前自动copy&rename为.java文件。
- a. 可以通过判断是sync还是assemble打包来确定要编译的组件
- b. 如果是sync的话,则读取所有组件中的.api文件
- c. 如果是某个组件单独运行的话,则只扫描该组件所依赖的组件中的.api文件以及自己组件中的.api文件
+ 2、内部有具体的实现Native方式(不使用Annotation)来进行UI跳转,这部分可忽略。

### 最新版本

模块|build-gradle|componentlib|router-anno-compiler|router-annotation
Expand Down
4 changes: 2 additions & 2 deletions UIRouterTable/KotlinRouterTable.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ auto generated, do not change !!!!

HOST : kotlin

分享杂志页面
������־ҳ��
/shareMagazine
author:com.luojilab.componentservice.share.bean.Author
author:com.luojilab.api.share.bean.Author
bookName:String

4 changes: 2 additions & 2 deletions UIRouterTable/ShareRouterTable.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ auto generated, do not change !!!!

HOST : share

分享书籍页面
�����鼮ҳ��
/shareBook
author:com.luojilab.componentservice.share.bean.Author
author:com.luojilab.api.share.bean.Author
bookName:String

4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ android {
}

dependencies {
compile project(':componentservice')
// compile project(':componentservice')
compile project(':ApiComponentService')
annotationProcessor project(':router-anno-compiler')
}

combuild {
applicationName = 'com.luojilab.componentdemo.application.AppApplication'
isRegisterCompoAuto = true
}

13 changes: 8 additions & 5 deletions app/src/main/java/com/luojilab/componentdemo/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
import android.view.View;
import android.widget.Button;

import com.luojilab.api.reader.readerbook.ReadBookService;
import com.luojilab.component.basiclib.ToastManager;
import com.luojilab.component.basicres.BaseActivity;
import com.luojilab.component.basicres.BaseApplication;
import com.luojilab.component.componentlib.router.Router;
import com.luojilab.componentservice.readerbook.ReadBookService;
import com.luojilab.router.facade.annotation.RouteNode;

@RouteNode(path = "/main", desc = "首页")
Expand All @@ -28,8 +28,8 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

installReadBookBtn = findViewById(R.id.install_share);
uninstallReadBtn = findViewById(R.id.uninstall_share);
installReadBookBtn = (Button) findViewById(R.id.install_share);
uninstallReadBtn = (Button) findViewById(R.id.uninstall_share);
installReadBookBtn.setOnClickListener(this);
uninstallReadBtn.setOnClickListener(this);
showFragment();
Expand Down Expand Up @@ -69,8 +69,11 @@ public void onClick(View v) {
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (data != null) {
ToastManager.show(BaseApplication.getAppContext(), data.getStringExtra("result"));
//分享组件 的 RESULT_CODE
if (resultCode == 8888) {
if (data != null) {
ToastManager.show(BaseApplication.getAppContext(), data.getStringExtra("result"));
}
}
}
}
65 changes: 65 additions & 0 deletions bintrayv1.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
apply plugin: 'com.jfrog.bintray'

version = libraryVersion

if (project.hasProperty("android")) { // Android libraries
task sourcesJar(type: Jar) {
classifier = 'sources'
from android.sourceSets.main.java.srcDirs
}

task javadoc(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
}
} else { // Java libraries
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
}

task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}

artifacts {
archives javadocJar
archives sourcesJar
}

//指定编译的编码
tasks.withType(JavaCompile){
options.encoding = "UTF-8"
}


// Bintray
Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())

bintray {
user = properties.getProperty("bintray.user")
key = properties.getProperty("bintray.apikey")

configurations = ['archives']
pkg {
repo = bintrayRepo
name = bintrayName
desc = libraryDescription
websiteUrl = siteUrl
vcsUrl = gitUrl
licenses = allLicenses
publish = true
publicDownloadNumbers = true
version {
desc = libraryDescription
gpg {
sign = true //Determines whether to GPG sign the files. The default is false
passphrase = properties.getProperty("bintray.gpg.password")
//Optional. The passphrase for GPG signing'
}
}
}
}
6 changes: 4 additions & 2 deletions build-gradle/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ ext {
licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
allLicenses = ["Apache-2.0"]
}
apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/installv1.gradle'
apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/bintrayv1.gradle'
//apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/installv1.gradle'
//apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/bintrayv1.gradle'
apply from: '../installv1.gradle'
apply from: '../bintrayv1.gradle'

dependencies {
compile 'com.android.tools.build:gradle:2.3.2'
Expand Down
28 changes: 28 additions & 0 deletions build-gradle/src/main/groovy/com.dd.buildgradle/ComBuild.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,24 @@ package com.dd.buildgradle
import com.dd.buildgradle.exten.ComExtension
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.Task

class ComBuild implements Plugin<Project> {

//默认是app,直接运行assembleRelease的时候,等同于运行app:assembleRelease
String compilemodule = "app"

void apply(Project project) {
/**
* 每个Gradle的Project都维护了一个ExtenionContainer,
我们可以通过project.extentions访问额外的Property和定义额外的Property

弄好之后,在build.gradle中的配置如下面所示的格式
* combuild {
applicationName = 'com.luojilab.reader.runalone.application.ReaderApplication'
isRegisterCompoAuto = false
}
*/
project.extensions.create('combuild', ComExtension)

String taskNames = project.gradle.startParameter.taskNames.toString()
Expand Down Expand Up @@ -44,6 +55,7 @@ class ComBuild implements Plugin<Project> {

//根据配置添加各种组件依赖,并且自动化生成组件加载代码
if (isRunAlone) {
//应用plugin为 application
project.apply plugin: 'com.android.application'
if (!module.equals(mainmodulename)) {
project.android.sourceSets {
Expand All @@ -56,10 +68,12 @@ class ComBuild implements Plugin<Project> {
}
System.out.println("apply plugin is " + 'com.android.application')
if (assembleTask.isAssemble && module.equals(compilemodule)) {
//编译组件
compileComponents(assembleTask, project)
project.android.registerTransform(new ComCodeTransform(project))
}
} else {
//应用plugin为 library
project.apply plugin: 'com.android.library'
System.out.println("apply plugin is " + 'com.android.library')
}
Expand Down Expand Up @@ -92,6 +106,7 @@ class ComBuild implements Plugin<Project> {
private AssembleTask getTaskInfo(List<String> taskNames) {
AssembleTask assembleTask = new AssembleTask()
for (String task : taskNames) {
//ASSEMBLE打包 、 aR = assembleRelease 、RESGUARD混淆
if (task.toUpperCase().contains("ASSEMBLE")
|| task.contains("aR")
|| task.toUpperCase().contains("INSTALL")
Expand All @@ -101,6 +116,12 @@ class ComBuild implements Plugin<Project> {
}
assembleTask.isAssemble = true
String[] strs = task.split(":")
/**
* 根据当前的task,获取要运行的组件,规则如下:
* assembleRelease ---app
* app:assembleRelease :app:assembleRelease ---app
* sharecomponent:assembleRelease :sharecomponent:assembleRelease ---sharecomponent
*/
assembleTask.modules.add(strs.length > 1 ? strs[strs.length - 2] : "all")
break
}
Expand All @@ -115,6 +136,11 @@ class ComBuild implements Plugin<Project> {
* @param project
*/
private void compileComponents(AssembleTask assembleTask, Project project) {
/**
* 从配置文件中读取要依赖的组件名 配置文件格式如下:
debugComponent=readercomponent,sharecomponent,sharecomponentkotlin
compileComponent=readercomponent,sharecomponent,sharecomponentkotlin
*/
String components
if (assembleTask.isDebug) {
components = (String) project.properties.get("debugComponent")
Expand All @@ -126,6 +152,7 @@ class ComBuild implements Plugin<Project> {
System.out.println("there is no add dependencies ")
return
}
//通过 逗号分隔 转换为组件名数组
String[] compileComponents = components.split(",")
if (compileComponents == null || compileComponents.length == 0) {
System.out.println("there is no add dependencies ")
Expand All @@ -146,6 +173,7 @@ class ComBuild implements Plugin<Project> {
* 示例语法:module
* compileComponent=readercomponent,sharecomponent
*/
//如果为直接引用module工程
project.dependencies.add("compile", project.project(':' + str))
System.out.println("add dependencies project : " + str)
}
Expand Down
Loading