Gradle:API vs API Project()差异

发布于 2025-02-09 23:00:19 字数 327 浏览 1 评论 0原文

我是Gradle的新手,但在Maven方面有很好的经验。 我想知道下面这两个之间有什么区别。

api project(':my-prj-1') 

VS

api "com.mydomain:grpc-helper:${grpc-helperVersion}"

我可以看到,在使用项目时,我只是给出项目名称而不是文物详细信息。

因此,我什么时候或何时可以使用API项目,与Just api相比有什么区别。在这种情况下,与Maven有任何比较。

I am quite new to gradle but have good experience with maven.
I am wondering what is the difference between these two below.

api project(':my-prj-1') 

vs

api "com.mydomain:grpc-helper:${grpc-helperVersion}"

I can see that when using project, i am giving just the project name not the artifactory details.

So when should or when can i use api project and what is the difference compared with just api. And in this case is there any comparison possible with Maven.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夜吻♂芭芘 2025-02-16 23:00:19

(对不起,我的英语不好)

我想您有一个名为myprj-1的子项目,可以构建sub-artifact com.mydomain:grpc-helper

API Project(':MyPrj-1'),当您构建主项目时,子项目还将构建,其工件将在主项目中使用。 (1)

作者:api“ com.mydomain:grpc-helper:$ {grpc-helperversion}”,主项目将仅尝试从存储库中找到工件,如果子项目不在构建还将失败。 (2)

根据我的经验,我更喜欢第一种方法,因为它更安全。如果已经构建了子图片,则跳过了子项目构建(由于增量构建),因此第二种方法没有性能差异。

(Sorry for my poor English)

I suppose you have a sub-project named my-prj-1 that can build the sub-artifact com.mydomain:grpc-helper.

By api project(':my-prj-1'), when you build the main project, the sub-project will also get built and its artifact will be used in the main project. (1)

By api "com.mydomain:grpc-helper:${grpc-helperVersion}", the main project will try to find the artifact from the repository only, if the sub-project is not built yet, the build will fail. (2)

From my experience, I would prefer the first approach since it a little bit safer. If the sub-artifact is already built then the sub-project build is skipped (due to incremental build) so there are no performance differences from the second approach.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文