【问题标题】:Cannot install a published Java library无法安装已发布的 Java 库
【发布时间】:2019-06-12 17:48:25
【问题描述】:

我已经向https://bintray.com/tylerlong/maven/ringcentral-pubnub发布了一个java库

我尝试通过 gradle 使用它:

dependencies {
    ...

    compile 'com.ringcentral:ringcentral-pubnub:1.0.0-beta10'
}

当我运行./gradlew build 时,出现以下错误:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileJava'.
> Could not resolve all files for configuration ':compileClasspath'.
   > Could not find com.ringcentral:ringcentral-pubnub:1.0.0-beta10.
     Searched in the following locations:
       - https://jcenter.bintray.com/com/ringcentral/ringcentral-pubnub/1.0.0-beta10/ringcentral-pubnub-1.0.0-beta10.pom
       - https://jcenter.bintray.com/com/ringcentral/ringcentral-pubnub/1.0.0-beta10/ringcentral-pubnub-1.0.0-beta10.jar
     Required by:
         project :

这是build.gradle 文件:https://github.com/ringcentral/ringcentral-pubnub-java/blob/master/build.gradle

我真的不知道为什么它不起作用。我在这里有另一个图书馆,它就像一个魅力:https://bintray.com/tylerlong/maven/ringcentral。我以类似的方式发布了这两个库。为什么一个有效而另一个无效?

这里是重现问题的示例项目:https://github.com/tylerlong/ringcentral-pubnub-demo

【问题讨论】:

    标签: java maven bintray


    【解决方案1】:

    在给定的 Github 示例中;您需要配置 Gradle 构建以使用您的自定义(bintray)maven 存储库。使用当前设置,它只在 jcenter 中查找,并且您的依赖项在该存储库中不可用(因此出现错误)。

    确保您的构建包含:

    repositories {
        jcenter()
        maven {
          url 'https://dl.bintray.com/tylerlong/maven'
        }
    }
    

    关于

    为什么一个有效而另一个无效?

    也许你以不同的方式发布了“一个”和“另一个”;所以只有一个存在于正确的存储库中?或者,您的构建使用mavenLocal,并且您实际上在本地安装了一个 dep。无论如何-仔细检查你的回购!

    【讨论】:

    • 感谢您的回复。我的目标是允许用户从 jcenter() 下载我的库,而无需在构建脚本中添加任何自定义 url。我已经通过 ringcentral 库实现了目标。但是 ringcentral-pubnub 库不起作用。我需要找出根本原因。
    【解决方案2】:

    我做的一切都正确,但我忘记了最后一步:链接到 jcenter。

    参考:https://medium.com/@anitaa_1990/6-easy-steps-to-upload-your-android-library-to-bintray-jcenter-59e6030c8890

    我将包裹提交给 jcenter 后得到以下回复:

    您要求包含您的包裹 Bintray 的 JCenter 中的 /tylerlong/maven/ringcentral-pubnub 已经 批准。

    然后一切都像魅力一样!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-07-16
      • 1970-01-01
      • 2021-11-06
      • 2011-07-12
      • 2021-01-30
      相关资源
      最近更新 更多