From 9ce09cfd79d8ea00c58a182cfd5ec6eb8d54ee6b Mon Sep 17 00:00:00 2001
From: lwb <q3213421wrwqr>
Date: 星期一, 02 十一月 2020 15:46:43 +0800
Subject: [PATCH] 9527 使用gradle脚本在构建时去除主目录下与渠道重复的类
---
/dev/null | 17 ---
SdkProject/library/src/main/java/com/secondworld/universalsdk/command/CmdInit.java | 18 +++
SdkProject/settings.gradle | 1
SdkProject/library/src/main/java/com/secondworld/universalsdk/command/CmdAssetCopy.java | 14 ++
SdkProject/channel/test/config.properties | 2
SdkProject/library/build.gradle | 80 +++++++++++++++
SdkProject/library/src/main/java/com/secondworld/universalsdk/CodeU2A.java | 60 ++++++++++++
SdkProject/library/src/main/java/com/secondworld/universalsdk/CodeA2U.java | 40 ++++++++
SdkProject/library/src/main/java/com/secondworld/universalsdk/H2EngineSDK.java | 32 ++++++
SdkProject/utils.gradle | 22 ++++
SdkProject/library/src/main/java/com/secondworld/universalsdk/command/ICommand.java | 12 ++
11 files changed, 276 insertions(+), 22 deletions(-)
diff --git a/SdkProject/channel/test/config.properties b/SdkProject/channel/test/config.properties
index dae5e3b..22ff451 100644
--- a/SdkProject/channel/test/config.properties
+++ b/SdkProject/channel/test/config.properties
@@ -1 +1 @@
-PLUGINS=jpush;bugly
\ No newline at end of file
+PLUGINS=
\ No newline at end of file
diff --git a/SdkProject/library/build.gradle b/SdkProject/library/build.gradle
index 9eefdaf..dc4132e 100644
--- a/SdkProject/library/build.gradle
+++ b/SdkProject/library/build.gradle
@@ -1,6 +1,30 @@
plugins {
id 'com.android.library'
}
+def rootPath = rootProject.getRootDir().getAbsolutePath()
+def channelPath = "${rootPath}/channel/${CHANNEL_NAME}"
+
+def applyGradle(String path) {
+ path = "${path}.gradle"
+ File file = file(path)
+ if (file.exists())
+ apply from: path
+}
+
+applyGradle("${rootPath}/utils")
+applyGradle("${channelPath}/build")
+
+Properties localProp = loadProperties('local')
+Properties channelProp = loadProperties("${channelPath}/config")
+
+def plugins = channelProp.getProperty("PLUGINS").split(';')
+
+plugins.each {
+ applyGradle("${rootPath}/plugins/${it}/build")
+}
+
+//娓犻亾闇�瑕佽鐩栦富鐩綍鐨刯ava鏂囦欢
+def channelJavaFiles = getAllFiles(new ArrayList<File>(), "${channelPath}/java")
android {
compileSdkVersion 29
@@ -16,6 +40,13 @@
consumerProguardFiles "consumer-rules.pro"
}
+ flavorDimensions "version"
+ productFlavors {
+ merger {
+ dimension "version"
+ }
+ }
+
buildTypes {
release {
minifyEnabled false
@@ -26,11 +57,58 @@
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
-}
+ lintOptions {
+ checkReleaseBuilds false
+ abortOnError false
+ }
+ //鍚堝苟璧勬簮
+ sourceSets {
+ main {
+ java {
+ //鍓旈櫎涓荤洰褰曚笅锛屾笭閬撻噸澶嶇殑绫�
+ channelJavaFiles.each {
+ def tag = "java\\"
+ def str = it.getAbsolutePath()
+ def str1 = str.substring(0, str.indexOf(tag))
+ def str2 = str.substring(str1.length() + tag.length(), str.length())
+ exclude str2
+ }
+ }
+ }
+ merger {
+ java {
+ srcDirs "${channelPath}/java"
+ }
+ jniLibs.srcDirs "${channelPath}/libs"
+ res.srcDirs "${channelPath}/res"
+ manifest {
+ File file = file("${channelPath}/AndroidManifest.xml")
+ if (file.exists())
+ srcFile "${channelPath}/AndroidManifest.xml"
+ }
+ //鍚堝苟鎻掍欢
+ plugins.each {
+ def pluginPath = "${rootPath}/plugins/${it}"
+ java.srcDirs "${pluginPath}/java"
+ jniLibs.srcDirs "${pluginPath}libs"
+ res.srcDirs "${pluginPath}/res"
+ manifest {
+ File file = file("${pluginPath}/AndroidManifest.xml")
+ if (file.exists())
+ srcFile "${pluginPath}/AndroidManifest.xml"
+ }
+ }
+ }
+ }
+
+}
dependencies {
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.2.1'
+ implementation 'androidx.constraintlayout:constraintlayout:2.0.3'
+ implementation 'androidx.navigation:navigation-fragment:2.3.1'
+ implementation 'androidx.navigation:navigation-ui:2.3.1'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
diff --git a/SdkProject/library/src/main/java/com/secondworld/universalsdk/CodeA2U.java b/SdkProject/library/src/main/java/com/secondworld/universalsdk/CodeA2U.java
new file mode 100644
index 0000000..0850ec8
--- /dev/null
+++ b/SdkProject/library/src/main/java/com/secondworld/universalsdk/CodeA2U.java
@@ -0,0 +1,40 @@
+package com.secondworld.universalsdk;
+
+/**
+ * Created by Administrator on 2018/7/18 0018.
+ */
+
+public interface CodeA2U {
+ /**
+ * 璧勬簮鎷疯礉瀹屾垚
+ */
+ int AssetCopyFinished = 0;
+ /**
+ * 鐢甸噺鏀瑰彉
+ */
+ int BatteryLevel = 1;
+ /**
+ * 鍏呯數鐘舵�佹敼鍙�
+ */
+ int BatteryCharging = 2;
+ /**
+ * 鍥炶皟sdk閫昏緫瀹屾瘯
+ */
+ int SdkInitComplete = 90;
+ /**
+ * 鍥炶皟android璁惧淇℃伅
+ */
+ int DeviceInfo = 3;
+ /**
+ * 鍥炶皟鎺ㄩ�佺殑鐙珛id
+ */
+ int PushClientID = 4;
+ /**
+ * 鍥炶皟澶栭儴瀛樺偍鏍圭洰褰曞湴鍧�
+ */
+ int ExternalStorage = 5;
+ /**
+ * 瑙﹀彂浜嗛��鍑烘父鎴忛�昏緫, 鎵撳紑浜屾纭鐣岄潰
+ */
+ int ExitGame = 6;
+}
diff --git a/SdkProject/library/src/main/java/com/secondworld/universalsdk/CodeU2A.java b/SdkProject/library/src/main/java/com/secondworld/universalsdk/CodeU2A.java
new file mode 100644
index 0000000..40f4863
--- /dev/null
+++ b/SdkProject/library/src/main/java/com/secondworld/universalsdk/CodeU2A.java
@@ -0,0 +1,60 @@
+package com.secondworld.universalsdk;
+
+/**
+ * Created by Administrator on 2018/7/18 0018.
+ */
+
+public interface CodeU2A {
+ /**
+ * 鎵ц璧勬簮鎷疯礉
+ */
+ int AssetCopy = 0;
+ /**
+ * 鎵ц寮�濮嬬數閲忔敼鍙�,鍏呯數鐘舵�佹敼鍙樼洃鍚�
+ */
+ int BatteryListenStart = 1;
+ /**
+ * 鎵ц鍋滄鐢甸噺鏀瑰彉,鍏呯數鐘舵�佹敼鍙樼洃鍚�
+ */
+ int BatteryListenStop = 2;
+ /**
+ * 鑾峰彇鍞竴璇嗗埆鐮�
+ */
+ int UniqueID = 3;
+ /**
+ * 鐢宠鍦ˋndroidManifest鏂囦欢涓�
+ */
+ int RequestManifestPermissions = 4;
+ /**
+ * 鍗曠嫭鍔ㄦ�佺敵璇锋煇涓�涓潈闄�
+ */
+ int RequestPermission = 5;
+ /**
+ * 閲嶅惎搴旂敤
+ */
+ int RestartApp = 6;
+ /**
+ * 鎷疯礉鏂囨湰淇℃伅
+ */
+ int CopyContent = 7;
+ /**
+ * 鎵撳紑缃戝潃
+ */
+ int OpenWebView = 8;
+ /**
+ * SDK鍒濆鍖�, 瀹屽叏鑷姩鍒濆鍖栫殑娴佺▼, 瀹屾垚蹇呰閫昏緫鍚庡啀鍥炶皟鍥炲幓
+ */
+ int Init = 9;
+ /**
+ * 瀹夎搴旂敤
+ */
+ int InstallAPK = 10;
+ /**
+ * 澶栭儴瀛樺偍鏍圭洰褰曞湴鍧�
+ */
+ int ExteneralStorage = 11;
+ /**
+ * 鎷疯礉娓告垙璧勬簮
+ */
+ int CopyOneAsset = 12;
+}
diff --git a/SdkProject/library/src/main/java/com/secondworld/universalsdk/H2EngineSDK.java b/SdkProject/library/src/main/java/com/secondworld/universalsdk/H2EngineSDK.java
index 1f597c6..85832bb 100644
--- a/SdkProject/library/src/main/java/com/secondworld/universalsdk/H2EngineSDK.java
+++ b/SdkProject/library/src/main/java/com/secondworld/universalsdk/H2EngineSDK.java
@@ -1,4 +1,36 @@
package com.secondworld.universalsdk;
+import com.secondworld.universalsdk.command.ICommand;
+
+import org.json.JSONObject;
+
+import java.util.HashMap;
+
public class H2EngineSDK {
+
+ public static HashMap<Integer, ICommand> allCommand = new HashMap();
+
+ public static void init() {
+
+ }
+
+ private static void AddCommand(ICommand command) {
+ allCommand.put(command.getCode(), command);
+ }
+
+ //unity 鍙戞潵鐨勬秷鎭�
+ public static void HandleUnityMessage(String json) {
+ try {
+ JSONObject _json = new JSONObject(json);
+ int code = _json.getInt("code");
+ ICommand command = allCommand.get(code);
+ if (command == null) {
+ return;
+ }
+ command.process(json);
+ } catch (Exception e) {
+
+ }
+ }
+
}
diff --git a/SdkProject/library/src/main/java/com/secondworld/universalsdk/command/CmdAssetCopy.java b/SdkProject/library/src/main/java/com/secondworld/universalsdk/command/CmdAssetCopy.java
new file mode 100644
index 0000000..4af539c
--- /dev/null
+++ b/SdkProject/library/src/main/java/com/secondworld/universalsdk/command/CmdAssetCopy.java
@@ -0,0 +1,14 @@
+package com.secondworld.universalsdk.command;
+
+import com.secondworld.universalsdk.CodeU2A;
+
+public class CmdAssetCopy implements ICommand {
+ @Override
+ public int getCode() {
+ return CodeU2A.AssetCopy;
+ }
+
+ @Override
+ public void process(String json) {
+ }
+}
diff --git a/SdkProject/library/src/main/java/com/secondworld/universalsdk/command/CmdInit.java b/SdkProject/library/src/main/java/com/secondworld/universalsdk/command/CmdInit.java
new file mode 100644
index 0000000..491b23b
--- /dev/null
+++ b/SdkProject/library/src/main/java/com/secondworld/universalsdk/command/CmdInit.java
@@ -0,0 +1,18 @@
+package com.secondworld.universalsdk.command;
+
+import com.secondworld.universalsdk.CodeU2A;
+
+/**
+ * 娓告垙鍒濆鍖�
+ */
+public class CmdInit implements ICommand {
+ @Override
+ public int getCode() {
+ return CodeU2A.Init;
+ }
+
+ @Override
+ public void process(String json) {
+
+ }
+}
diff --git a/SdkProject/library/src/main/java/com/secondworld/universalsdk/command/ICommand.java b/SdkProject/library/src/main/java/com/secondworld/universalsdk/command/ICommand.java
new file mode 100644
index 0000000..d481225
--- /dev/null
+++ b/SdkProject/library/src/main/java/com/secondworld/universalsdk/command/ICommand.java
@@ -0,0 +1,12 @@
+package com.secondworld.universalsdk.command;
+
+/**
+ * unity 浼犻�掕繃鏉ョ殑鍛戒护
+ */
+public interface ICommand {
+
+ int getCode();
+
+ void process(String json);
+
+}
diff --git a/SdkProject/merger/.gitignore b/SdkProject/merger/.gitignore
deleted file mode 100644
index 42afabf..0000000
--- a/SdkProject/merger/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-/build
\ No newline at end of file
diff --git a/SdkProject/merger/build.gradle b/SdkProject/merger/build.gradle
deleted file mode 100644
index 257d232..0000000
--- a/SdkProject/merger/build.gradle
+++ /dev/null
@@ -1,86 +0,0 @@
-plugins {
- id 'com.android.library'
-}
-def rootPath = rootProject.getRootDir().getAbsolutePath()
-def channelPath = "${rootPath}/channel/${CHANNEL_NAME}"
-
-def applyGradle(String path) {
- path = "${path}.gradle"
- File file = file(path)
- if (file.exists())
- apply from: path
-}
-
-applyGradle("${rootPath}/utils")
-applyGradle("${channelPath}/build")
-
-Properties localProp = loadProperties('local')
-Properties channelProp = loadProperties("${channelPath}/config")
-
-def plugins = channelProp.getProperty("PLUGINS").split(';')
-
-plugins.each {
- applyGradle("${rootPath}/plugins/${it}/build")
-}
-
-android {
- compileSdkVersion 29
- buildToolsVersion "30.0.2"
-
- defaultConfig {
- minSdkVersion 21
- targetSdkVersion 29
- versionCode 1
- versionName "1.0"
-
- testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
- consumerProguardFiles "consumer-rules.pro"
- }
-
- buildTypes {
- release {
- minifyEnabled false
- proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
- }
- }
- compileOptions {
- sourceCompatibility JavaVersion.VERSION_1_8
- targetCompatibility JavaVersion.VERSION_1_8
- }
-
- //鍚堝苟璧勬簮
- sourceSets {
- main {
- java.srcDirs "src/main/java", "${channelPath}/java"
- jniLibs.srcDirs "libs", "${channelPath}/libs"
- res.srcDirs 'src/main/res', "${channelPath}/res"
- manifest {
- srcFile "src/main/AndroidManifest.xml"
- File file = file("${channelPath}/AndroidManifest.xml")
- if (file.exists())
- srcFile "${channelPath}/AndroidManifest.xml"
- }
- //鍚堝苟鎻掍欢
- plugins.each {
- def pluginPath = "${rootPath}/plugins/${it}"
- java.srcDirs "${pluginPath}/java"
- jniLibs.srcDirs "${pluginPath}libs"
- res.srcDirs "${pluginPath}/res"
- manifest {
- File file = file("${pluginPath}/AndroidManifest.xml")
- if (file.exists())
- srcFile "${pluginPath}/AndroidManifest.xml"
- }
- }
- }
- }
-}
-
-dependencies {
- implementation 'androidx.appcompat:appcompat:1.2.0'
- implementation 'com.google.android.material:material:1.2.1'
- implementation project(path: ':library')
- testImplementation 'junit:junit:4.+'
- androidTestImplementation 'androidx.test.ext:junit:1.1.2'
- androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
-}
\ No newline at end of file
diff --git a/SdkProject/merger/consumer-rules.pro b/SdkProject/merger/consumer-rules.pro
deleted file mode 100644
index e69de29..0000000
--- a/SdkProject/merger/consumer-rules.pro
+++ /dev/null
diff --git a/SdkProject/merger/proguard-rules.pro b/SdkProject/merger/proguard-rules.pro
deleted file mode 100644
index 481bb43..0000000
--- a/SdkProject/merger/proguard-rules.pro
+++ /dev/null
@@ -1,21 +0,0 @@
-# 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
\ No newline at end of file
diff --git a/SdkProject/merger/src/androidTest/java/com/secondworld/merger/ExampleInstrumentedTest.java b/SdkProject/merger/src/androidTest/java/com/secondworld/merger/ExampleInstrumentedTest.java
deleted file mode 100644
index 21145d1..0000000
--- a/SdkProject/merger/src/androidTest/java/com/secondworld/merger/ExampleInstrumentedTest.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package com.secondworld.merger;
-
-import android.content.Context;
-
-import androidx.test.platform.app.InstrumentationRegistry;
-import androidx.test.ext.junit.runners.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.getInstrumentation().getTargetContext();
- assertEquals("com.secondworld.merger.test", appContext.getPackageName());
- }
-}
\ No newline at end of file
diff --git a/SdkProject/merger/src/main/AndroidManifest.xml b/SdkProject/merger/src/main/AndroidManifest.xml
deleted file mode 100644
index 86f09e1..0000000
--- a/SdkProject/merger/src/main/AndroidManifest.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.secondworld.merger">
-
-</manifest>
\ No newline at end of file
diff --git a/SdkProject/merger/src/test/java/com/secondworld/merger/ExampleUnitTest.java b/SdkProject/merger/src/test/java/com/secondworld/merger/ExampleUnitTest.java
deleted file mode 100644
index 603e0d7..0000000
--- a/SdkProject/merger/src/test/java/com/secondworld/merger/ExampleUnitTest.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package com.secondworld.merger;
-
-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);
- }
-}
\ No newline at end of file
diff --git a/SdkProject/settings.gradle b/SdkProject/settings.gradle
index 136b5e5..4eee44f 100644
--- a/SdkProject/settings.gradle
+++ b/SdkProject/settings.gradle
@@ -1,4 +1,3 @@
-include ':merger'
include ':library'
include ':app'
rootProject.name = "SdkProject"
\ No newline at end of file
diff --git a/SdkProject/utils.gradle b/SdkProject/utils.gradle
index 1ca8bc5..eb8d22b 100644
--- a/SdkProject/utils.gradle
+++ b/SdkProject/utils.gradle
@@ -1,12 +1,30 @@
-
//鍔犺浇鏈泦閰嶇疆properties鏂囦欢
def loadProperties(String name) {
Properties properties = new Properties()
- InputStream inputStream = project.rootProject.file("${name}.properties").newDataInputStream();
+ InputStream inputStream = project.rootProject.file("${name}.properties").newDataInputStream()
properties.load(inputStream)
return properties
}
+//閫掑綊璇诲彇璇ョ洰褰曚笅鐨勬枃浠�
+def getAllFiles(ArrayList<File> list, String path) {
+ list.clear()
+ File file = file(path)
+ if (file.isFile()) {
+ list.add(file)
+ return list
+ }
+ def files = file.listFiles()
+ files.each {
+ if (it.isDirectory())
+ getAllFiles(list,it.getAbsolutePath())
+ else
+ list.add(it)
+ print "\n"
+ }
+ return list
+}
ext {
+ getAllFiles = this.&getAllFiles
loadProperties = this.&loadProperties
}
\ No newline at end of file
--
Gitblit v1.8.0