Browse Source

提交2.0.3版本,将android support转成androidx支持,并将Maven库存放到个人服务器上

yanyi 5 years ago
parent
commit
a4e93b0849

+ 28 - 6
README.md

@@ -1,12 +1,34 @@
 # OkHttp
-## OkHttp请求封装
-### 使用方法
 
-module 下添加
+OkHttp请求封装
+----------
+使用
+---
+### 根目录下build.gradle添加Maven地址
+~~~
+repositories {
+        maven {
+            url "http://maven.yanyi.online:8081/nexus/content/repositories/mylove/"
+        }
+    }
+~~~
+### module 下添加
+~~~
+implementation 'com.yanyi.benyanyi:okhttplib:2.0.3'
+~~~
+
+或者
+~~~
+<dependency>
+  <groupId>com.yanyi.benyanyi</groupId>
+  <artifactId>okhttplib</artifactId>
+  <version>2.0.3</version>
+  <type>aar</type>
+</dependency>
+~~~
 
-`implementation 'com.yanyi.benyanyi:okhttplib:2.0.2'` 
-  
 ### 更新记录
+* 2020-05-16(2.0.3) 将android support转成androidx支持,并将Maven库存放到个人服务器上
 * 2020-01-16(2.0.2) 修复解析崩溃问题,优化返回方法
 * 2019-08-26(2.0.1) 优化下载
 * 2019-08-20(2.0.0) 升级2.x版本,重构代码,优化方法,使调用更简洁明了
@@ -19,7 +41,7 @@ module 下添加
 * 2018-09-14(1.0.8) 优化下载文件方法
 * 2018-09-12(1.0.7) 修复下载文件回调没返回问题,下载路径都是根目录下
 
-<br/>
+---
 若在使用过程中出现什么问题,可以联系作者<br/>
 作者:演绎<br/>
 QQ:1541612424<br/>

+ 8 - 7
app/build.gradle

