Просмотр исходного кода

添加 publish 功能,升级 oss 依赖,移除友盟 sdk

cc12458 1 месяц назад
Родитель
Сommit
71c3b7ba4a

+ 3 - 1
.gitignore

@@ -14,4 +14,6 @@
 .cxx
 local.properties
 .kotlin/
-**/build/**
+**/build/**
+
+local-repo/

+ 6 - 0
.idea/AndroidProjectSystem.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="AndroidProjectSystem">
+    <option name="providerId" value="com.android.tools.idea.GradleProjectSystem" />
+  </component>
+</project>

+ 10 - 0
.idea/deploymentTargetSelector.xml

@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="deploymentTargetSelector">
+    <selectionStates>
+      <SelectionState runConfigName="app">
+        <option name="selectionMode" value="DROPDOWN" />
+      </SelectionState>
+    </selectionStates>
+  </component>
+</project>

+ 2 - 4
.idea/gradle.xml

@@ -4,17 +4,15 @@
   <component name="GradleSettings">
     <option name="linkedExternalProjectsSettings">
       <GradleProjectSettings>
-        <option name="testRunner" value="GRADLE" />
-        <option name="distributionType" value="DEFAULT_WRAPPED" />
+        <option name="testRunner" value="CHOOSE_PER_TEST" />
         <option name="externalProjectPath" value="$PROJECT_DIR$" />
         <option name="gradleHome" value="$PROJECT_DIR$/../../../Cache/.gradle/wrapper/dists/gradle-7.0.2-bin/857tjihv64xamwrf0h14cai3r/gradle-7.0.2" />
-        <option name="gradleJvm" value="corretto-11" />
+        <option name="gradleJvm" value="#GRADLE_LOCAL_JAVA_HOME" />
         <option name="modules">
           <set>
             <option value="$PROJECT_DIR$" />
             <option value="$PROJECT_DIR$/TYUsbSDK" />
             <option value="$PROJECT_DIR$/app" />
-            <option value="$PROJECT_DIR$/app/usbmaisdk" />
             <option value="$PROJECT_DIR$/ble" />
           </set>
         </option>

+ 10 - 0
.idea/migrations.xml

@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="ProjectMigrations">
+    <option name="MigrateToGradleLocalJavaHome">
+      <set>
+        <option value="$PROJECT_DIR$" />
+      </set>
+    </option>
+  </component>
+</project>

+ 17 - 0
.idea/runConfigurations.xml

@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="RunConfigurationProducerService">
+    <option name="ignoredProducers">
+      <set>
+        <option value="com.intellij.execution.junit.AbstractAllInDirectoryConfigurationProducer" />
+        <option value="com.intellij.execution.junit.AllInPackageConfigurationProducer" />
+        <option value="com.intellij.execution.junit.PatternConfigurationProducer" />
+        <option value="com.intellij.execution.junit.TestInClassConfigurationProducer" />
+        <option value="com.intellij.execution.junit.UniqueIdConfigurationProducer" />
+        <option value="com.intellij.execution.junit.testDiscovery.JUnitTestDiscoveryConfigurationProducer" />
+        <option value="org.jetbrains.kotlin.idea.junit.KotlinJUnitRunConfigurationProducer" />
+        <option value="org.jetbrains.kotlin.idea.junit.KotlinPatternConfigurationProducer" />
+      </set>
+    </option>
+  </component>
+</project>

+ 2 - 2
TYUsbSDK/build.gradle

@@ -47,14 +47,14 @@ dependencies {
 
     implementation 'com.github.felHR85:UsbSerial:6.1.0'
     api 'com.opencsv:opencsv:5.6'
-    api 'com.aliyun.dpa:oss-android-sdk:2.9.5'
+    api 'com.aliyun.dpa:oss-android-sdk:2.9.21'
     api 'com.github.PhilJay:MPAndroidChart:v3.1.0'
     implementation fileTree(include: ['*.jar'], dir: 'libs')
     implementation 'com.android.volley:volley:1.2.1'
     api 'com.jakewharton.rxbinding2:rxbinding:2.0.0'
     api 'io.reactivex.rxjava2:rxjava:2.1.7'
     api 'io.reactivex.rxjava2:rxandroid:2.0.1'
-    api 'org.greenrobot:eventbus:3.1.1'
+    api 'org.greenrobot:eventbus:3.3.1'
     api 'com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.41'
     implementation 'androidx.work:work-runtime-ktx:2.7.0'
 }

+ 4 - 1
TYUsbSDK/proguard-rules.pro

@@ -18,4 +18,7 @@
 
 # If you keep the line number information, uncomment this to
 # hide the original source file name.
-#-renamesourcefileattribute SourceFile
+#-renamesourcefileattribute SourceFile
+-keep class com.alibaba.sdk.android.oss.** { *; }
+-dontwarn okio.**
+-dontwarn org.apache.commons.codec.binary.**

+ 3 - 8
app/build.gradle

@@ -40,16 +40,11 @@ dependencies {
     testImplementation 'junit:junit:4.+'
     androidTestImplementation 'androidx.test.ext:junit:1.1.2'
     androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
-    implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0'
-//    implementation project(path: ':ble')
-    implementation files('libs/ble-release.aar')
-    implementation 'com.umeng.umsdk:common:9.4.4' //(必选)
-    implementation 'com.umeng.umsdk:asms:1.4.1' // asms包依赖(必选)
-    implementation 'com.umeng.umsdk:apm:1.5.2' // U-APM包依赖(必选)
+    implementation 'com.taiyi.sdk.pulse:ble:1.1.0-alpha.01'
     implementation 'com.android.volley:volley:1.2.1'
     implementation 'com.opencsv:opencsv:5.6'
-    implementation 'org.greenrobot:eventbus:3.1.1'
-    implementation 'com.aliyun.dpa:oss-android-sdk:2.9.5'
+    implementation 'org.greenrobot:eventbus:3.3.1'
+    implementation 'com.aliyun.dpa:oss-android-sdk:2.9.21'
     implementation 'com.jakewharton.rxbinding2:rxbinding:2.0.0'
     implementation 'io.reactivex.rxjava2:rxjava:2.1.7'
     implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'

BIN
app/libs/ble-release-1.aar


BIN
app/libs/ble-release.aar


+ 0 - 6
app/src/main/java/com/taiyi/usbmaidemo/AppApplication.java

@@ -2,15 +2,9 @@ package com.taiyi.usbmaidemo;
 
 import android.app.Application;
 
-import com.umeng.commonsdk.UMConfigure;
-
 public class AppApplication extends Application {
     @Override
     public void onCreate() {
         super.onCreate();
-        UMConfigure.setLogEnabled(true);
-        //添加注释
-        UMConfigure.init(this, "646f14d4a1a164591b23609b", "umeng", UMConfigure.DEVICE_TYPE_PHONE, "");
-
     }
 }

+ 5 - 3
ble/build.gradle

@@ -5,11 +5,11 @@ plugins {
 
 android {
     namespace 'com.taiyi.zhimai'
-    compileSdk 33
+    compileSdk 31
 
     defaultConfig {
         minSdk 21
-        targetSdk 33
+        targetSdk 31
 
         testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
         consumerProguardFiles "consumer-rules.pro"
@@ -46,4 +46,6 @@ dependencies {
 //    api 'io.reactivex.rxjava2:rxjava:2.1.7'
 //    api 'io.reactivex.rxjava2:rxandroid:2.0.1'
 //    api 'com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.41'
-}
+}
+
+apply from: "../publish.gradle"

+ 3 - 0
ble/gradle.properties

@@ -0,0 +1,3 @@
+MAVEN_LIB_ARTIFACTID=ble
+MAVEN_LIB_VERSION=1.1.0-alpha.01
+MAVEN_LIB_DESCRIPTION=six.pulse:packag

BIN
ble/libs/TYUsbSDK-debug.aar


+ 4 - 1
ble/proguard-rules.pro

@@ -18,4 +18,7 @@
 
 # If you keep the line number information, uncomment this to
 # hide the original source file name.
-#-renamesourcefileattribute SourceFile
+#-renamesourcefileattribute SourceFile
+-keep class com.alibaba.sdk.android.oss.** { *; }
+-dontwarn okio.**
+-dontwarn org.apache.commons.codec.binary.**

+ 3 - 1
gradle.properties

@@ -16,4 +16,6 @@ org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
 # https://developer.android.com/topic/libraries/support-library/androidx-rn
 android.useAndroidX=true
 # Automatically convert third-party libraries to use AndroidX
-android.enableJetifier=true
+android.enableJetifier=true
+
+MAVEN_LIB_GROUP=com.taiyi.sdk.pulse

+ 171 - 0
publish.gradle

@@ -0,0 +1,171 @@
+apply plugin: 'maven-publish'
+
+Properties rootLocalProperties = new Properties()
+def rootLocalPropertiesFile = project.rootProject.file('local.properties')
+if (rootLocalPropertiesFile != null && rootLocalPropertiesFile.exists()) {
+    rootLocalProperties.load(rootLocalPropertiesFile.newDataInputStream())
+    rootLocalProperties.each { name, value ->
+        project.ext[name] = value
+    }
+}
+
+
+Properties localProperties = new Properties()
+def localPropertiesFile = project.file('local.properties');
+if (localPropertiesFile != null && localPropertiesFile.exists()) {
+    localProperties.load(localPropertiesFile.newDataInputStream())
+    localProperties.each { name, value ->
+        project.ext[name] = value
+    }
+}
+
+
+def getPropertyValue(key) {
+    return project.ext.has(key) ? project.ext.getProperty(key) : (project.rootProject.ext.has(key)?project.rootProject.ext.getProperty(key):null)
+}
+
+def projectGroupId = getPropertyValue('MAVEN_LIB_GROUP')
+def projectArtifactId = getPropertyValue("MAVEN_LIB_ARTIFACTID")
+def projectVersionName = getPropertyValue("MAVEN_LIB_VERSION")
+def projectDescription = getPropertyValue("MAVEN_LIB_DESCRIPTION")
+
+if (!projectGroupId) {
+    println('missing parameter MAVEN_LIB_GROUP')
+    return
+}
+
+if (!projectArtifactId) {
+    println('missing parameter MAVEN_LIB_ARTIFACTID')
+    return
+}
+
+if (!projectVersionName) {
+    println('missing parameter MAVEN_LIB_VERSION')
+    return
+}
+
+
+def isAndroidProject = project.hasProperty('android')
+if (isAndroidProject) {
+    task androidJavadocs(type: Javadoc) {
+        source = android.sourceSets.main.java.srcDirs
+        classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
+    }
+    task javadocsJar(type: Jar, dependsOn: androidJavadocs) {
+        archiveClassifier.set("javadoc")
+        from androidJavadocs.destinationDir
+    }
+    task sourcesJar(type: Jar) {
+        archiveClassifier.set("sources")
+        from android.sourceSets.main.java.srcDirs
+    }
+
+    afterEvaluate { project ->
+        tasks.all { Task task ->
+            if (task.name.equalsIgnoreCase('publish')) {
+                task.dependsOn tasks.getByName('assemble')
+            }
+        }
+    }
+} else {
+    task javadocsJar(type: Jar, dependsOn: javadoc) {
+        archiveClassifier.set("javadoc")
+        from javadoc.destinationDir
+    }
+    task sourcesJar(type: Jar) {
+        archiveClassifier.set("sources")
+        from sourceSets.main.allJava
+    }
+}
+
+tasks.withType(Javadoc).all {
+    options {
+        encoding "UTF-8"
+        charSet 'UTF-8'
+        author true
+        version true
+        links "http://docs.oracle.com/javase/8/docs/api"
+        if (isAndroidProject) {
+            linksOffline "http://d.android.com/reference", "${android.sdkDirectory}/docs/reference"
+        }
+        failOnError = false
+    }
+    enabled = false
+}
+
+artifacts {
+    archives javadocsJar, sourcesJar
+}
+
+afterEvaluate {
+    publishing {
+        publications {
+            aar(MavenPublication) {
+                groupId = projectGroupId
+                artifactId = projectArtifactId
+                version = projectVersionName
+                if (isAndroidProject) {
+                    artifact(tasks.getByName("bundleReleaseAar"))
+                } else {
+                    artifact("$buildDir/libs/${project.getName()}.jar")
+                }
+//                artifact javadocsJar
+//                artifact sourcesJar
+
+                pom {
+                    name = projectArtifactId
+                    description = projectDescription
+                    // If your project has a dedicated site, use its URL here
+                    withXml {
+                        def dependenciesNode = asNode().appendNode('dependencies')
+                        def scopes = []
+                        if (configurations.hasProperty("compile")) {
+                            scopes.add(configurations.compile)
+                        }
+                        if (configurations.hasProperty("api")) {
+                            scopes.add(configurations.api)
+                        }
+                        if (configurations.hasProperty("implementation")) {
+                            scopes.add(configurations.implementation)
+                        }
+                        if (configurations.hasProperty("debugImplementation")) {
+                            scopes.add(configurations.debugImplementation)
+                        }
+                        if (configurations.hasProperty("releaseImplementation")) {
+                            scopes.add(configurations.releaseImplementation)
+                        }
+                        scopes.each { scope ->
+                            scope.allDependencies.each {
+                                if (it instanceof ModuleDependency) {
+                                    boolean isTransitive = ((ModuleDependency) it).transitive
+                                    if (!isTransitive) {
+                                        return
+                                    }
+                                }
+
+                                if (it.group == "unspecified" || it.version == 'unspecified') {
+                                    return
+                                }
+
+                                if (it.group && it.name && it.version) {
+                                    def dependencyNode = dependenciesNode.appendNode('dependency')
+                                    dependencyNode.appendNode('groupId', it.group)
+                                    dependencyNode.appendNode('artifactId', it.name)
+                                    dependencyNode.appendNode('version', it.version)
+                                    dependencyNode.appendNode('scope', scope.name)
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+
+        repositories {
+            maven {
+                name = projectArtifactId
+                url = uri("${rootProject.projectDir}/local-repo")
+            }
+        }
+    }
+}

+ 1 - 1
settings.gradle

@@ -5,10 +5,10 @@ dependencyResolutionManagement {
         mavenCentral()
         maven { url 'https://jitpack.io' }
         jcenter() // Warning: this repository is going to shut down soon
+        maven { url "file://${rootDir}/local-repo" }
     }
 }
 rootProject.name = "USBMaiDemo"
 include ':app'
-include ':app:usbmaisdk'
 include ':TYUsbSDK'
 include ':ble'