1
0
Fork 0
mirror of https://github.com/ethauvin/kobalt.git synced 2025-04-26 00:17:11 -07:00

Minor fixes to KobaltClient.

This commit is contained in:
Cedric Beust 2016-06-01 21:07:58 -08:00
parent 0dd42bf3d4
commit 9e8d335a05

View file

@ -17,6 +17,7 @@ import okhttp3.OkHttpClient
import retrofit2.Call import retrofit2.Call
import retrofit2.Retrofit import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory import retrofit2.converter.gson.GsonConverterFactory
import retrofit2.http.GET
import retrofit2.http.POST import retrofit2.http.POST
import retrofit2.http.Query import retrofit2.http.Query
import java.io.* import java.io.*
@ -31,7 +32,10 @@ fun main(argv: Array<String>) {
} }
interface Api { interface Api {
@POST("/getDependencies") @GET("/ping")
fun ping() : Call<String>
@POST("/v0/getDependencies")
fun getDependencies(@Query("buildFile") buildFile: String) : Call<List<DependencyData.GetDependenciesData>> fun getDependencies(@Query("buildFile") buildFile: String) : Call<List<DependencyData.GetDependenciesData>>
} }
@ -40,16 +44,25 @@ class KobaltClient : Runnable {
private val service = Retrofit.Builder() private val service = Retrofit.Builder()
.client(OkHttpClient.Builder().build()) .client(OkHttpClient.Builder().build())
.baseUrl("http://localhost:1252") .baseUrl("http://localhost:1238")
.addConverterFactory(GsonConverterFactory.create()) .addConverterFactory(GsonConverterFactory.create())
.build() .build()
.create(Api::class.java) .create(Api::class.java)
override fun run() { override fun run() {
// val pong = service.ping().execute()
// println("Result from ping: " + pong)
val buildFile = Paths.get(SystemProperties.homeDir, "kotlin/klaxon/kobalt/src/Build.kt").toString() val buildFile = Paths.get(SystemProperties.homeDir, "kotlin/klaxon/kobalt/src/Build.kt").toString()
val dependencies = service.getDependencies(buildFile) val dependencies = service.getDependencies(buildFile)
val results = dependencies.execute() val response = dependencies.execute()
println("Dependencies: $results") if (response.isSuccessful) {
println("Dependencies: $response")
} else {
println("Error calling getDependencies: " + response.errorBody().string())
}
println("")
} }
} }