发布 Android 库并使用另一个模块作为依赖项

问题描述 投票:0回答:1

我的项目结构包含 3 个模块:

:library
:shared
:internal

它们之间的依赖关系如下:

:library
--取决于-->
:internal
通过实现
:library
--取决于-->
:shared
通过 api
:internal
--取决于-->
:shared
通过 实现

因此,

:library
使用
:internal
without暴露它和
:shared
暴露它。 此外,
:internal
也使用
:shared


问题: 如何使用

:library
Gradle 插件发布
maven-publish
模块并包含其他模块源?

目前,我的发布看起来像这样(:library

build.gradle.kts
):

publishing {
    publications {
        register<MavenPublication>("release") {
            groupId = Project.GROUP_ID
            artifactId = Project.ARTIFACT_ID
            version = Project.VERSION
            from(components["release"])
        }
    }
}

但是在发布(我使用 JitPack)并将其添加为另一个项目的 build.gradle 文件中的依赖项之后,我在尝试构建它时遇到以下错误:

> Could not resolve all files for configuration ':app:debugCompileClasspath'.
   > Could not find [:shared module].
     Required by:
         project :app > [`:library` module]

如何向已发布的模块提供我的依赖模块?

android gradle maven-publish
1个回答
0
投票

我认为这可行:

https://medium.com/@zakir01913/android-library-distribution-with-multiple-modules-and-flavors-to-maven-local-dcbb75bc52eb

我面临同样的问题,我正在尝试不同的方法来解决它,这看起来很不错,尚未测试,但看起来非常接近可能的解决方案。

© www.soinside.com 2019 - 2024. All rights reserved.