diff --git a/.idea/libraries/kobalt__Compile_.xml b/.idea/libraries/kobalt__Compile_.xml index 3bdcbd12..4d66b436 100644 --- a/.idea/libraries/kobalt__Compile_.xml +++ b/.idea/libraries/kobalt__Compile_.xml @@ -5,8 +5,6 @@ - - diff --git a/.idea/libraries/kobalt_plugin_api__Compile_.xml b/.idea/libraries/kobalt_plugin_api__Compile_.xml index e4d02488..8c4fc324 100644 --- a/.idea/libraries/kobalt_plugin_api__Compile_.xml +++ b/.idea/libraries/kobalt_plugin_api__Compile_.xml @@ -7,8 +7,6 @@ - - @@ -17,6 +15,7 @@ + diff --git a/kobalt/src/Build.kt b/kobalt/src/Build.kt index bcc48039..15e2abe6 100644 --- a/kobalt/src/Build.kt +++ b/kobalt/src/Build.kt @@ -62,7 +62,6 @@ val kobaltPluginApi = project { dependencies { compile("org.jetbrains.kotlinx:kotlinx.dom:0.0.9", - "com.squareup.okio:okio:1.6.0", "com.google.inject:guice:4.0", "com.google.inject.extensions:guice-assistedinject:4.0", "javax.inject:javax.inject:1", @@ -70,8 +69,8 @@ val kobaltPluginApi = project { "org.apache.maven:maven-model:3.3.3", "io.reactivex:rxjava:1.0.16", "com.google.code.gson:gson:2.4", + "com.squareup.okio:okio:1.6.0", "com.squareup.okhttp3:okhttp:3.2.0", - "com.squareup.retrofit:retrofit:1.9.0", "com.squareup.retrofit2:retrofit:2.0.0-beta4", "com.squareup.retrofit2:converter-gson:2.0.0-beta4", "com.beust:jcommander:1.48" diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/Http.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/Http.kt index db97b075..0ba0acca 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/Http.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/maven/Http.kt @@ -4,12 +4,14 @@ import com.beust.kobalt.KobaltException import com.beust.kobalt.misc.CountingFileRequestBody import com.beust.kobalt.misc.log import okhttp3.* -import retrofit.mime.TypedFile +import java.io.File import java.io.IOException import javax.inject.Singleton @Singleton class Http { + class TypedFile(val mimeType: String, val file: File) + fun get(user: String?, password: String?, url: String) : Response { val client = OkHttpClient() val request = Request.Builder().url(url) @@ -47,7 +49,7 @@ class Http { error: (Response) -> Unit = DEFAULT_ERROR_RESPONSE) { val fullHeaders = Headers.Builder() - fullHeaders.set("Content-Type", file.mimeType()) + fullHeaders.set("Content-Type", file.mimeType) headers.names().forEach { fullHeaders.set(it, headers.get(it)) } user?.let { @@ -59,9 +61,9 @@ class Http { .url(url) val request = (if (post) - requestBuilder.post(CountingFileRequestBody(file.file(), file.mimeType(), progressCallback)) + requestBuilder.post(CountingFileRequestBody(file.file, file.mimeType, progressCallback)) else - requestBuilder.put(CountingFileRequestBody(file.file(), file.mimeType(), progressCallback))) + requestBuilder.put(CountingFileRequestBody(file.file, file.mimeType, progressCallback))) .build() log(2, "Uploading $file to $url") diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/misc/GithubApi2.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/misc/GithubApi2.kt index 836d680b..19470351 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/misc/GithubApi2.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/misc/GithubApi2.kt @@ -5,8 +5,6 @@ import com.beust.kobalt.internal.DocUrl import com.beust.kobalt.maven.Http import com.google.gson.annotations.SerializedName import com.google.inject.Inject -import retrofit.RetrofitError -import retrofit.mime.TypedFile import retrofit2.Call import retrofit2.Retrofit import retrofit2.converter.gson.GsonConverterFactory @@ -73,13 +71,13 @@ class GithubApi2 @Inject constructor( .execute() .body() - uploadAsset(accessToken, response.uploadUrl!!, TypedFile("application/zip", zipFile), + uploadAsset(accessToken, response.uploadUrl!!, Http.TypedFile("application/zip", zipFile), tagName) .toBlocking() .forEach { action -> log(1, "\n${zipFile.name} successfully uploaded") } - } catch(e: RetrofitError) { + } catch(e: Exception) { throw KobaltException("Couldn't upload release: " + e.message, e) // val error = parseRetrofitError(e) // throw KobaltException("Couldn't upload release, ${error.message}: " @@ -87,13 +85,13 @@ class GithubApi2 @Inject constructor( } } - private fun uploadAsset(token: String, uploadUrl: String, typedFile: TypedFile, tagName: String) + private fun uploadAsset(token: String, uploadUrl: String, typedFile: Http.TypedFile, tagName: String) : Observable { val strippedUrl = uploadUrl.substring(0, uploadUrl.indexOf("{")) - val fileName = typedFile.file().name + val fileName = typedFile.file.name val url = "$strippedUrl?name=$fileName&label=$fileName" val headers = okhttp3.Headers.of("Authorization", "token $token") - val totalSize = typedFile.file().length() + val totalSize = typedFile.file.length() http.uploadFile(url = url, file = typedFile, headers = headers, post = true, // Github requires POST progressCallback = http.percentProgressCallback(totalSize)) @@ -123,7 +121,7 @@ class GithubApi2 @Inject constructor( throw KobaltException("Couldn't find the latest release") } } - } catch(e: RetrofitError) { + } catch(e: Exception) { log(1, "Couldn't retrieve releases from github: " + e.message) e.printStackTrace() // val error = parseRetrofitError(e) diff --git a/src/main/kotlin/com/beust/kobalt/plugin/publish/BintrayApi.kt b/src/main/kotlin/com/beust/kobalt/plugin/publish/BintrayApi.kt index bae55b8d..cae618ed 100644 --- a/src/main/kotlin/com/beust/kobalt/plugin/publish/BintrayApi.kt +++ b/src/main/kotlin/com/beust/kobalt/plugin/publish/BintrayApi.kt @@ -15,7 +15,6 @@ import com.google.gson.JsonObject import com.google.gson.JsonParser import com.google.inject.assistedinject.Assisted import okhttp3.Response -import retrofit.mime.TypedFile import java.io.File import javax.annotation.Nullable import javax.inject.Inject @@ -153,7 +152,7 @@ class BintrayApi @Inject constructor ( val results = arrayListOf() filesToUpload.forEach { file -> http.uploadFile(username, password, fileToPath(file) + optionPath, - TypedFile(MediaType.ANY_APPLICATION_TYPE.toString(), file), + Http.TypedFile(MediaType.ANY_APPLICATION_TYPE.toString(), file), post = false, // Bintray requires PUT success = { r: Response -> results.add(true) }, error = { r: Response ->