@@ -1,14 +1,14 @@
 apply plugin: 'com.android.application'
 
 android {
-    compileSdkVersion 28
+    compileSdkVersion 29
     defaultConfig {
         applicationId "com.mylove.okhttp"
         minSdkVersion 15
-        targetSdkVersion 28
+        targetSdkVersion 29
         versionCode 1
         versionName "1.0"
-        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
+        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
 
 
         multiDexEnabled true
@@ -34,16 +34,17 @@ android {
 
 dependencies {
     implementation fileTree(include: ['*.jar'], dir: 'libs')
-    implementation 'com.android.support:appcompat-v7:28.0.0'
+    implementation 'androidx.appcompat:appcompat:1.0.0'
     testImplementation 'junit:junit:4.12'
-    androidTestImplementation 'com.android.support.test:runner:1.0.2'
-    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
-    implementation project(':okhttplib')
+    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
+    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
+//    implementation project(':okhttplib')
     implementation 'com.yanyi.benyanyi:loglib:1.0.3'
     implementation 'com.yanyi.benyanyi:permissionlib:1.0.9'
     implementation 'io.reactivex.rxjava2:rxjava:2.2.10'
     implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
     implementation 'org.greenrobot:eventbus:3.1.1'
     implementation 'com.google.code.gson:gson:2.8.6'
+    implementation project(path: ':okhttplib')
 
 }

+ 2 - 2
app/src/androidTest/java/com/benyanyi/okhttp/ExampleInstrumentedTest.java

@@ -1,8 +1,8 @@
 package com.benyanyi.okhttp;
 
 import android.content.Context;
-import android.support.test.InstrumentationRegistry;
-import android.support.test.runner.AndroidJUnit4;
+import androidx.test.platform.app.InstrumentationRegistry;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
 
 import org.junit.Test;
 import org.junit.runner.RunWith;

+ 1 - 1
app/src/main/AndroidManifest.xml

@@ -29,7 +29,7 @@
         </activity>
         <!-- 定义FileProvider -->
         <provider
-            android:name="android.support.v4.content.FileProvider"
+            android:name="androidx.core.content.FileProvider"
             android:authorities="com.mylove.okhttp.fileProvider"
             android:exported="false"
             android:grantUriPermissions="true">

+ 2 - 2
app/src/main/java/com/mylove/okhttp/DownloadActivity.java

@@ -2,8 +2,8 @@ package com.mylove.okhttp;
 
 import android.content.Context;
 import android.os.Bundle;
-import android.support.annotation.IdRes;
-import android.support.v7.app.AppCompatActivity;
+import androidx.annotation.IdRes;
+import androidx.appcompat.app.AppCompatActivity;
 import android.view.View;
 import android.widget.Button;
 import android.widget.ProgressBar;

+ 3 - 2
app/src/main/java/com/mylove/okhttp/MainActivity.java

@@ -2,10 +2,11 @@ package com.mylove.okhttp;
 
 import android.content.Intent;
 import android.os.Bundle;
-import android.support.annotation.Nullable;
-import android.support.v7.app.AppCompatActivity;
 import android.view.View;
 
+import androidx.annotation.Nullable;
+import androidx.appcompat.app.AppCompatActivity;
+
 import com.benyanyi.loglib.Jlog;
 import com.benyanyi.okhttp.OkHttpUtil;
 import com.benyanyi.okhttp.listener.OnOkHttpListener;

+ 3 - 1
build.gradle

@@ -5,11 +5,12 @@ buildscript {
     repositories {
         google()
         jcenter()
+        maven { url 'http://maven.yanyi.online:8081/nexus/content/repositories/mylove/' }
     }
     dependencies {
         classpath 'com.android.tools.build:gradle:3.2.0'
         classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0'
-        classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.3'
+//        classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.3'
 //        classpath 'com.novoda:bintray-release:0.8.0'
 
         // NOTE: Do not place your application dependencies here; they belong
@@ -21,6 +22,7 @@ allprojects {
     repositories {
         google()
         jcenter()
+        maven { url 'http://maven.yanyi.online:8081/nexus/content/repositories/mylove/' }
         //解决中文乱码问题
         tasks.withType(Javadoc) { //兼容中文
             options.addStringOption('Xdoclint:none', '-quiet')

+ 2 - 0
gradle.properties

@@ -9,6 +9,8 @@
 
 # Specifies the JVM arguments used for the daemon process.
 # The setting is particularly useful for tweaking memory settings.
+android.enableJetifier=true
+android.useAndroidX=true
 org.gradle.jvmargs=-Xmx1536m
 
 # When configured, Gradle will run in incubating parallel mode.

+ 15 - 67
okhttplib/bintrayUpload.gradle

@@ -1,80 +1,28 @@
-// 这里添加下面两行代码。
-apply plugin: 'com.github.dcendents.android-maven'
-apply plugin: 'com.jfrog.bintray'
+apply plugin: 'maven-publish'
+apply plugin: 'maven'
 
-// 定义两个链接,下面会用到。
-def siteUrl = 'http://www.yanyis.space/yanyi/baseokhttp' // 项目主页。
-def gitUrl = 'http://www.yanyis.space/yanyi/baseokhttp.git' // Git仓库的url。
+Properties properties = new Properties()
+properties.load(project.rootProject.file('local.properties').newDataInputStream())
+uploadArchives {
+    repositories {
+        mavenDeployer {
+            repository(url: properties.getProperty("POM_URL")) {
+                authentication(userName: properties.getProperty("nexus.user"), password: properties.getProperty("nexus.password"))
+            }
 
-group = "com.yanyi.benyanyi"// 唯一包名,比如compile 'com.ansen.http:okhttpencapsulation:1.0.1'中的com.ansen.http就是这里配置的。
-version = "2.0.3-base3" //项目引用的版本号,比如compile 'com.ansen.http:okhttpencapsulation:1.0.1'中的1.0.1就是这里配置的。
-install {
-    repositories.mavenInstaller {
-        // This generates POM.xml with proper parameters
-        pom {
-            project {
-                packaging 'aar'
-                // Add your description here
-                name 'okhttp3 + rxjava2'
-                url siteUrl
-                // Set your license
+            pom.groupId = properties.getProperty("POM_GROUP_ID")
+            pom.artifactId = properties.getProperty("POM_ATRIFACT_ID")
+            pom.version = properties.getProperty("POM_VERSION")
+
+            pom.project {
                 licenses {
                     license {
                         name 'The Apache Software License, Version 2.0'
                         url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
                     }
                 }
-                developers {
-                    developer {
-                        id 'benyanyi'     //填写的一些基本信息
-                        name 'benyanyi'
-                        email 'git@yanyi.red'
-                    }
-                }
-                scm {
-                    connection gitUrl
-                    developerConnection gitUrl
-                    url siteUrl
-                }
             }
         }
     }
 }
-task sourcesJar(type: Jar) {
-    from android.sourceSets.main.java.srcDirs
-    classifier = 'sources'
-}
-task javadoc(type: Javadoc) {
-    source = android.sourceSets.main.java.srcDirs
-    classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
-}
-task javadocJar(type: Jar, dependsOn: javadoc) {
-    classifier = 'javadoc'
-    from javadoc.destinationDir
-}
-artifacts {
-    archives javadocJar
-    archives sourcesJar
-}
-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 = "OkHttpLib"
-        name = "OkHttpLib"   //发布到JCenter上的项目名字
-        websiteUrl = siteUrl
-        vcsUrl = gitUrl
-        licenses = ["Apache-2.0"]
-        publish = true
-    }
-}
-javadoc { //jav doc采用utf-8编码否则会报“GBK的不可映射字符”错误
-    options{
-        encoding "UTF-8"
-        charSet 'UTF-8'
-    }
-}
 //gradlew bintrayUpload    terminal中输入

+ 11 - 11
okhttplib/build.gradle

@@ -1,17 +1,17 @@
 apply plugin: 'com.android.library'
 
 android {
-    compileSdkVersion 28
+    compileSdkVersion 29
 
 
 
     defaultConfig {
         minSdkVersion 14
-        targetSdkVersion 28
+        targetSdkVersion 29
         versionCode 1
         versionName "1.0"
 
-        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
+        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
 
     }
 
@@ -25,18 +25,18 @@ android {
 
 dependencies {
     implementation fileTree(include: ['*.jar'], dir: 'libs')
-    implementation 'com.android.support:appcompat-v7:28.0.0'
+    implementation 'androidx.appcompat:appcompat:1.0.0'
     testImplementation 'junit:junit:4.12'
-    androidTestImplementation 'com.android.support.test:runner:1.0.2'
-    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
-    implementation 'com.squareup.okhttp3:okhttp:4.0.0'
+    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
+    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
+    implementation 'com.squareup.okhttp3:okhttp:4.5.0'
     //网络请求log 拦截器
-    implementation 'com.squareup.okhttp3:logging-interceptor:4.0.0'
-    implementation 'com.squareup.okio:okio:2.2.2'
+    implementation 'com.squareup.okhttp3:logging-interceptor:4.5.0'
+    implementation 'com.squareup.okio:okio:2.6.0'
     implementation 'io.reactivex.rxjava2:rxjava:2.2.10'
     implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
-    implementation 'com.google.code.gson:gson:2.8.5'
-    implementation 'com.squareup.retrofit2:retrofit:2.5.0'
+    implementation 'com.google.code.gson:gson:2.8.6'
+//    implementation 'com.squareup.retrofit2:retrofit:2.5.0'
     api files('lib/android-xml-json.jar')
     implementation 'org.greenrobot:eventbus:3.1.1'
 

+ 2 - 2
okhttplib/src/androidTest/java/com/benyanyi/okhttp/ExampleInstrumentedTest.java

@@ -1,8 +1,8 @@
 package com.benyanyi.okhttp;
 
 import android.content.Context;
-import android.support.test.InstrumentationRegistry;
-import android.support.test.runner.AndroidJUnit4;
+import androidx.test.platform.app.InstrumentationRegistry;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
 
 import org.junit.Test;
 import org.junit.runner.RunWith;

+ 1 - 1
okhttplib/src/main/java/com/benyanyi/okhttp/download/FileUtil.java

@@ -2,7 +2,7 @@ package com.benyanyi.okhttp.download;
 
 import android.graphics.Bitmap;
 import android.os.Environment;
-import android.support.annotation.NonNull;
+import androidx.annotation.NonNull;
 
 import com.benyanyi.okhttp.util.FormatUtil;
 

+ 1 - 1
okhttplib/src/main/java/com/benyanyi/okhttp/type/HttpConfig.java

@@ -1,7 +1,7 @@
 package com.benyanyi.okhttp.type;
 
 import android.content.Context;
-import android.support.annotation.NonNull;
+import androidx.annotation.NonNull;
 
 import com.benyanyi.okhttp.util.OkHttpLog;