分叉monorepo,并使用Jitpack构建子目录?

时间:2019-07-02 20:09:52

标签: android gradle adaptive-cards jitpack

我正尝试派生Microsoft的Adaptive Cards存储库,并使用jitpack.io将我的派生包含在Android项目中。这里的挑战是Android项目不在项目的根目录中。它位于source/android下。至少我认为这是我的问题。

查看我的fork和新功能分支的jitpack构建日志,我可以看到它正在找到repo和branch,但是构建失败并显示以下错误消息:

Android project not found. Looking for AndroidManifest.xml and project.properties.
Build tool exit code: 0
Looking for artifacts...
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8 -Dhttps.protocols=TLSv1.2
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8 -Dhttps.protocols=TLSv1.2
Looking for pom.xml in build directory and ~/.m2
2019-07-02T19:10:51.036415693Z
Exit code: 0

ERROR: No build artifacts found

完整的构建日志: https://jitpack.io/com/github/synchealth/AdaptiveCards/feature~custom-typeface-custom-typeface-gbd45cf5-1/build.log

很明显jitpack不在相关子目录中找到Android项目。

这是我通过gradle包含依赖项的方式:

implementation 'com.github.synchealth:AdaptiveCards:feature~custom-typeface-SNAPSHOT'

但是,这给我带来了Gradle错误:ERROR: Failed to resolve: com.github,这很奇怪。

要包含原始存储库,这就是我拥有的:

implementation 'io.adaptivecards:adaptivecards-android:1.2.0'

在这里,adaptivecards-android是在生成的pom.xml中指定的工件ID,但是在尝试从github解析软件包时,我不确定如何或是否应该使用此工件ID。我尝试过也尝试过

implementation 'com.github.synchealth:AdaptiveCards:adaptivecards-android:feature~custom-typeface-SNAPSHOT'

但是我在Gradle中又遇到了一个ERROR: failed to resolve错误。

派生此存储库并将我要构建的子目录通知jitpack的正确方法是什么?

1 个答案:

答案 0 :(得分:1)

虽然代码托管在github上,但是编译后的库很可能是从jcenter或google上获取的。如果您查看其他build.gradle文件,将会看到以下内容:

repositories {
    jcenter()
    google()
}

您的项目将在这些地方查找其依赖项。最简单的解决方案是编译库的版本并将其本地添加到lib文件夹中。您可以将其添加为依赖项,并将jar文件添加到libs文件夹:

implementation fileTree(include: ['*.jar'], dir: 'libs')

或者如果它被编译为.aar(Android存档)

implementation fileTree(include: ['*.aar'], dir: 'libs')