如何运行改造源代码?

时间:2017-11-28 12:57:28

标签: android android-studio intellij-idea retrofit retrofit2

我对Retrofit源代码感兴趣。

https://github.com/square/retrofit

但我发现无处可告诉我如何运行源代码。

我从IntelliJ IDEA或Android Studio导入源代码,源代码的根目录和目录'sample'。

但是没有一个能成功运行。

有几个pom.xml文件。

任何人都知道如何运行这些代码?

修改 评论说这是一个图书馆,无法运行。当我在使用build.gradle导入它的android项目中使用它时,我们只导入这个库。

所以我的问题是:

  1. 如何使用maven导入它?

  2. 这个库的维护者如何维护这个库,我认为它至少是可调试的,可以打破一个观点。应该有一些测试用例来测试这个库,如何运行测试用例?

  3. 如何阅读源代码?

1 个答案:

答案 0 :(得分:2)

Maven Central中提供了Retrofit源代码: https://search.maven.org/#search|gav|1|g%3A%22com.squareup.retrofit2%22%20AND%20a%3A%22retrofit%22(sources.jar)。

如果您使用Maven,如果您浏览课程,它将自动下载到Android Studio中。

我在我的一个Android项目中使用了这个库:https://github.com/ghusta/android-docker-search

要在Android中导入,请在app/build.gradle中添加类似内容:

dependencies {

    implementation 'com.squareup.retrofit2:retrofit:2.3.0'
    implementation 'com.squareup.retrofit2:converter-jackson:2.3.0'
    ...
}

不要忘记包含jcenter()Maven repo(https://developer.android.com/studio/build/index.html#top-level)。