Search in sources :

Example 1 with Dependency

use of org.ballerinalang.toml.model.Dependency in project ballerina by ballerina-lang.

the class ManifestBuildListener method createDependencyObject.

/**
 * Create dependency object and set the name.
 *
 * @param packageName pkg name of the dependency
 */
private void createDependencyObject(String packageName) {
    dependency = new Dependency();
    DependencyField dependencyField = DependencyField.NAME;
    if (dependencyField != null) {
        dependencyField.setValueTo(dependency, packageName);
    }
}
Also used : DependencyField(org.ballerinalang.toml.model.fields.DependencyField) Dependency(org.ballerinalang.toml.model.Dependency)

Example 2 with Dependency

use of org.ballerinalang.toml.model.Dependency in project ballerina by ballerina-lang.

the class PackageLoader method updateVersionFromToml.

private void updateVersionFromToml(PackageID pkgId) {
    String orgName = pkgId.orgName.value;
    String pkgName = pkgId.name.value;
    String pkgAlias = orgName + "/" + pkgName;
    // TODO: make getDependencies return a map
    Optional<Dependency> dependency = manifest.getDependencies().stream().filter(d -> d.getPackageName().equals(pkgAlias)).findFirst();
    if (dependency.isPresent()) {
        if (pkgId.version.value.isEmpty()) {
            pkgId.version = new Name(dependency.get().getVersion());
        } else {
            throw new BLangCompilerException("dependency version in Ballerina.toml mismatches" + " with the version in the source for package " + pkgAlias);
        }
    }
}
Also used : SystemPackageRepositoryProvider(org.ballerinalang.spi.SystemPackageRepositoryProvider) Arrays(java.util.Arrays) PackageSource(org.ballerinalang.repository.PackageSource) BLangIdentifier(org.wso2.ballerinalang.compiler.tree.BLangIdentifier) PROJECT_DIR(org.ballerinalang.compiler.CompilerOptionName.PROJECT_DIR) BLangImportPackage(org.wso2.ballerinalang.compiler.tree.BLangImportPackage) IdentifierNode(org.ballerinalang.model.tree.IdentifierNode) Converter(org.wso2.ballerinalang.compiler.packaging.converters.Converter) Names(org.wso2.ballerinalang.compiler.util.Names) RepoHierarchy(org.wso2.ballerinalang.compiler.packaging.RepoHierarchy) URI(java.net.URI) Path(java.nio.file.Path) ProjectSourceRepo(org.wso2.ballerinalang.compiler.packaging.repo.ProjectSourceRepo) PackageID(org.ballerinalang.model.elements.PackageID) Set(java.util.Set) ServiceLoader(java.util.ServiceLoader) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) List(java.util.List) Manifest(org.ballerinalang.toml.model.Manifest) OFFLINE(org.ballerinalang.compiler.CompilerOptionName.OFFLINE) Resolution(org.wso2.ballerinalang.compiler.packaging.Resolution) RepoHierarchyBuilder(org.wso2.ballerinalang.compiler.packaging.RepoHierarchyBuilder) Optional(java.util.Optional) SymbolEnter(org.wso2.ballerinalang.compiler.semantics.analyzer.SymbolEnter) CompilerOptions(org.wso2.ballerinalang.compiler.util.CompilerOptions) ManifestProcessor(org.ballerinalang.toml.parser.ManifestProcessor) RemoteRepo(org.wso2.ballerinalang.compiler.packaging.repo.RemoteRepo) ArrayList(java.util.ArrayList) Dependency(org.ballerinalang.toml.model.Dependency) RepoHierarchyBuilder.node(org.wso2.ballerinalang.compiler.packaging.RepoHierarchyBuilder.node) HomeRepoUtils(org.wso2.ballerinalang.util.HomeRepoUtils) PackageRepository(org.ballerinalang.repository.PackageRepository) Repo(org.wso2.ballerinalang.compiler.packaging.repo.Repo) TreeBuilder(org.ballerinalang.model.TreeBuilder) ProgramingSourceRepo(org.wso2.ballerinalang.compiler.packaging.repo.ProgramingSourceRepo) ProjectDirs(org.wso2.ballerinalang.compiler.util.ProjectDirs) StreamSupport(java.util.stream.StreamSupport) BLangPackage(org.wso2.ballerinalang.compiler.tree.BLangPackage) BLangCompilerException(org.ballerinalang.compiler.BLangCompilerException) Name(org.wso2.ballerinalang.compiler.util.Name) ZipRepo(org.wso2.ballerinalang.compiler.packaging.repo.ZipRepo) PackageEntity(org.ballerinalang.repository.PackageEntity) Parser(org.wso2.ballerinalang.compiler.parser.Parser) Paths(java.nio.file.Paths) GenericPackageSource(org.wso2.ballerinalang.compiler.packaging.GenericPackageSource) CacheRepo(org.wso2.ballerinalang.compiler.packaging.repo.CacheRepo) Collections(java.util.Collections) CompilerContext(org.wso2.ballerinalang.compiler.util.CompilerContext) BLangCompilerException(org.ballerinalang.compiler.BLangCompilerException) Dependency(org.ballerinalang.toml.model.Dependency) Name(org.wso2.ballerinalang.compiler.util.Name)

Aggregations

Dependency (org.ballerinalang.toml.model.Dependency)2 URI (java.net.URI)1 Path (java.nio.file.Path)1 Paths (java.nio.file.Paths)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 List (java.util.List)1 Objects (java.util.Objects)1 Optional (java.util.Optional)1 ServiceLoader (java.util.ServiceLoader)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 StreamSupport (java.util.stream.StreamSupport)1 BLangCompilerException (org.ballerinalang.compiler.BLangCompilerException)1 OFFLINE (org.ballerinalang.compiler.CompilerOptionName.OFFLINE)1 PROJECT_DIR (org.ballerinalang.compiler.CompilerOptionName.PROJECT_DIR)1 TreeBuilder (org.ballerinalang.model.TreeBuilder)1 PackageID (org.ballerinalang.model.elements.PackageID)1 IdentifierNode (org.ballerinalang.model.tree.IdentifierNode)1