为“Ballerina.toml”中的“repository”元素设置什么值才能从 Ballerina Central 获取依赖项?

问题描述 投票:0回答:1

Ballerina.toml
中指定依赖项时,应为
repository
元素设置什么值才能从 Ballerina Central 获取依赖项?为了清楚起见,请考虑下面的示例

[[dependency]]
org = "ballerinax"
name = "googleapis.gmail"
version = "2.1.1"
repository = "local"
dependencies ballerina ballerina-swan-lake
1个回答
0
投票

在 Ballerina 中,

repository
中的
Ballerina.toml
元素用于指定从何处获取依赖项。配置依赖项时,如果某个包标有
repository = "local"
,则表示当前包仅应考虑本地存储库中的包(在 Ballerina.toml 的依赖项部分中指定)。

对于未明确标记为

repository = "local"
的所有其他包,Ballerina 将在中央存储库中查找它们。这些依赖项存储在本地的
./.ballerina
文件夹中。如果本地没有找到所需的包,Ballerina 会自动从 Ballerina Central 获取并保存在本地存储库中。

要解析来自 Ballerina Central 的包,您可以在 .bal 文件中添加导入语句,如下例所示:

import ballerinax/twitter;

接下来,您可以执行命令

bal pull <package-org>/<package-name>:<version> --repository <repository-id> 
或使用
bal build
命令。此过程可确保从 Ballerina Central 获取必要的依赖项并将其包含在您的项目中。

© www.soinside.com 2019 - 2024. All rights reserved.