Skip to content

Commit

Permalink
支持flavor方式编译依赖
Browse files Browse the repository at this point in the history
  • Loading branch information
athol.yi committed Feb 24, 2023
1 parent f8edbdd commit 400514d
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 32 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ plugins {
}

ext {
version = "3.0.1"
version = "3.0.4"
groupId = 'com.codyer.ElegantBus'
minSdkVersion = 21
targetSdkVersion = 32
Expand Down
11 changes: 11 additions & 0 deletions config-aar.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,21 @@ afterEvaluate {
flavors.forEach { flavor ->
println("++++++++++ productFlavors : " + flavor.name)
"$flavor.name"(MavenPublication) {
// from components."${flavor.name}Release"
groupId = rootProject.ext.groupId
artifactId = project.getName() + "-$flavor.name"
artifact tasks.findByName("bundle${flavor.name.capitalize()}ReleaseAar")
version = rootProject.ext.version
pom.withXml {
def dependenciesNode = asNode().appendNode('dependencies')
// Iterate over the api dependencies (we don't want the test ones), adding a <dependency> node for each
configurations.api.allDependencies.each {
def dependencyNode = dependenciesNode.appendNode('dependency')
dependencyNode.appendNode('groupId', rootProject.ext.groupId)
dependencyNode.appendNode('artifactId', it.name)
dependencyNode.appendNode('version', rootProject.ext.version)
}
}
}
}
}
Expand Down
16 changes: 0 additions & 16 deletions ipc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,3 @@ android {
dependencies {
api project(':core')
}
/*
afterEvaluate {
publishing {
publications {
android.productFlavors.forEach {flavor ->
println("++++++++++ productFlavors : " + flavor.name)
"$flavor.name"(MavenPublication) {
groupId = rootProject.ext.groupId
artifactId = project.getName() + "-$flavor.name"
artifact tasks.findByName("bundle${flavor.name.capitalize()}ReleaseAar")
version = rootProject.ext.version
}
}
}
}
}*/
10 changes: 5 additions & 5 deletions ipc/src/aidl/java/cody/bus/ElegantBusService.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/*
* ************************************************************
* 文件:ElegantBusService.java 模块:ElegantBus.ipc.main 项目:ElegantBus
* 当前修改时间:2023年02月24日 17:46:20
* 上次修改时间:2023年01月05日 14:27:06
* 文件:ElegantBusService.java 模块:ElegantBus.ipc 项目:ElegantBus
* 当前修改时间:2023年02月24日 18:35:16
* 上次修改时间:2023年02月24日 17:51:45
* 作者:Cody.yi https://github.com/codyer
*
* 描述:ElegantBus.ipc.main
* 描述:ElegantBus.ipc
* Copyright (c) 2023
* ************************************************************
*/
Expand All @@ -28,7 +28,7 @@
* 跨进程事件总线支持服务
* aidl 实现
*/
public class ElegantBusService extends Service {
public class ElegantBusService extends BaseBusService {
private final RemoteCallbackList<IProcessCallback> mRemoteCallbackList = new RemoteCallbackList<>();
private final String mServiceProcessName;
private final Map<String, EventWrapper> mEventCache = new ConcurrentHashMap<>();
Expand Down
14 changes: 6 additions & 8 deletions ipc/src/binder/java/cody/bus/ElegantBusService.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
/*
* ************************************************************
* 文件:ElegantBusService.java 模块:ElegantBus.ipc 项目:ElegantBus
* 当前修改时间:2023年02月24日 17:46:20
* 上次修改时间:2023年01月05日 14:27:06
* 文件:ElegantBusService.java 模块:ElegantBus.ipc.main 项目:ElegantBus
* 当前修改时间:2023年02月24日 18:35:16
* 上次修改时间:2023年02月24日 18:35:12
* 作者:Cody.yi https://github.com/codyer
*
* 描述:ElegantBus.ipc
* 描述:ElegantBus.ipc.main
* Copyright (c) 2023
* ************************************************************
*/

package cody.bus;

import android.app.Service;
import android.content.Intent;
import android.os.Binder;
import android.os.IBinder;
Expand All @@ -25,10 +24,9 @@


/**
* 跨进程事件总线支持服务
* aidl 实现
* 跨进程事件总线支持服务 binder 实现
*/
public class ElegantBusService extends Service {
public class ElegantBusService extends BaseBusService {
private final RemoteCallbackList<IProcessCallback> mRemoteCallbackList = new RemoteCallbackList<>();
private final String mServiceProcessName;
private final Map<String, EventWrapper> mEventCache = new ConcurrentHashMap<>();
Expand Down
43 changes: 41 additions & 2 deletions ipc/src/main/java/cody/bus/BaseBusService.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
* ************************************************************
* 文件:BaseBusService.java 模块:ElegantBus.ipc.main 项目:ElegantBus
* 当前修改时间:2023年02月24日 17:46:20
* 上次修改时间:2023年02月24日 16:06:02
* 当前修改时间:2023年02月24日 18:35:16
* 上次修改时间:2023年02月24日 18:35:12
* 作者:Cody.yi https://github.com/codyer
*
* 描述:ElegantBus.ipc.main
Expand All @@ -12,12 +12,51 @@

package cody.bus;

import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.Service;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.os.Build;


/**
* 跨进程事件总线支持服务
*/
public abstract class BaseBusService extends Service {
private String getNotificationChannelId() {
return new ComponentName(this, BaseBusService.class).toShortString();
}

@Override
public void onCreate() {
super.onCreate();
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
NotificationManager notificationManager = getSystemService(NotificationManager.class);
notificationManager.createNotificationChannel(new NotificationChannel(
getNotificationChannelId(), getNotificationChannelId(),
NotificationManager.IMPORTANCE_DEFAULT));
Notification notification = new Notification
.Builder(getApplicationContext(), getNotificationChannelId())
.setContentTitle("BusService")
.setSmallIcon(android.R.drawable.ic_popup_sync)
.build();
startForeground(1, notification);
}
}

@Override
public void onDestroy() {
super.onDestroy();
}

public static void startUserService(Context context, Intent intent) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
context.startForegroundService(intent);
} else {
context.startService(intent);
}
}
}

0 comments on commit 400514d

Please sign in to comment.