diff --git a/build.gradle b/build.gradle index 8e6261d..4055c94 100644 --- a/build.gradle +++ b/build.gradle @@ -2,26 +2,13 @@ buildscript { repositories { google() - jcenter() + mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:3.4.2' + classpath 'com.android.tools.build:gradle:4.0.1' } } -plugins { - id "com.jfrog.bintray" version "1.8.4" -} - -plugins { - id "com.github.dcendents.android-maven" version "2.1" -} - -bintray { - publications = [] - configurations = [] -} - allprojects { repositories { google() diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..199d16e --- /dev/null +++ b/gradle.properties @@ -0,0 +1,20 @@ +# Project-wide Gradle settings. +# IDE (e.g. Android Studio) users: +# Gradle settings configured through the IDE *will override* +# any settings specified in this file. +# For more details on how to configure your build environment visit +# http://www.gradle.org/docs/current/userguide/build_environment.html +# Specifies the JVM arguments used for the daemon process. +# The setting is particularly useful for tweaking memory settings. +org.gradle.jvmargs=-Xmx1536m +# When configured, Gradle will run in incubating parallel mode. +# This option should only be used with decoupled projects. More details, visit +# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects +# org.gradle.parallel=true +# AndroidX package structure to make it clearer which packages are bundled with the +# Android operating system, and which are packaged with your app's APK +# https://developer.android.com/topic/libraries/support-library/androidx-rn +android.useAndroidX=true +# Automatically convert third-party libraries to use AndroidX +android.enableJetifier=true + diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index f4ac9b0..dfb6cb5 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip diff --git a/library/build.gradle b/library/build.gradle index 8b52bc3..c25a507 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -1,14 +1,12 @@ apply plugin: 'com.android.library' -apply plugin: 'com.github.dcendents.android-maven' -apply plugin: 'com.jfrog.bintray' +apply plugin: 'maven-publish' +apply plugin: 'signing' -// https://github.com/bintray/gradle-bintray-plugin/issues/74#issuecomment-168367341 -// https://github.com/dcendents/android-maven-gradle-plugin/issues/9 ext { GROUP = 'com.codepath.libraries' - BASE_VERSION = "2.0" - VERSION_NAME = "2.1.3" + BASE_VERSION = "2.3" + VERSION_NAME = "2.3.0" POM_PACKAGING = "aar" POM_DESCRIPTION = "CodePath OAuth Handler" @@ -32,13 +30,13 @@ group = GROUP archivesBaseName = POM_ARTIFACT_ID android { - compileSdkVersion 28 + compileSdkVersion 30 defaultConfig { versionCode 1 versionName VERSION_NAME minSdkVersion 21 - targetSdkVersion 28 + targetSdkVersion 30 } // Related to https://github.com/scribejava/scribejava/issues/480 @@ -54,26 +52,65 @@ android { } } -bintray { - user = project.hasProperty('bintrayUser') ? project.property('bintrayUser') : System.getenv('BINTRAY_USER') - key = project.hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY') - - configurations = ['archives'] // needs apply plugin 'com.jfrog.bintray' to work - - pkg { - repo = 'maven' - name = 'android-oauth-handler' - userOrg = 'codepath' - licenses = ['Apache-2.0'] - vcsUrl = 'https://github.com/codepath/android-oauth-handler.git' - version { - name = BASE_VERSION - desc = POM_NAME - released = new Date() - vcsTag = VERSION_NAME +afterEvaluate { + publishing { + publications { + // Creates a Maven publication called "release". + release(MavenPublication) { + // Applies the component for the release build variant. + from components.release + + // You can then customize attributes of the publication as shown below. + groupId = GROUP + artifactId = POM_ARTIFACT_ID + version = VERSION_NAME + + pom { + name = POM_NAME + url = POM_URL + description = POM_DESCRIPTION + licenses { + license { + name = POM_LICENCE_NAME + url = POM_LICENCE_URL + } + } + developers { + developer { + id = POM_DEVELOPER_ID + name = POM_DEVELOPER_NAME + } + } + scm { + url = POM_SCM_URL + } + } + } + } + repositories { + maven { + name = "Sonatype" + credentials { + username = System.getenv('NEXUS_USERNAME') + password = System.getenv('NEXUS_PASSWORD') + } + def releasesRepoUrl = 'https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/' + def snapshotsRepoUrl = 'https://s01.oss.sonatype.org/content/repositories/snapshots/' + url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl + setUrl(url) + } } } +} +signing { + // gpg on MacOS is the same as gpg2 + // ln -s /usr/local/bin/gpg /usr/local/bin/gpg2 + // Make sure to populate the variables in gradle.properties + // signing.gnupg.keyName=XXX + // signing.gnupg.passpharse + useGpgCmd() + sign(publishing.publications) } task sourcesJar(type: Jar) { @@ -86,22 +123,22 @@ artifacts { } ext { - supportVersion = '28.0.0' + supportVersion = '28.0.0' } dependencies { - api "androidx.appcompat:appcompat:1.0.2" - api 'com.codepath.libraries:asynchttpclient:0.0.8' + api "androidx.appcompat:appcompat:1.3.0" + api 'com.codepath.libraries:asynchttpclient:2.1.1' api 'com.github.scribejava:scribejava-apis:4.1.1' api 'com.github.scribejava:scribejava-httpclient-okhttp:4.1.1' implementation 'se.akerfeldt:okhttp-signpost:1.1.0' implementation 'oauth.signpost:signpost-core:1.2.1.2' implementation 'com.facebook.stetho:stetho:1.5.1' implementation 'com.facebook.stetho:stetho-okhttp3:1.5.1' - implementation "com.squareup.okhttp3:logging-interceptor:4.1.0" + implementation "com.squareup.okhttp3:logging-interceptor:4.7.2" } -/*task jar(type: Jar) { +task jar(type: Jar) { from android.sourceSets.main.java.srcDirs -}*/ +} diff --git a/library/src/main/java/com/codepath/oauth/OAuthTokenClient.java b/library/src/main/java/com/codepath/oauth/OAuthTokenClient.java index 03629b4..d76079d 100755 --- a/library/src/main/java/com/codepath/oauth/OAuthTokenClient.java +++ b/library/src/main/java/com/codepath/oauth/OAuthTokenClient.java @@ -34,12 +34,20 @@ public OAuthTokenClient(BaseApi apiInstance, String consumerKey, String consumer this.apiInstance = apiInstance; this.handler = handler; if (callbackUrl == null) { callbackUrl = OAuthConstants.OUT_OF_BAND; }; - this.service = new ServiceBuilder() + if(scope == null) { + this.service = new ServiceBuilder() + .apiKey(consumerKey) + .apiSecret(consumerSecret).callback(callbackUrl) + .httpClientConfig(OkHttpHttpClientConfig.defaultConfig()) + .build(apiInstance); + } else { + this.service = new ServiceBuilder() .apiKey(consumerKey) .apiSecret(consumerSecret).callback(callbackUrl) .httpClientConfig(OkHttpHttpClientConfig.defaultConfig()) .scope(scope) // OAuth2 requires scope .build(apiInstance); + } } // Get a request token and the authorization url