发布具有外部依赖项的 Android 库
Publish Android library with external dependencies
我有一个 Android 闭源模块,将在其他项目中用作库。它包含外部依赖项。
为了发布它,我正在使用以下 gradle 任务创建一个 Maven 工件:
apply plugin: 'maven'
def coreAarFile = file('...build\outputs\aar\android-sdk-release.aar')
artifacts {
archives coreAarFile
}
uploadArchives {
repositories.mavenDeployer {
repository(url: "file://.\mvn-repo")
pom.project {
groupId 'a.blabla'
artifactId 'blabla-sdk'
version "1.0.0"
}
}
}
它可以毫无问题地生成 .aar 文件、pom.xml 等。
然后我创建了一个项目,该项目对我声明的库具有依赖性。它一直工作到需要访问外部依赖项时抛出 class 未找到异常。
如何编辑我的 gradle 任务以包含外部依赖项或至少对它们的引用?它们发表在 mvnrepository.com 和 github.com.
我将 uploadArchives 移动到模块的 build.gradle 并删除了 artifacts 元素。有效!
感谢CommonsWare指点正确的方向
我有一个 Android 闭源模块,将在其他项目中用作库。它包含外部依赖项。
为了发布它,我正在使用以下 gradle 任务创建一个 Maven 工件:
apply plugin: 'maven'
def coreAarFile = file('...build\outputs\aar\android-sdk-release.aar')
artifacts {
archives coreAarFile
}
uploadArchives {
repositories.mavenDeployer {
repository(url: "file://.\mvn-repo")
pom.project {
groupId 'a.blabla'
artifactId 'blabla-sdk'
version "1.0.0"
}
}
}
它可以毫无问题地生成 .aar 文件、pom.xml 等。
然后我创建了一个项目,该项目对我声明的库具有依赖性。它一直工作到需要访问外部依赖项时抛出 class 未找到异常。
如何编辑我的 gradle 任务以包含外部依赖项或至少对它们的引用?它们发表在 mvnrepository.com 和 github.com.
我将 uploadArchives 移动到模块的 build.gradle 并删除了 artifacts 元素。有效!
感谢CommonsWare指点正确的方向