简体   繁体   English

将Android库发布到依赖本地Android库项目的Maven

[英]Publish Android library to Maven that depends on a local Android library project

I have a library project, libParent , that includes another library project, libChild , as a dependency. 我有一个库项目libParent ,其中包括另一个库项目libChild作为依赖项。 If you look at the build.gradle dependencies section, you will see something like the following: 如果查看build.gradle依赖项部分,将看到类似以下内容:

dependencies {
    ...

    compile project(':libChild')
}

Now, I want to publish libParent to maven as an aar file. 现在,我想将libParent作为aar文件发布到maven。 Note that libChild has not been published, but I would like to include its sources/resources within libParent 's artificat. 请注意, libChild尚未发布,但是我想将其源代码/资源包括在libParent The maven publishing section of my build.gradle file looks like the following: 我的build.gradle文件的maven发布部分如下所示:

task sourcesJar(type: Jar) {
    from android.sourceSets.main.java.srcDirs
    classifier = 'sources'
}

task javadoc(type: Javadoc) {
    source = android.sourceSets.main.java.srcDirs
    classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
}

task javadocJar(type: Jar, dependsOn: javadoc) {
    classifier = 'javadoc'
    from javadoc.destinationDir
}

artifacts {
    archives javadocJar
    archives sourcesJar
}

Once I publish my module and include it as a dependency in my app, I get the following error: 一旦发布模块并将其作为依赖项包含在我的应用程序中,就会收到以下错误:

Could not find 'libParent:libChild:unspecified'
     Searched in the following locations:
     https://oss.sonatype.org/content/respositories/snapshots/libParent/libChild/unspecified/libChild-unspecified.pom

I know that libChild is not getting baked into my published artifact, but how do I go about making sure that the sources/resources of libChild get included? 我知道libChild不会融入我发布的工件中,但是如何确保libChild的源/资源包括在内?

You can't do it. 你做不到

If a library has a dependency, the pom file of the parent lib will contain this dependency. 如果库具有依赖项,则父库的pom文件将包含此依赖项。

You can't resolve this dependency including the sources/resources. 您无法解决包括源/资源在内的这种依赖性。
You have to publish also the child lib. 您还必须发布子库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM