From 6f51c2073dc74ee5cac3515e4bc6478d819fc03f Mon Sep 17 00:00:00 2001 From: Salomon BRYS Date: Wed, 3 Feb 2021 15:50:49 +0100 Subject: [PATCH] No more internal imports in Gradle build. --- build.gradle.kts | 48 ++++++++++++++++++++++++++++++++---------------- 1 file changed, 32 insertions(+), 16 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 26accd3..99c03f8 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,9 +1,10 @@ -import org.gradle.internal.impldep.org.apache.http.auth.UsernamePasswordCredentials -import org.gradle.internal.impldep.org.apache.http.client.methods.HttpPost -import org.gradle.internal.impldep.org.apache.http.entity.ContentType -import org.gradle.internal.impldep.org.apache.http.entity.StringEntity -import org.gradle.internal.impldep.org.apache.http.impl.auth.BasicScheme -import org.gradle.internal.impldep.org.apache.http.impl.client.HttpClients +import io.ktor.client.HttpClient +import io.ktor.client.features.auth.Auth +import io.ktor.client.features.auth.providers.basic +import io.ktor.client.request.post +import io.ktor.content.TextContent +import io.ktor.http.ContentType +import kotlinx.coroutines.runBlocking plugins { id("com.android.library") @@ -11,6 +12,14 @@ plugins { `maven-publish` } +buildscript { + dependencies { + val ktorVersion = "1.3.1" + classpath("io.ktor:ktor-client-okhttp:$ktorVersion") + classpath("io.ktor:ktor-client-auth-jvm:$ktorVersion") + } +} + group = "fr.acinq.tor" version = "0.1.0" @@ -160,14 +169,22 @@ publishing { } if (hasBintray) { + val client = HttpClient() { + install(Auth) { + basic { + username = bintrayUsername!! + password = bintrayApiKey!! + } + } + } + val postBintrayPublish by tasks.creating { group = "bintray" doLast { - HttpClients.createDefault().use { client -> - client.execute(HttpPost("https://api.bintray.com/content/acinq/$bintrayRepo/${rootProject.name}/$bintrayVersion/publish").apply { - addHeader(BasicScheme().authenticate(UsernamePasswordCredentials(bintrayUsername, bintrayApiKey), this, null)) - entity = StringEntity("{}", ContentType.APPLICATION_JSON) - }) + runBlocking { + client.post("https://api.bintray.com/content/acinq/$bintrayRepo/${rootProject.name}/$bintrayVersion/publish") { + body = TextContent("{}", ContentType.Application.Json) + } } } } @@ -175,11 +192,10 @@ if (hasBintray) { val postBintrayDiscard by tasks.creating { group = "bintray" doLast { - HttpClients.createDefault().use { client -> - client.execute(HttpPost("https://api.bintray.com/content/acinq/$bintrayRepo/${rootProject.name}/$bintrayVersion/publish").apply { - addHeader(BasicScheme().authenticate(UsernamePasswordCredentials(bintrayUsername, bintrayApiKey), this, null)) - entity = StringEntity("{ \"discard\": true }", ContentType.APPLICATION_JSON) - }) + runBlocking { + client.post("https://api.bintray.com/content/acinq/$bintrayRepo/${rootProject.name}/$bintrayVersion/publish") { + body = TextContent("{ \"discard\": true }", ContentType.Application.Json) + } } } }