简体   繁体   English

Android库可与本地Maven存储库一起使用

[英]Android library to work with local maven repository

I have an Android app which uses a library of my own. 我有一个使用我自己的库的Android应用。 I am developing them at the same time so when I have a change in my library I want to test it in my app as well. 我同时开发它们,所以当我在库中进行更改时,我也想在我的应用程序中对其进行测试。

They are setup as different projects since my library will also be used by other developers. 由于我的库也将由其他开发人员使用,因此将它们设置为不同的项目。 The way we work is we build the library using a CI platform adn deploy it to an artifactory server. 我们的工作方式是使用CI平台构建库并将其部署到人工服务器。

Then from the app I reference this library directly through artifactory. 然后从应用程序中,我直接通过人工制品引用该库。 This way when my CI platform builds the app, the build process takes the lib from artifactory and CI works smoothly. 这样,当我的CI平台构建应用程序时,构建过程就会从工件中获取库文件,并且CI可以顺利进行。

This is a good way to work but is a pain in the ass when developing them in parallel, because I have to commit the changes, create a pull request, merge it with the development branch and wait for CI to build it and deploy it on the artifactory server, just so I can test it on the app. 这是一种很好的工作方式,但是在并行开发它们时会很麻烦,因为我必须提交更改,创建拉取请求,将其与开发分支合并,并等待CI进行构建并将其部署在人工服务器,以便我可以在应用程序上对其进行测试。

Coming from java EE development, I used maven install, which deploys the artifact in the local maven repo, then I could already use it from my web application. 来自java EE开发,我使用了maven install,它将工件部署在本地maven存储库中,然后我就可以在Web应用程序中使用它了。

I want to do soemthing similar, ie have gradle deploy my artifact on my local repo, so the artifact on the local repo is updated but not on the remote one. 我想做类似的事情,即让gradle将我的工件部署到我的本地仓库上,这样就可以更新本地仓库上的工件,而不是在远程仓库上。 This way I can debug more easily while still keeping the CI setup in place. 这样,我可以更轻松地调试,同时仍然保持CI设置。

But I have no idea how to do this on gradle. 但我不知道如何在gradle上执行此操作。 The artifactory plugin seems like it only allows deployment on an artifactory server. 人工插件似乎只允许在人工服务器上进行部署。

any ideas? 有任何想法吗?

If you're using the maven plugin, you can run the install task to deploy the artifacts to your local Maven repo [1]. 如果使用的是maven插件,则可以运行安装任务以将工件部署到本地Maven存储库[1]。 After you have the Artifacts deployed to your local maven repo, you need to add mavenLocal() [2] as one of the repositories to be able to resolve the dependency. 将工件部署到本地Maven存储库后,需要添加mavenLocal() [2]作为存储库之一,以便能够解决依赖关系。 One strategy I use is to always set a custom version for my local copy so that I can be certain that the local version is getting picked up - but if you choose not to do that the dependencies get resolved in the order the repositories are listed (so you'll need to ensure mavenLocal is before your Artifactory server). 我使用的一种策略是始终为本地副本设置自定义版本,以便可以确定已获取本地版本-但是,如果您选择不这样做,则将按照列出存储库的顺序解析依赖项(因此,您需要确保mavenLocal位于Artifactory服务器之前)。

[1] https://docs.gradle.org/current/userguide/maven_plugin.html , https://github.com/dcendents/android-maven-gradle-plugin [1] https://docs.gradle.org/current/userguide/maven_plugin.htmlhttps://github.com/dcendents/android-maven-gradle-plugin

[2] https://discuss.gradle.org/t/how-to-use-maven-local-repository-for-gradle-build/2244 [2] https://discuss.gradle.org/t/how-to-use-maven-local-repository-for-gradle-build/2244

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

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