发布到maven reporsitory

时间:2016-12-22 03:58:01

标签: java maven gradle android-gradle

当我编译带有依赖项DemoProject:demo的{​​{1}}时,它失败并出现以下错误提示:

compile 'cn.dreamtobe.android.phone:sdkproject-library:1.0.1

所以真正的问题是:

如何将Download http://mymaven.dreamtobe.cn:8081/artifactory/content/repositories/mobile/cn/dreamtobe/android/phone/sdkproject-library/1.0.0/sdkproject-library-1.0.1.pom FAILURE: Build failed with an exception. * What went wrong: A problem occurred configuring project ':demo'. > Could not resolve all dependencies for configuration ':demo:_debugCompile'. > Could not find SDKProject:api:unspecified. Searched in the following locations: file:/Users/Jacksgong/.m2/repository/SDKProject/api/unspecified/api-unspecified.pom file:/Users/Jacksgong/.m2/repository/SDKProject/api/unspecified/api-unspecified.jar https://jcenter.bintray.com/SDKProject/api/unspecified/api-unspecified.pom https://jcenter.bintray.com/SDKProject/api/unspecified/api-unspecified.jar Required by: DemoProject:demo:unspecified > cn.dreamtobe.android.phone:sdkproject-library:1.0.1 * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. BUILD FAILED Total time: 42.323 secs 模块的内容放在一起,而不是在将:api模块发布到maven repo时在.pom文件中声明它。

  

因为我们在DemoProject中找不到它,因为:libray只能在SDKProject中识别

我的SDKProject层次结构是:

':api'

library-module 依赖于 api-module ,下面是 library-module 中的SDKProject |- library module(`:library`) |- api module(`:api`)

build.gradle

SDKProject根目录中的... dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" compile project(':api') } ext { GROUP_ID = GROUP POM_ARTIFACT_ID = IMPL_POM_ARTIFACT } apply from: '../upload.gradle' 脚本:

upload.gradle

1 个答案:

答案 0 :(得分:0)

我自己通过flat-aar解决了这个问题。

另一种方法是将Apis代码和Impls代码放在同一个模块中,并写入gradle | ike this:publishing multiple modules to maven,这样,gradle脚本会将Api和Impl过滤为两个模块。

最后

我为此问题创建了两个示例演示:https://github.com/Jacksgong/gralde-sample